-
Notifications
You must be signed in to change notification settings - Fork 11
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
NetCDF preparation for BGFLOOD #63
Comments
I've been exploring how to save netCDF files out if they are datasets. At this stage I can't figure out how to encode CRS information in a Dataset vs a Dataarray such that is will be read in by rioxarray :( I've also looked into grouped data. Waiting to hear back from @AliceHarang and @CyprienBosserelle as to if this is the expected form! Just to note, I don't get the groups showing up in PyNcView, but I can open each group in Xarray.Info:
Open questions:
|
I think we need to explore and discuss the different netcdf conventions that suits the data best. An stick to the selected conventions. This is valid for both BGFlood and geofabric. |
Yes - good point @CyprienBosserelle - and as you can see from some of my previous comments I've been having trouble establishing exactly what these are. I'm going to investigate a little more how exactly the python library rioxarray encodes CRS information - something I obviously should have done before advocating for its use. I'll remove the BG-FLOOD issue I've created if this investigation suggests we shouldn't be encoding CRS info to be encoded with the netCDG file! It'd be great to better understand what you've been doing for your netCDF files and where you're planning to go with your netCDF files so we can hopefully make geofabrics and BG-FLOOD more similar - especially while I'm making these changes to GeoFabrics. I'm curious to understand what you are doing with adaptive grids - separate netCDF files or one netCDF file with multiple resolutions in different groups. I'm going to set up a 30min meeting to understand what's already being done/planned in BG-FLOOD so I can adopt where it makes sense in GeoFabrics. Let me know if I should shift the proposed meeting time. |
There is a bit of documentation already in BG-FLOOD
|
This is a bit of a catch-all issue for work relating to the requirements associated with the NetCDF output from GeoFabrics (and also input to BGFLOOD).
Requirements:
spatial_ref
information like geotransform and crs - see section below.write_crs()
andwrite_transform
variable
andcoordinates
attributes:units
information: See link for conventions.long_name
: A description of the variable/coordiante.standard_name
: Must be included in the NUG table.vertical_datum
: Non-standard attribute name to record the vertical datum of any elevation data.DEMs and roughness should be defined over a full rectangular grid with no NaN valuesNaNs have since been deemed ok!NetCDF conventions
There are standards defining the conventions for attributes in netCDF files.
See CF conventions for some details about conventions around netCDF files.
The
spatial_ref
coordinateThis is where information associated with the coordinate system and projection (CRS and transform) are encoded.
Coordinate systems CF-1.6 <--> CRS
There is an optional grid mapping attribute called
crs_wkt
may be used to specify multiple coordinate system properties in so-called well-known text format (usually abbreviated to CRS WKT or OGC WKT) as detailed in the cfconventions.org page. With example mappings at the github page.It looks like this information is sometimes encoded within a "spatial_ref" coordinate (see issue).
Python Libraries
There are various Python libraries for interacting with NetCDF files including netCDF4, xarray, and rioxarray. netCDF4 is an engine used by xarray to read and write netCDF files. xarray has some power constructs for constructing and interacting with data stored in netCDF files. rioxarray combines xarray with rasterio by providing access to the rasterio engine with the rio accessor.
xarray supports two main objects - DataArrays and DataSets. DataArrays work well for a single layer of data (possibly across many bands), and the DataSet class should be used for multiple variables that may have different dimension (i.e. different resolutions, or x,y vs time).
Other
There is potential for a translation layer between GeoFabrics and BG-FLOOD or also between the catchment generation code and either GeoFabrics and/or BG-FLOOD. This would be contained in a separate repository to either.
The text was updated successfully, but these errors were encountered: