Description Usage Arguments References Examples
Functions to work with EPSG projection specifications
1 2 3 4 5 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## 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.