prj_auxiliary: Functions to get, set, transform and check presence of prj...

prj_auxiliaryR Documentation

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

Description

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

Usage

rmf_get_prj(...)

## S3 method for class 'dis'
rmf_get_prj(dis)

## S3 method for class 'modflow'
rmf_get_prj(modflow)

rmf_has_prj(...)

## S3 method for class 'dis'
rmf_has_prj(dis)

## S3 method for class 'modflow'
rmf_has_prj(modflow)

rmf_set_prj(...)

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

## S3 method for class 'dis'
rmf_set_prj(dis, prj)

## S3 method for class 'modflow'
rmf_set_prj(modflow, prj)

rmf_transform_prj(...)

## S3 method for class 'prj'
rmf_transform_prj(prj, crs)

## S3 method for class 'dis'
rmf_transform_prj(dis, crs)

## S3 method for class '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.

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.

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

Examples

dis <- rmf_read_dis(rmf_example_file('water-supply-problem.dis'))
rmf_get_prj(dis)

m <- rmf_read(rmf_example_file('example-model.nam'), verbose = FALSE)
rmf_get_prj(m)

# return NULL
rmf_get_prj(rmf_create_dis())

rmf_has_prj(dis)
rmf_has_prj(m)
rmf_has_prj(rmf_create_dis())

dis <- rmf_create_dis()
prj <- rmf_create_prj(origin = c(100, -150))
rmf_set_prj(dis, prj)

# 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)

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)
rmf_transform_prj(dis, crs = 3044)

## Not run: 
# error when no prj is present
rmf_transform_prj(rmf_create_dis(), 3044)

## End(Not run)


rogiersbart/RMODFLOW documentation built on Jan. 14, 2023, 4:21 a.m.