geoarrow-python icon indicating copy to clipboard operation
geoarrow-python copied to clipboard

Test collection unions against geoarrow-rs

Open paleolimbot opened this issue 11 months ago • 2 comments

In #59 we implement the geometry and collection union types in the latest version of the GeoArrow spec; however the geometry and geometry collection type doesn't quite match geoarrow-rs' because our union members are named (which I think is in the spec?). When we figure out what the right version is, we should test it!

# pip install --pre --upgrade geoarrow-rust-core
from geoarrow.rust.core._rust import NativeType
import geoarrow.pyarrow as ga
import pyarrow as pa
import geoarrow.types as gt

rs_type = NativeType(type="geometrycollection", dimension="XY", coord_type="separated")
pa_type = pa.DataType._import_from_c_capsule(rs_type.__arrow_c_schema__())

ga_type = gt.type_spec(
    gt.Encoding.GEOARROW, gt.GeometryType.GEOMETRYCOLLECTION, gt.Dimensions.XY
).to_pyarrow()

pa_type.storage_type
#> ListType(list<geometries: dense_union<: struct<x: double not null, y: double not null>=1, : list<vertices: struct<x: double not null, y: double not null> not null>=2, : list<rings: list<vertices: struct<x: double not null, y: double not null> not null> not null>=3, : list<points: struct<x: double not null, y: double not null> not null>=4, : list<linestrings: list<vertices: struct<x: double not null, y: double not null> not null> not null>=5, : list<polygons: list<rings: list<vertices: struct<x: double not null, y: double not null> not null> not null> not null>=6> not null>)
ga_type.storage_type
#> ListType(list<geometries: dense_union<Point: struct<x: double not null, y: double not null>=1, LineString: list<vertices: struct<x: double not null, y: double not null> not null>=2, Polygon: list<vertices: list<rings: struct<x: double not null, y: double not null> not null> not null>=3, MultiPoint: list<points: struct<x: double not null, y: double not null> not null>=4, MultiLineString: list<vertices: list<linestrings: struct<x: double not null, y: double not null> not null> not null>=5, MultiPolygon: list<vertices: list<rings: list<polygons: struct<x: double not null, y: double not null> not null> not null> not null>=6> not null>)

paleolimbot avatar Jan 22 '25 03:01 paleolimbot

(which I think is in the spec?).

Did we validate if this is in the spec?

kylebarron avatar Feb 05 '25 19:02 kylebarron

It looks like it is: https://github.com/geoarrow/geoarrow/blob/main/format.md#geometry

kylebarron avatar Feb 05 '25 19:02 kylebarron