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

Support __arrow_c_array__ in viz() #425

Closed
kylebarron opened this issue Mar 20, 2024 · 0 comments · Fixed by #427
Closed

Support __arrow_c_array__ in viz() #425

kylebarron opened this issue Mar 20, 2024 · 0 comments · Fixed by #427

Comments

@kylebarron
Copy link
Member

kylebarron commented Mar 20, 2024

It would be nice to be able to visualize any array. Note that this should be before __geo_interface__ in the conversion steps.

You might want to do something like the following to ensure the field metadata isn't lost if extension types aren't installed.

if hasattr(obj, "__arrow_c_array__"):
    schema, _ = obj.__arrow_c_array__()

    class SchemaHolder:
        def __init__(self, capsule) -> None:
            self.capsule = capsule

        def __arrow_c_schema__(self):
            return self.capsule
        
    pyarrow_field = pa.field(SchemaHolder(schema))
    pyarrow_array = pa.array(obj)
kylebarron added a commit that referenced this issue Mar 25, 2024
Closes #425, blocked
on apache/arrow#38010 (comment).
The main issue is that we need a reliable way to maintain the geoarrow
extension metadata through FFI. The easiest way would be if `pa.field()`
were able to support `__arrow_c_schema__` input. Or alternatively, one
option is to have a context manager of sorts to register global pyarrow
geoarrow extension arrays, and then deregister them after use.
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 a pull request may close this issue.

1 participant