Convert map projection of a object of class prevR.
Source:R/changeproj.prevR.r
changeproj-prevR-method.Rd
This function converts map projection (and/or datum) used by an object of class prevR into another one.
Arguments
- object
object of class prevR.
- proj
new map projection. One of (i) character: a string accepted by GDAL, (ii) integer, a valid EPSG value (numeric), or (iii) an object of class
crs
, seesf::st_crs()
.
Details
changeproj()
transform the columns "x" and "y" of the slot
clusters
of object
and convert boundary
using the new
map projection defined by proj
.
If applicable, the slot rings
will be recalculated.
Examples
print(fdhs)
#> Object of class 'prevR'
#> Number of clusters: 401
#> Number of observations: 8000
#> Number of positive cases: 810
#> The dataset is weighted.
#>
#> National prevalence: 10.12%
#> National weighted prevalence: 10.16%
#>
#> Projection used: +proj=longlat +datum=WGS84
#>
#> Coordinate range
#> min max
#> x -5.37750 3.6850
#> y 4.80326 14.1225
#>
#> Boundary coordinate range
#> xmin ymin xmax ymax
#> -5.518916 4.736723 3.851701 15.082593
plot(fdhs, axes = TRUE, main = "Projection: longitude/latitude")
fdhs2 <- changeproj(
fdhs,
"+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
)
print(fdhs2)
#> Object of class 'prevR'
#> Number of clusters: 401
#> Number of observations: 8000
#> Number of positive cases: 810
#> The dataset is weighted.
#>
#> National prevalence: 10.12%
#> National weighted prevalence: 10.16%
#>
#> Projection used: +proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
#>
#> Coordinate range
#> min max
#> x 240094.2 1231995
#> y 531003.3 1562155
#>
#> Boundary coordinate range
#> xmin ymin xmax ymax
#> 224228.1 523628.1 1251165.0 1669034.2
plot(fdhs2, axes = TRUE, main = "Projection: UTM Zone 30")