Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python top-level function API #293

Merged
merged 2 commits into from
Dec 4, 2023
Merged

Conversation

kylebarron
Copy link
Member

@kylebarron kylebarron commented Dec 4, 2023

This is just a proof of concept, only for area. It's annoying how verbose the implementation is, so I want to ideate on that a bit more.

It works!

import pyarrow as pa
import shapely
import pandas as pd
import geopandas as gpd
from geoarrow.rust.core import WKBArray

gdf = gpd.read_file(gpd.datasets.get_path('nybb'))
large_gdf = pd.concat([gdf] * 1000)
wkb = shapely.to_wkb(large_gdf['geometry'])

pa_wkb_arr = pa.array(wkb)
rust_wkb_arr = WKBArray.from_arrow(pa_wkb_arr)
rust_multi_polygon_arr = rust_wkb_arr.to_multi_polygon_array()
area1 = rust_multi_polygon_arr.area()

from geoarrow.rust.core import area
area2 = area(rust_multi_polygon_arr)
image

Closes #266. For geoarrow/geoarrow-python#38

@kylebarron kylebarron changed the title python top-level function python top-level function API Dec 4, 2023
@kylebarron kylebarron merged commit b1cbd90 into main Dec 4, 2023
6 checks passed
@kylebarron kylebarron deleted the kyle/python-top-level-function branch December 4, 2023 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python: Prototype top-level functions that work on external input
1 participant