-
Notifications
You must be signed in to change notification settings - Fork 317
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
Feat pyproj crs #1737
Feat pyproj crs #1737
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1737 +/- ##
=========================================
- Coverage 72.1% 72.0% -0.1%
=========================================
Files 253 254 +1
Lines 56040 55915 -125
=========================================
- Hits 40420 40302 -118
+ Misses 15620 15613 -7
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good feature, and I've thought of implementing this at one time too. Users of GeoPandas or rasterio know the .crs
property, so this is aims to be similar bridge to modern pyproj / PROJ.
However, I'd like to see #1730 merged before a thorough review, as I anticipate several conflicts. Only a few comments from a quick first read are attached.
49c159b
to
85d660d
Compare
…to a pyproj.CRS instance attached to the grid classes as a .crs attribute
…to a pyproj.CRS instance attached to the grid classes as a .crs attribute
… crs argument and prjfile argument
…efile header under 'crs' key; read 'proj4' key as crs input
…self._modelgrid.set_coord_info() instead of epsg or proj4
…of proj4 (needed for a792e73); fix(Grid.read_usgs_model_reference_file): to handle quoting in usgs.model.reference
… coordinate references
…id issues with encoding the degree symbol to ascii; fix the same issue in test_grid.py. Also replace epsg code 4326 in example name files with epsgs for projected CRS (geographic CRS no longer allowed)
* refactor to use pyproj.CRS instead of epsg and proj4 to store CRS information; * use pyproj.CRS.to_cf() to get Climate and Forecast (CF) grid mapping input for the NetCDF file * drop support for pyproj versions < 2.2.0 * move contents of _initialize_attributes to __init__() method
…sses; superceded by pyproj.CRS
…hen reading usgs.model.reference
… crs argument and prjfile argument
…coordinate reference input
* remove _initialize_attributes() method * call initialize_geometry() in workflow regardless if model has a crs or not (and set bounds and vbounds attributes in both cases)
…est case to hopefully avoid file conflicts with parallel test runs
…o use crs arg and to reflect deprecation of EpsgReference class
…darray' (similar to Scipy)
@mwtoews any other comments? |
Apologies for the slow delay, but I'll make some time in the next few days to provide more thorough feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the spare review time, only a few remarks.
thanks @mwtoews, I think I've addressed all of your comments. @langevin-usgs @jdhughes-usgs what else needs to happen to get this merged? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @aleaf. This looks to be a very nice improvement.
This pull request seeks to refactor coordinate reference system (CRS) handling in Flopy to exclusively use the pyproj.CRS coordinate reference system manager object. Basically, this means that a single
crs
argument can be used to specify a CRS is any recognized format (EPSG code, proj string, well-known text etc) andpyproj.CRS
will detect the format and the CRS if it can, and create an object instance accordingly that can then be passed to other functions and methods that need a CRS. This means that we no longer have to manage multiple options for CRS input, and it also greatly simplifies comparison of CRS from different inputs. The exception to this is retaining aprjfile
argument to the modelgrid and export methods, which allows users to simply supply a path to an ESRI-style projection file, instead of having to open the file themselves to get and then manage the well-known text inside. This may be more convenient for users working with more obscure CRS that don't have an EPSG code, for example. A few notes:epsg
andproj4
arguments are still accepted, but produce a warning that they will be deprecated in Flopy 3.4pyproj.CRS
)pyproj.CRS
object is written to the Name file under acrs
key. Usually this is just a simple authority string such as"EPSG: 26916"
, but this could also be full well-known text string like in a projection file. PROJ strings and EPSG codes are still read from the Name file orusgs.model.reference
files as previously.In addition to simplifying input for users, this should improve the reliability and robustness of exporting data that can be displayed or used in a GIS with other data. It could also enable automatic reprojection of input data from GIS file formats or other models, in Flopy's preprocessing utilities.