[FEA] Integrate GeoSeries with read_polygon_shapefile - #609
Conversation
|
There are very informative discussions on the ordering of polygon vertices: https://gis.stackexchange.com/questions/119150/order-of-polygon-vertices-in-general-gis-clockwise-or-counterclockwise |
|
The Shapefile Reader API does have a problem in dealing with multi-polygons. The initial design was to break multi-polygons (as well as GeometryCollection) into multiple (single/regular) polygons (with or without holes). Yet the implementations was to consolidate the rings of multi-polygons, which essentially treats the first ring as the outer ring and the rest as the inner rings, i.e., a single/regular polygon with holes. Subsequently, it will break PIP algorithms. There are two solutions:
|
isVoid
left a comment
There was a problem hiding this comment.
For discussion: would you think it's better to support factory functions like GeoColumn.from_shapefile and GeoSeries.from_shapefile? We can still support constructing the objects in constructor, but under the hood punt to the factory functions.
harrism
left a comment
There was a problem hiding this comment.
I think handling winding order can be cleaner, made some suggestions.
|
There is a simple way to determine the orientation of a ring/curve, e.g., signed area. |
|
Ah nice! Computing the handedness of the polygon is nothing more than the determinant of the matrix formed by the first three points. That handedness is guaranteed to continue through all of the rest of the points. It is tempting to implement this for completeness. |
|
We should definitely have an area computation as well, and it looks quite simple. I'll file an issue for it. |
harrism
left a comment
There was a problem hiding this comment.
Nearly there. A couple of smelly C-style casts need to be fixed up.
isVoid
left a comment
There was a problem hiding this comment.
Thanks for addressing all comments. I think you should update the PR description from mentioning reversed to winding_order.
157cf5b to
8ccc066
Compare
8ccc066 to
19600a5
Compare
|
@gpucibot merge |
This useful PR adds a
GeoSeriesconstructor for the tuple returned byread_polygon_shapefile. Now users can sayand load the data directly into GeoArrow.
This PR touches many files because I add a
reversedargument to python and C++ so that the user can swap back and forth if they desire. This was required because the original implementation was reverse-ordering the polygons, which does not match GeoPandas results when reading a shapefile. Now it does, and is tested in both configurations.Closes #668.