epsg | R Documentation |
Functions to work with EPSG projection specifications
agency.root(agency = NULL)
getEPSG(ref.id = 4326, verbose = TRUE, agency = NULL)
D_project(Df, coords = names(Df)[1:2], p4, p4old, verbose = TRUE, ...)
agency |
character; |
ref.id |
integer; |
verbose |
logical; |
Df |
an object to be coerced into a |
coords |
character; the names of the coordinates in |
p4 , p4old |
character; these are the proj4 strings for the new ( |
... |
additional parameters to |
A list of EPSG projections: http://spatialreference.org/ref/epsg/
A list of PROJ commands: https://trac.osgeo.org/proj/wiki/GenParms
## Not run:
library(maps)
library(maptools)
library(datasets)
data(state)
states <- data.frame(state.x77, state.center)
# HI/AK are in the middle of the ocean, so take them out:
states <- states[states$x > -121,]
# uses getEPSG to project if p4/p4old are missing
d1 <- D_project(states, c("x","y"))
# set p4
p <- getEPSG()
d2 <- D_project(states, c("x","y"), p)
all.equal(d1,d2) # TRUE
# reproject into UTM-11 in kilometers
d2u <- spTransform(d2, CRS("+proj=utm +zone=11 +ellps=WGS84 +units=km"))
# change the projection
pold <- p
p <- getEPSG(2153) # UTM-11 in meters
d3 <- D_project(states, c("x","y"), p, pold)
layout(matrix(1:6,ncol=3))
us <- map("usa",plot=FALSE)
plot(d1, axes=TRUE); title("d1"); lines(us)
plot(d2, axes=TRUE);title("d2 (== d1)"); lines(us)
plot(d2u, axes=TRUE);title("d2 - utm11/km")
plot(d3, axes=TRUE);title("d3 - utm11/m")
#
# rotate with maptools (can also do this using ...)
plot(elide(d2u, rotate=45));title("d2 at 45") # clockwise
plot(elide(d2u, rotate=-45));title("d2 at -45") # counter-clockwise
#
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.