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

Propagate CRS and geometry column from Shapefile.Table via DataAPI #118

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented Aug 8, 2024

Does what it says on the tin, and tests that DataFrame(table) retains these values.

We currently use the :note style meaning that the value of the metadata is propagated through any transformation of the table. This is up for discussion (for reference, GeoDataFrames.jl uses :default styling, which is invalidated if the dataframe is transformed.).

The only operations I can see might have a problem with this are:

  • Changing the geometry column in a dataframe (when would you do this anyway?)
  • Reprojecting geometry (we can make GeometryOps switch the metadata for us, though).

@asinghvi17
Copy link
Member Author

This test was failing before the writer change and I don't entirely understand why:

write tables: Test Failed at /home/runner/work/Shapefile.jl/Shapefile.jl/test/table.jl:55
  Expression: all(isequal.(replace.(skipmissing(a), !isascii => (x->begin
                        #= /home/runner/work/Shapefile.jl/Shapefile.jl/test/table.jl:56 =#
                        '_' ^ textwidth(x)
                    end)), skipmissing(b)))

https://github.com/JuliaGeo/Shapefile.jl/actions/runs/10305538693/job/28526609515?pr=118#step:5:846

@rafaqz
Copy link
Member

rafaqz commented Aug 8, 2024

This generally looks good.

But before we merge it I think we need a PR to GeoInterface.jl adding this specification to the docs, so it can be discussed as an ecosystem change rather than a PR to Shapefile.jl. I imagine @evetion and @visr will have some input to add.

@evetion
Copy link
Member

evetion commented Aug 11, 2024

Using :note is somewhat better indeed, the :default style for GeoDataFrames is lost as soon as you subset the table, I might change that.

Implicitely, stuff that (re)projects should check/set the crs, so either take a DataAPI dep, or add the dep to GeoInterface.

Lastly, there's colmetadata, and especially for multiple columns, it makes sense to have the crs (also?) on the column level.

end
end
function DataAPI.metadata(t::Table, key::String; style = false)
result = if key == "GEOINTERFACE:geometrycolumns"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this was a constant in GeoInterface.jl

Like:
GI.geometrycolumns_metadata_key

function DataAPI.metadata(t::Table, key::String; style = false)
result = if key == "GEOINTERFACE:geometrycolumns"
(:geometry,)
elseif key == "GEOINTERFACE:crs"
Copy link
Member

@rafaqz rafaqz Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And GI.crs_metadata_key

Or something...

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 this pull request may close these issues.

3 participants