yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
141 stars 27 forks source link

Tables.jl interface doesn't provide all columns of dataset #332

Closed juliohm closed 1 year ago

juliohm commented 1 year ago

Download the https://github.com/datasets/geo-countries/blob/master/data/countries.geojson file and load it:

julia> import ArchGDAL as AG

julia> using Tables

julia> data = AG.read("countries.geojson")
GDAL Dataset (Driver: GeoJSON/GeoJSON)
File(s): 
  countries.geojson

Number of feature layers: 1
  Layer 0: countries (wkbMultiPolygon)

julia> table = AG.getlayer(data, 0)
Layer: countries
  Geometry 0 (): [wkbMultiPolygon], MULTIPOLYGON (((-69....), ...
     Field 0 (ADMIN): [OFTString], Aruba, Afghanistan, Angola, Anguilla, ...
     Field 1 (ISO_A3): [OFTString], ABW, AFG, AGO, AIA, ALB, ALA, AND, ARE, ...
     Field 2 (ISO_A2): [OFTString], AW, AF, AO, AI, AL, AX, AD, AE, AR, AM, ...

julia> Tables.columns(table) |> Tables.columnnames
(Symbol(""), :ADMIN, :ISO_A3, :ISO_A2)

I would expect a "geometry" column, but the column is not available in the latest release of the package. Is this a bug or intended behavior? I will need to adapt code downstream to retrieve the column of geometries with a different method.

visr commented 1 year ago

The Symbol("") column is the geometry column in this case. Admittedly not a great name. The problem is GDAL supports multiple geometry columns, and the API provides the names for each, which is empty in this case (for all GeoJSON I assume).

rafaqz commented 1 year ago

Yes it actually needs a :geometry column to confirm to the GeoInterface.jl spec.

rafaqz commented 1 year ago

Oh right it is using the override method for custom names.

I guess we should force : geometry if the name is""?

visr commented 1 year ago

That renaming was done before but reverted, see also #196.

juliohm commented 1 year ago

In any case, what is the low-level function I need to call to retrieve the vector of geometries in a layer?

Em qui., 6 de out. de 2022 09:36, Martijn Visser @.***> escreveu:

That renaming was done before but reverted, see also #196 https://github.com/yeesian/ArchGDAL.jl/issues/196.

— Reply to this email directly, view it on GitHub https://github.com/yeesian/ArchGDAL.jl/issues/332#issuecomment-1269963036, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3OP2OF3PGLI2LSVFLTWB3BULANCNFSM6AAAAAAQ6RXFNI . You are receiving this because you authored the thread.Message ID: @.***>

juliohm commented 1 year ago

This issue is blocking some development downstream.

@visr @rafaqz by looking into the docs I can't find a simple method to extract the column of geometries:

https://yeesian.com/ArchGDAL.jl/stable/features/#Feature-Layers

Tried getgeomdefn but it returned a single view object, which is not what I expected.

visr commented 1 year ago

Looks like you could use this: https://github.com/yeesian/ArchGDAL.jl/commit/d2ae1bd1bff8a2378e871ca681deb3aed8031122#diff-8863bda6c8110806a88867bdf86f050a626aa87859b7cf333f04eb5007086e50R54-R57

juliohm commented 1 year ago

This issue is no longer relevant given the existence of alternative packages to load geojson.