JuliaGeo / Shapefile.jl

Parsing .shp files in Julia
http://juliageo.org/Shapefile.jl/
MIT License
82 stars 14 forks source link

Accessing a Shapefile.Row geometry via row.geometry fails #82

Closed felixcremer closed 1 year ago

felixcremer commented 1 year ago

The docstring of Row states, that the geometry should be accessible by row.geometry.

When I try to access the geometry of a Shapefile.Row via row.geometry it fails with the following error:

julia> row = first(inundation)
Shapefile.Row{Shapefile.Polygon}(Polygon(1504 Points), (ID = "1", var"Area[km²]" = missing, land_cover = missing, inu_days = 276, var"area[skm]" = 0.871))

julia> row.geometry
ERROR: ArgumentError: Column not present: geometry
Stacktrace:
 [1] getcolumn(row::DBFTables.Row, name::Symbol)
   @ DBFTables ~/.julia/packages/DBFTables/a7IAV/src/DBFTables.jl:312
 [2] getproperty
   @ ~/.julia/packages/Tables/T7rHm/src/Tables.jl:186 [inlined]
 [3] getproperty(row::Shapefile.Row{Shapefile.Polygon}, name::Symbol)
   @ Shapefile ~/.julia/packages/Shapefile/UOgPn/src/table.jl:19
 [4] top-level scope
   @ REPL[47]:1

This failure seems to be coming from trying to find the geometry column in the record entry of row. This is defined here; https://github.com/JuliaGeo/Shapefile.jl/blob/ade9474e0d7d4985464c94f1463c3ace44cd59c9/src/table.jl#L19

rafaqz commented 1 year ago

Ah damn that no longer works. Yes we should check for :geometry keys and otherwise forward to :record.

I think GeoInterface.geometry on the row should work though.