environmentaltools.common.shp

environmentaltools.common.shp(file_name: str, joint: bool = False, variable: str = None)[source]

Read shapefile and extract geometry coordinates.

Reads shapefiles using geopandas and extracts coordinates from various geometry types (Point, Polygon, LineString, MultiPoint, MultiLineString, MultiPolygon).

Parameters:
  • file_name (str) – Path to shapefile.

  • joint (bool) – If True, concatenates all geometries into single DataFrame. Defaults to False (returns list of DataFrames).

  • variable (str, optional) – Additional attribute column to extract alongside coordinates. Defaults to None.

Returns:

If joint=True or single geometry, returns DataFrame

with columns [x, y] or [x, y, variable]. Otherwise returns list of DataFrames, one per geometry feature.

Return type:

pd.DataFrame or list

Raises:

ValueError – If geometry type cannot be processed with available methods.