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

write_arrow() does not automatically recognize geometry fields #522

Open
paleolimbot opened this issue Feb 4, 2025 · 1 comment
Open

Comments

@paleolimbot
Copy link

Very possible there's a flaw in my example, but:

import pyogrio
import pyarrow as pa

tab = pa.table(
    [[b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0?']],
    schema = pa.schema([
        pa.field("geometry", pa.binary(), metadata={
            "ARROW:extension:name": "geoarrow.wkb",
            "ARROW:extension:metadata": ""
        })
    ])
)

tab.schema.field("geometry").metadata
#> {b'ARROW:extension:name': b'geoarrow.wkb', b'ARROW:extension:metadata': b''}

pyogrio.write_arrow(tab, "foofy.fgb")
#> DataLayerError: Error while writing batch to OGR layer: Cannot find OGR geometry field for Arrow array geometry
@jorisvandenbossche
Copy link
Member

Can you try with adding geometry_type="Unknown" to the write call? When geometry_name is specified, we check that you also have to specify geometry_type, but we don't enforce that when the geometry column is inferred.

So either we should raise an error (about having to specify geometry_type) in this case as well, or we should maybe let it default to "Unknown"?

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

No branches or pull requests

2 participants