[R-sig-Geo] Checking for equivalence of PROJ4 strings.

Josh O'Brien joshmobrien at gmail.com
Tue Mar 12 00:16:14 CET 2013


Hello,

Is there a better / more official / less error-prone way than the
following to check the equivalence of two PROJ4 strings?

checkProjEquivalence <- function(SP, crs1, crs2) {
    cc1 <- coordinates(spTransform(SP, crs1))
    cc2 <- coordinates(spTransform(SP, crs2))
    identical(cc1, cc2)
}

## Example inputs
crs1 <- CRS("+proj=utm +zone=11 +datum=NAD83 +units=m +no_defs
+ellps=GRS80 +towgs84=0,0,0")
crs2 <- CRS("+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0
+units=m +no_defs")
SP <- SpatialPoints(cbind(457900, 4918700), proj4string = crs1)

## Trying it out
checkProjEquivalence(SP, crs1, crs2)
## [1] TRUE



More information about the R-sig-Geo mailing list