pysal.lib.weights.get_ids

pysal.lib.weights.get_ids(in_shps, idVariable)[source]

Gets the IDs from the DBF file that moves with a given shape file or a geopandas.GeoDataFrame.

Parameters:
in_shps : str or geopandas.GeoDataFrame

The input geographic data. Either (1) a path to a shapefile including suffix (str); or (2) a geopandas.GeoDataFrame.

idVariable : str

name of a column in the shapefile’s DBF or the geopandas.GeoDataFrame to use for ids.

Returns:
ids : list

a list of IDs

Examples

>>> from pysal.lib.weights.util import get_ids
>>> import pysal.lib
>>> polyids = get_ids(pysal.lib.examples.get_path("columbus.shp"), "POLYID")
>>> polyids[:5]
[1, 2, 3, 4, 5]
>>> from pysal.lib.weights.util import get_ids
>>> import pysal.lib
>>> import geopandas as gpd
>>> gdf = gpd.read_file(pysal.lib.examples.get_path("columbus.shp"))
>>> polyids = gdf["POLYID"]
>>> polyids[:5]
0    1
1    2
2    3
3    4
4    5
Name: POLYID, dtype: int64