libpysal.weights.get_ids

libpysal.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_shpsstr or geopandas.GeoDataFrame

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

idVariablestr

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

Returns:
idslist

a list of IDs

Examples

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