I am moving my upload logic for features to GeoPandas. Amongst my features, I have one without a geometry. I can insert it into PostGIS like stated here Uploading a geodataframe with some missing geometries using 'to_postgis'
gdf = gpd.GeoDataFrame(df, crs="EPSG:25833", geometry=Polygon())
But this yields a POLYGON EMPTY
value in the geometry column.
I would like that it is NULL
in order to be consistent with the previous insert logic.
However, if I use
gdf = gpd.GeoDataFrame(df, geometry=None)
as should be possible, reading this post: https://geopandas.org/en/stable/docs/user_guide/missing_empty.html this yields an AttributeError: 'DataFrame' object has no attribute 'geometry' when calling gdf.to_postgis()
" File \"/home/api/.local/lib/python3.11/site-packages/geopandas/geodataframe.py\",
line 1931, in to_postgis",
" geopandas.io.sql._write_postgis(",
" File \"/home/api/.local/lib/python3.11/site-packages/geopandas/io/sql.py\",
line 397, in _write_postgis",
" geom_name = gdf.geometry.name",
" ^^^^^^^^^^^^",
" File \"/home/api/.local/lib/python3.11/site-packages/pandas/core/generic.py\",
line 6204, in __getattr__",
" return object.__getattribute__(self, name)",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
"AttributeError: 'DataFrame' object has no attribute 'geometry'"
Any ideas where my error is or if it is even possible to store NULL geometries with GeoPandas/PostGIS?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4