[R-sig-Geo] spTransform changes the bounding box
PCB
pedrocontebarros at gmail.com
Sat Jun 23 20:20:04 CEST 2012
Dear All,
I have been trying to use spTransform to convert some lon-lat data
(SpatialPointsDataFrame) onto Equal Area projection.
However, it seems that spTransform changes the bounding box of the data to
contain exclusively the data points, and this crashes my code.
I have been looking around, but could not find out what I am doing wrong.
Is there a way to tell spTransform not to change the bounding box?
Some reproducible example:
bbox1 <- matrix(c(10, 20, -25, -3), , ncol=2, byrow = T)
dimnames(bbox1) <- list(c("lon", "lat"), c("min", "max"))
CRSWG84 <- CRS(" +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
+towgs84=0,0,0")
#Two points inside the bounding box
pts1 <- SpatialPoints(coords = matrix(c(12, 15, -20, - 10), nrow=2, byrow=F)
, bbox=bbox1, proj4string = CRSWG84)
#Check the bounding box
bbox(pts1)
#I get
# min max
#lon 10 20
#lat -25 -3
##Project into Lambert Azimuthal Equal Area
CRSEqA <- CRS(" +proj=laea +ellps=WGS84")
pts1Laea <- spTransform(pts1, CRSEqA)
#Reproject back
pts1LonLat <- spTransform(pts1Laea, CRSWG84)
#Check the bounding box
bbox(pts1LonLat)
#I get
# min max
#lon 12 15
#lat -20 -10
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/spTransform-changes-the-bounding-box-tp7580319.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list