geoarrow / geoarrow-rs

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

Better errors when parsing to a native type #800

Closed kylebarron closed 1 month ago

kylebarron commented 1 month ago

Closes https://github.com/geoarrow/geoarrow-rs/issues/783

kylebarron commented 1 month ago
import geopandas as gpd
from geoarrow.rust.compute import area

path = "/Users/kyle/Downloads/nz-building-outlines.parquet"
table = gpd.read_parquet(path)
gs = table.geometry
area(gs.to_arrow())

Now gives an error of

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
File /Users/kyle/github/geoarrow/geoarrow-rs/python/geoarrow-core/tmp_geopandas.py:11
      [9](https://file+.vscode-resource.vscode-cdn.net/Users/kyle/github/geoarrow/geoarrow-rs/python/geoarrow-core/tmp_geopandas.py:9) table = gpd.read_parquet(path)
     [10](https://file+.vscode-resource.vscode-cdn.net/Users/kyle/github/geoarrow/geoarrow-rs/python/geoarrow-core/tmp_geopandas.py:10) gs = table.geometry
---> [11](https://file+.vscode-resource.vscode-cdn.net/Users/kyle/github/geoarrow/geoarrow-rs/python/geoarrow-core/tmp_geopandas.py:11) area(gs.to_arrow())

Exception: General error: Expected GeoArrow native type, got 'geoarrow.wkb'.
If you're passing a serialized GeoArrow type like 'geoarrow.wkb' or 'geoarrow.wkt', you need to parse to a native representation.