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
Feature/spatial #20
Merged
Merged
Feature/spatial #20
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks very complete Cas. This should also provide the required functionality for making the rmf_create_* function implementations much more straightforward I think. Will not go through lengthy testing right now, and just merge. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introducing S3 conversions from spatial objects to RMODFLOW objects (
rmf_list
andrmf_2d/3d/4d_arrays
) and vice versa. Supported spatial classes aresf
,stars
andraster objects
.stars
is the main driver because it can handle rotated grids or rectilinear grids. Vector/raster I/O is not handled by RMODFLOW; only conversions. Most functionality is explained in the vignette 'spatial.Rmd'.A brief summary:
prj
object. It consists of an origin vector (bottomleft model corner coordinates), a rotation angle and asf crs
element. Theprj
object can be part of thedis
object. Upon writing a DIS file to disk, RMODFLOW projection information is written to the header comments. When reading in a DIS file, RMODFLOW projection information is obtained from either RMODFLOW style projection information in the DIS headers, ModelMuse style projection information or OWHM style. It can also be read from a usgs.model.reference fileprj
argument obtain this from the supplieddis
argument usingrmf_get_prj()
which returns NULL fordis
objects without aprj
. prj arguments can still be supplied explicitely to function calls.dis$lenuni
) and the crs in theprj
object usingrmfi_prj_length_multiplier
(e.g. inrmf_convert_grid_to_xyz
).rmf_list
andrmf_2d/3d/4d_arrays
tosf
,stars
andraster
(the latter only for non-rotated regular grids).sf
,stars
andraster
tormf_list
andrmf_2d/3d/4d_arrays
.rmf_as_tibble
and other functions using coordinates have been updatedrmf_export_*
functions have been removed as RMODFLOW doesn't provide I/O for spatial objects.Notes:
rmf_as_list.sf
returns multiple cells for POINT geometries located on cell boundaries usingop = sf::st_intersects
(default). While this is correct behaviour from a spatial point of view, typically in the MODFLOW world, point values should be connected to a single cell. E.g. a well location should not belong the multiple cells, just one. See also the vignette.Breaking changes:
prj$projection
is replaced byprj$crs
(in line withsf
).rmf_write_prj
andrmf_read_prj
are replaced by internal functions sinceprj
is read/written from thedis
file (or read from usgs.model.reference) instead of individual files.