Skip to content

Commit

Permalink
Add support for GeoInterface CRS metadata (#25)
Browse files Browse the repository at this point in the history
* Add support for GeoInterface CRS metadata

* Apply suggestions

* Apply suggestions

* Add tests
  • Loading branch information
eliascarv authored Dec 20, 2024
1 parent 70baf2a commit 46f1b35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ function read(::Parquet2Driver, fn::Union{AbstractString,Parquet2.FilePathsBase.
for column in keys(meta.columns)
df[!, column] = GFT.WellKnownBinary.(Ref(GFT.Geom()), df[!, column])
end
# set GeoInterface metadata
metadata!(df, "GEOINTERFACE:geometrycolumns", Tuple(Symbol.(keys(meta.columns))))
crs = meta.columns[meta.primary_column].crs
if !isnothing(crs)
metadata!(df, "GEOINTERFACE:crs", crs)
end
df
end

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ end
df = GeoParquet.read(fn)
@test nrow(df) === 5
@test df.geometry[1] isa GFT.WellKnownBinary
# GeoInterface metadata
@test metadata(df, "GEOINTERFACE:geometrycolumns") == (:geometry,)
@test metadata(df, "GEOINTERFACE:crs") isa GFT.ProjJSON

@test_throws Exception GeoParquet.read(fn, columns=(:geom,))
end
Expand Down

0 comments on commit 46f1b35

Please sign in to comment.