Create geometries with different number of points in a vectorized way
See original GitHub issueI have found this open-source project by looking for a vectorized geospatial python library. I am impressed about how the library can handle geospatial processing with full vectorization. However, I could not figure out how to create geometries with different number of points in a vectorized way. A very simple example.
I can create two polygons in one call, if the polygons have the same number of points.
pygeos.polygons(
[
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]],
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
]
)
However, if I put two polygons with different number of points, it will not work.
pygeos.polygons(
[
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]],
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]
]
)
I will get a type error:
TypeError: One of the arguments is of incorrect type. Please provide only Geometry objects.
Is this a design choice? Or does it have to do with the limitations of ufunc
in numpy
? Or maybe I have not found the correct usage of this library. In that case I apologise for not being able to find the relevant information in the documentation.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (8 by maintainers)
Top GitHub Comments
This issue has been addressed in our latest release 0.10.
That’s right, the direct route from coordinates + indices to polygons is not available. This is not possible for the generic case for polygons with holes (you would have to specify in which hole in which polygon the coordinate would have to go).
Hence the two-step procedure. It is conceivable to implement this specifically for the polygons without holes case (by far the most common one) by propagating indices to the internal
linearrings
constructor over here:https://github.com/pygeos/pygeos/blob/3fa59c7c52519ee1eb10f9ba7e49ced306201e9f/pygeos/creation.py#L223