[R-sig-Geo] Problem with spTransform() function
ASANTOS
alexandresantosbr at yahoo.com.br
Wed Jul 24 14:37:21 CEST 2013
Dear Members,
I have a problem with spTransform() function, when I try to use a
object in UTM Zone 23K south and project in latlong south. First, I have
a polygon SP object in UTM ( CRS("+proj=utm +zone=23+south +datum=WGS84
+units=m +no_defs"))
> bbox(SP)
min max
x 772259.1 775259.1
y 7840046.0 7843046.0
But if a using spTransform() for latlong (CRS("+proj=longlat +south
+datum=WGS84")):
> bbox(SPlatlong)
min max
x -37.67016 -37.58043
y 70.51439 70.54432
There are something wrong, because the min values are x -37.67016 and
y 70.51439, but I suppose to be x -42.4058069902 and y -19.5157348241.
What's the conversion problem?
My example:
require(sp)
require(rgdal)
# Create one point in UTM
xcc<-773759.1
ycc<-7841546
p.central<-cbind(xcc,ycc) ##Centroid
###Countour area
coordV<-NULL
coordV
<-rbind(coordV,cbind(p.central[,1]+c(-1500,1500,1500,-1500,-1500),p.central[,2]+c(1500,1500,-1500,-1500,1500)))
plot(coordV[,1],coordV[,2])
points(p.central[,1],p.central[,2], col="red")
#
# Creat a polygon
bnds <- cbind(x=c(coordV[,1]), y=c(coordV[,2]))
# Convert in spatial polygon and project in UTM Zone 23K
SP <- SpatialPolygons(list(Polygons(list(Polygon(bnds)), "1")))
proj4string(SP) = CRS("+proj=utm +zone=23+south +datum=WGS84 +units=m
+no_defs") ## Projeção
# Reproject the same area in latlong south
SPlatlong<- spTransform(SP, CRS("+proj=longlat +south +datum=WGS84"))
#
Thanks,
--
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT CEP: 78.200-000
Fone: (+55) 65 8132-8112 (TIM) (+55) 65 9686-6970 (VIVO)
alexandre.santos at cas.ifmt.edu.br
Lattes: http://lattes.cnpq.br/1360403201088680
More information about the R-sig-Geo
mailing list