Functions to get, set, transform and check presence of prj objects

rmf_get_prj(...)

# S3 method for dis
rmf_get_prj(dis)

# S3 method for modflow
rmf_get_prj(modflow)

rmf_has_prj(...)

# S3 method for dis
rmf_has_prj(dis)

# S3 method for modflow
rmf_has_prj(modflow)

rmf_set_prj(...)

# S3 method for character
rmf_set_prj(file, dis, prj = rmf_get_prj(dis))

# S3 method for dis
rmf_set_prj(dis, prj)

# S3 method for modflow
rmf_set_prj(modflow, prj)

rmf_transform_prj(...)

# S3 method for prj
rmf_transform_prj(prj, crs)

# S3 method for dis
rmf_transform_prj(dis, crs)

# S3 method for modflow
rmf_transform_prj(modflow, crs)

Arguments

dis

RMODFLOW dis object (or RMT3DMS btn object)

modflow

RMODFLOW modflow object (or RMT3DMS mt3dms object)

file

path to discretization file; typically "*.dis"

prj

RMODFLOW prj object

crs

coordinate reference system to transform to. Input for sf::st_crs.

Value

rmf_get_prj returns a RMODFLOW prj object if present; otherwise NULL

rmf_has_prj returns a logical depending on whether or not a RMODFLOW prj object is present

rmf_set_prj returns either a RMODFLOW dis or modflow object with the prj set or nothing when writing directly to a file.

rmf_transform_prj returns the RMODFLOW object with a transformed crs in the prj object

Details

These functions can also be used with the RMT3DMS library on btn and mt3dms objects.

If prj information is already present, a warning is raised when overwriting.

rmf_set_prj.character writes the projection information of prj directly into the header comments of the discretization file

rmf_transform_prj transforms the origin coordinates to the new crs. If no prj was set, an error is raised.

Examples

dis <- rmf_read_dis(rmf_example_file('water-supply-problem.dis')) rmf_get_prj(dis)
#> RMODFLOW Projection object: #> Origin coordinates (x y z) of the lowerleft corner: #> -3591.308 -1590.759 0 #> Grid rotation (degrees counterclockwise): #> 0 #> Coordinate Reference System: #> NA
m <- rmf_read(rmf_example_file('example-model.nam'), verbose = FALSE) rmf_get_prj(m)
#> RMODFLOW Projection object: #> Origin coordinates (x y z) of the lowerleft corner: #> 0 -1000 0 #> Grid rotation (degrees counterclockwise): #> 0 #> Coordinate Reference System: #> NA
# return NULL rmf_get_prj(rmf_create_dis())
#> NULL
rmf_has_prj(dis)
#> [1] TRUE
rmf_has_prj(m)
#> [1] TRUE
rmf_has_prj(rmf_create_dis())
#> [1] FALSE
dis <- rmf_create_dis() prj <- rmf_create_prj(origin = c(100, -150)) rmf_set_prj(dis, prj)
#> RMODFLOW Discretization File object with: #> 10 rows, 10 columns and 3 layers totalling 300 cells #> #> Time units: seconds #> Length units: meters #> #> Spacing along rows (DELR): 100 (constant) #> Spacing along columns (DELC): 100 (constant) #> #> Summary of top elevations: #> Top #> Min. :0 #> 1st Qu.:0 #> Median :0 #> Mean :0 #> 3rd Qu.:0 #> Max. :0 #> #> Summary of bottom elevations: #> Layer 1 Layer 2 Layer 3 #> Min. -10 -20 -30 #> 1st Qu. -10 -20 -30 #> Median -10 -20 -30 #> Mean -10 -20 -30 #> 3rd Qu. -10 -20 -30 #> Max. -10 -20 -30 #> #> Information for 1 stress-period: #> Period Length Timesteps Multiplier Type #> 1 1 1 1 Steady-state #> #> RMODFLOW Projection object: #> Origin coordinates (x y z) of the lowerleft corner: #> 100 -150 0 #> Grid rotation (degrees counterclockwise): #> 0 #> Coordinate Reference System: #> NA
# write directly to header comments of file f <- tempfile() rmf_write_dis(dis, file = f) rmf_set_prj(f, dis, prj) rmf_read_dis(f)
#> RMODFLOW Discretization File object with: #> 10 rows, 10 columns and 3 layers totalling 300 cells #> #> Time units: seconds #> Length units: meters #> #> Spacing along rows (DELR): 100 (constant) #> Spacing along columns (DELC): 100 (constant) #> #> Summary of top elevations: #> Top #> Min. :0 #> 1st Qu.:0 #> Median :0 #> Mean :0 #> 3rd Qu.:0 #> Max. :0 #> #> Summary of bottom elevations: #> Layer 1 Layer 2 Layer 3 #> Min. -10 -20 -30 #> 1st Qu. -10 -20 -30 #> Median -10 -20 -30 #> Mean -10 -20 -30 #> 3rd Qu. -10 -20 -30 #> Max. -10 -20 -30 #> #> Information for 1 stress-period: #> Period Length Timesteps Multiplier Type #> 1 1 1 1 Steady-state #> #> RMODFLOW Projection object: #> Origin coordinates (x y z) of the lowerleft corner: #> 100 -150 0 #> Grid rotation (degrees counterclockwise): #> 0 #> Coordinate Reference System: #> NA
prj <- rmf_create_prj(origin = c(152082, 168000.2), rotation = -12, crs = 31370) dis <- rmf_create_dis(prj = prj) rmf_transform_prj(prj, crs = 4326)
#> Warning: RMODFLOW does not work optimally for geographic coordinates. Please consider using a projected crs.
#> RMODFLOW Projection object: #> Origin coordinates (x y z) of the lowerleft corner: #> 4.3983 50.82243 0 #> Grid rotation (degrees counterclockwise): #> -12 #> Coordinate Reference System: #> EPSG: 4326 #> proj4string: +proj=longlat +datum=WGS84 +no_defs
rmf_transform_prj(dis, crs = 3044)
#> RMODFLOW Discretization File object with: #> 10 rows, 10 columns and 3 layers totalling 300 cells #> #> Time units: seconds #> Length units: meters #> #> Spacing along rows (DELR): 100 (constant) #> Spacing along columns (DELC): 100 (constant) #> #> Summary of top elevations: #> Top #> Min. :0 #> 1st Qu.:0 #> Median :0 #> Mean :0 #> 3rd Qu.:0 #> Max. :0 #> #> Summary of bottom elevations: #> Layer 1 Layer 2 Layer 3 #> Min. -10 -20 -30 #> 1st Qu. -10 -20 -30 #> Median -10 -20 -30 #> Mean -10 -20 -30 #> 3rd Qu. -10 -20 -30 #> Max. -10 -20 -30 #> #> Information for 1 stress-period: #> Period Length Timesteps Multiplier Type #> 1 1 1 1 Steady-state #> #> RMODFLOW Projection object: #> Origin coordinates (x y z) of the lowerleft corner: #> 175939.9 5640176 0 #> Grid rotation (degrees counterclockwise): #> -12 #> Coordinate Reference System: #> EPSG: 3044 #> proj4string: +proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
if (FALSE) { # error when no prj is present rmf_transform_prj(rmf_create_dis(), 3044) }