Skip to content

Instantly share code, notes, and snippets.

View wam27's full-sized avatar

Wil wam27

  • Duke University
  • Durham, NC
  • 16:02 (UTC -12:00)
View GitHub Profile
@wam27
wam27 / geopandas_convert_geometry_3D_2D.py
Created June 23, 2022 04:35 — forked from rmania/geopandas_convert_geometry_3D_2D.py
flatten geometry series (3D to 2D) in geopandas dataframe
# Often when reading in a ShapeFile from Basemap, you'll get: "ValueError: readshapefile can only handle 2D shape types"
# A trick can be to convert your geometry in your GeoPandas Dataframe and restoring the new flattened 2D geometry
# series back into a shapefile and try again.
# edit from http://stackoverflow.com/questions/33417764/basemap-readshapefile-valueerror
from shapely.geometry import Polygon, MultiPolygon, shape, Point
import geopandas as gp
def convert_3D_2D(geometry):
'''