geoarrow / geoarrow-rs

GeoArrow in Rust, Python, and JavaScript (WebAssembly) with vectorized geometry operations
http://geoarrow.org/geoarrow-rs/
Apache License 2.0
257 stars 17 forks source link

Provide better error message when passing unsupported geometry type #783

Closed jorisvandenbossche closed 1 month ago

jorisvandenbossche commented 1 month ago

Example I was trying:

In [17]: gs = GeoSeries.from_wkt([
    ...:     "POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))",
    ...:     "POLYGON ((4 2, 4 4, 2 4, 2 2, 4 2))"
    ...: ])

In [18]: geoarrow.rust.compute.area(gs.to_arrow())
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In[18], line 1
----> 1 geoarrow.rust.compute.area(gs.to_arrow())

Exception: Incorrect type passed to operation: 

The default in geopandas is still WKB, so when passing gs.to_arrow(geometry_encoding="geoarrow") explicitly to get native encoding works fine. But it would be useful to get a better error message (or should the WKB actually be supported and get converted on the fly?)

kylebarron commented 1 month ago

I agree we should have better errors here.

https://github.com/geoarrow/geoarrow-rs/pull/784 was a big refactor in the Rust core to treat "serialized arrays" like WKT and WKB as a separate concept from "native arrays" like point/line/polygon/etc.

This means that functions like area now only accept this NativeArray trait object and not a SerializedArray trait object. This should enable us to have simpler error messages because we can error when importing the NativeArray object.