-
Notifications
You must be signed in to change notification settings - Fork 32
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
add spatial reference #184
Comments
cc @rafaqz |
I have to say, that I am not knowledgeable at all on this topic. It seems that GeoFormatTypes.jl does not have any external dependencies. It seems to be a design goal to avoid large dependencies (I have already enough with NetCDF_jll :-)). So, yes I think it would be a useful functionality and it is fine for me to focus on WKT2. Maybe a PR can put this code in a separate file specific to spatial references? As in NetCDF you can define variables on different grids, it would be good to be able to use different CRS system in the same file. I guess it would be sufficient to make the variable name |
Yes all of that is right. WKT is the most flexible, since you can create any of your own projections and use them. EPSG only applies if that projection is in the database. I'm not really familiar with the grid mapping attributes, it is specific to CF only. You can convert WKT to EPSG, but that would need PROJ. Indeed GeoFormatTypes.jl is intended to stay light.
I haven't tried this yet, would be interesting to see if this works in QGIS for example. |
There are a few obscure things that dont convert from wkt to netcdf grid mapping. But otherwise they're interchangeable. This is a relevant CF thread about it: Writing grid mapping attributes would be good to have at some point, but the conversion is pretty complicated. @visr you dont need to access val for Int/string conversion, |
Just thinking it would also be good to also read |
Can somebody prepare a PR? |
Is this something that should be put into CommonDataModel? I am currently working on geozarr compatibility and loading ZarrDatasets in Rasters and for that we would need the crs handling in CommonDataModel. |
CommonDataModel seems the best place now. Its just waiting for someone who needs it enough to write it up... I can help review if that helps |
I wrote some code to add a coordinate reference system to a NCDataset, that might be useful for others, and perhaps can start a discussion on integrating a form of this into the package if desired.
In the CF conventions projections is discussed here: https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#grid-mappings-and-projections. For a while CF has had it's own CRS system of grid mappings identified by
grid_mapping_name
, with examples in https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#appendix-grid-mappings. Now there is also the option to use Well-known text (WKT2). Since we have code in the ecosystem for the latter but not the former, I only used WKT2. Older software may only support thegrid_mapping_name
, pyproj has code that supports creating these. Additionally I also added theepsg
attribute, since MDAL, which is used for loading ustructured grids (UGrid) in QGIS, recognizes that, but not yet WKT2. For raster data, GDAL does recognize WKT2.I found https://corteva.github.io/rioxarray/stable/getting_started/crs_management.html to be a good reference. Note this the implementation below hardcodes the dummy variable name to
spatial_ref
, we could make this variable.Now to use this, call
create_spatial_ref!
, and for each variable that uses that projection, add thegrid_mapping = "spatial_ref"
attribute.Note: grid_mapping axis order has to match WKT defined axis order.
WKT must be https://www.ogc.org/standards/wkt-crs OGC document 12-063. 1st May 2015.
The text was updated successfully, but these errors were encountered: