-
Notifications
You must be signed in to change notification settings - Fork 195
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
Traits: How to represent Polygon EMPTY
?
#1039
Comments
Reconciling different geometry representations is hard, and IMO it's probably not possible to match all users expectations 100% of the time. It definitely feels like a "pick your tradeoffs" kind of thing. Some possible approximations that come to mind for different circumstances might be: Watch out also for https://github.com/georust/geozero deals with translating between formats, and might have some insight.
I'm not entirely sure what a "missing" geometry is, but an "invalid" geometry feels like a distinct thing from an empty geometry. e.g. the output of unioning two disjoint polygons should be empty, but not invalid. Sorry I don't have more answers. |
I agree, but also feel like the simple features standard is a good target to strive for, and thus having some way to represent empty geometries is useful. Maybe it makes most sense to add an In terms of the current polygon trait, however, the user would have to remember to check if it's empty before accessing If you're curious, GeoArrow defines all geometries except for point as empty if they have an empty internal list, and a point as empty if the coordinates are |
(I'm thinking that the best way to start a focused discussion on a specific part of traits is to open a new issue, rather than add to the existing discussion thread/PR)
In geoarrow-rs I started a custom implementation of parsing a vector of WKB objects (a custom two-pass approach should be really efficient and I want geoarrow<-->WKB to be performant). For the implementation details, I created structs like
WKBPolygon
that reference a WKB object in a&[u8]
, and then implementedPolygonTrait
for that struct. Then for the high-level conversion from aWKBArray
to aPolygonArray
, I have two functions calledfirst_pass
andsecond_pass
that operate on iterators of objects implementingPolygonTrait
. This works surprisingly well! And it means that I can use those exact same functions to convert arrays of anything implementingPolygonTrait
, such as arrays ofgeo::Polygon
or an array inside a bump-allocated-vec.But I ran into a snag adding tests from the
![image](https://private-user-images.githubusercontent.com/15164633/253824365-e59c5017-253c-48ad-9f56-e2bf19474c36.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1Njc2OTgsIm5iZiI6MTcyNDU2NzM5OCwicGF0aCI6Ii8xNTE2NDYzMy8yNTM4MjQzNjUtZTU5YzUwMTctMjUzYy00OGFkLTlmNTYtZTJiZjE5NDc0YzM2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDA2Mjk1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUwNDlmNjZlYTZlNzZkYTMyNTMzOGU5ZDdmMTI3YzRmOGI0YmI1MDY2YzYyNjY3YzJmMWRkYzRiMzQyYzJiZWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.eG0nPI-X_ywiuQhq3mkauyQlLyFHazZdLzI_n-JWUio)
geoarrow/geoarrow-data
repo. There this Parquet file contains an object that is stored in WKB asPolygon EMPTY
. You can inspect this easily in e.g. geopandas:But when I try to load this file, I get an error calling
PolygonTrait::exterior
and I'm realizing that thePolygonTrait
(and alsogeo-types
) in effect doesn't supportPolygon EMPTY
because it requires at least an exterior ring to exist.In Arrow specifically, every array has a validity bitmap, so I should be able to work around this in this case (if I enforce that a missing/invalid geometry is the same as an empty geometry, which I'm not sure is true). But I wanted to raise this in relation to traits and see what people thought.
The text was updated successfully, but these errors were encountered: