From ba7cbedd4e8fd4b42358786e9eff4c3cda49a302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6rsch?= Date: Wed, 17 Jan 2024 12:44:33 +0100 Subject: [PATCH] fix(as_pandas): Update srid detection code to latest shapely Adjusted to latest geopandas read-in at https://github.com/geopandas/geopandas/blob/fed9e57a0033dee6c18ce9da40dcd49e1211f876/geopandas/io/sql.py#L44-L97 --- saio.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/saio.py b/saio.py index a08d828..44c2c4c 100644 --- a/saio.py +++ b/saio.py @@ -124,8 +124,7 @@ def register_schema(schema, engine): try: import geopandas as gpd - import shapely.wkb - import shapely.geos + import shapely, shapely.wkb has_geopandas = True except ImportError: has_geopandas = False @@ -196,12 +195,11 @@ def as_pandas(query, index_col=None, coerce_float=True, params=None, else: load_geom = lambda s: shapely.wkb.loads(str(s), hex=hex_encoded) - srid = getattr(obj, 'srid', -1) - if srid == -1: - srid = shapely.geos.lgeos.GEOSGetSRID(load_geom(obj)._geom) - - if crs is None and srid != 0: - crs = dict(init="epsg:{}".format(srid)) + if crs is None: + srid = shapely.get_srid(load_geom(obj)) + # if no defined SRID in geodatabase, returns SRID of 0 + if srid != 0: + crs = "epsg:{}".format(srid) df[geometry] = df[geometry].map(load_geom)