Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty SHAPE #1790

Open
hildermesmedeiros opened this issue Apr 8, 2024 · 4 comments
Open

Empty SHAPE #1790

hildermesmedeiros opened this issue Apr 8, 2024 · 4 comments

Comments

@hildermesmedeiros
Copy link

I'd like the spatial dataframes geometry to have empty geometry

when reading data from database(sqls) we can often see empty geometry columns.

having an empty geometry
"Imagine that a system creates a trigger to insert a new row, than an webhook does an etl to get data and geometrie from an external api"

The geoaccessor can read empty geometries, but creates the row with None. And the column becomes object.

geom = sdf.SHAPE.iloc[0]

geom.isEmpty
# would return True

Gracefully handle empty geom would be a good thing, if possible.

Describe the solution you'd like
Proposed Changes
I suggest that to implement the following changes:

Modify the spatial dataframe structure to accommodate empty geometries.

Ensure that operations on the dataframes (like transformations, visualizations, and exports, validation, svg) gracefully handle empty geometries.
Provide clear documentation on how empty geometries are represented and managed within the dataframes.
I believe that incorporating these changes will enhance the robustness and flexibility of our spatial data handling capabilities. I look forward to discussing this further and exploring the best ways to integrate this feature.

Describe alternatives you've considered
Implement ORM with sqlalchemy. Or geoaccessor and split the spatial dataframe.
Additional context

@achapkowski
Copy link
Contributor

Can you post sample input data?

@hildermesmedeiros
Copy link
Author

@achapkowski
Right now i'm testing in my local env. But in the client it is something like this:
image

image

@achapkowski
Copy link
Contributor

ok, I understand now, thank you.

@hildermesmedeiros
Copy link
Author

hildermesmedeiros commented Apr 11, 2024

@achapkowski

To my understanding, using arcpy would necessitate this initial fix:
image

Upon reviewing the Geometry Factory, I noticed that it already has the is_empty method implemented correctly. Perhaps this should be tagged as a bug.

Another enhancement or bug is the extension of the numpy array. In my understanding, sdf.isna() and sdf.isnull() should return True for empty geometries.

The implementation might look something like this, if I'm not mistaken.

P.S.: I tested this with arcpy as the backend.
https://github.com/geopandas/geopandas/blob/main/geopandas/array.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants