On Fri, 8 May 2009, Renaud Lancelot wrote:
Thank you, here is the full process trying to follow Edzer's suggestion:
library(RODBC)
library(rgdal)
channel <- odbcConnectAccess("farms.mdb")
sigal <- sqlQuery(channel, "select * from T_SIGAL")
Liste <- by(sigal,
list(zone = sigal$zone),
function(x){
strg <- paste("+proj=utm +ellps=intl +zone=",
unique(x$zone), sep = "")
SP <- SpatialPoints(cbind(x$UTM_X, x$UTM_Y),
proj4string=CRS(strg))
as.data.frame(spTransform(SP, CRS("+proj=longlat
+datum=WGS84")))
})
sigal2 <- do.call("rbind", Liste)
dimnames(sigal2) <- list(seq(nrow(sigal2)), c("x", "y"))
Plotting the result looks fine but I need to check further.
BTW, is it possible to stack directly the SpatialPoints objects?
Yes, you could use the spRbind() method in maptools:
library(maptools)
set.seed(1)
a <- SpatialPoints(matrix(runif(100), ncol=2))
b <- SpatialPoints(matrix(runif(100), ncol=2))
c <- spRbind(a, b)
plot(c, axes=TRUE)
points(a, col="green")
points(b, col="red")
Roger
Thank you for your help!
Renaud
2009/5/8 Jim Burke <j.bu...@earthlink.net>
Its all quite simple I think (i.e. "hope"). Have
you used spTransform(rdgal)?
## here I have a file from a local group delivered
## in UTM format that I transformed OK to long-lat.
library(rgdal) # for map projection support; automatically loads sp
## transform internal measurements from UTM to long lat format
longlat_sp <- spTransform(UTM_format_sp, CRS("+init=epsg:4326"))
sapply(slot(longlat_sp, "polygons"), function(x) slot(x, "ID"))
showMethods("spTransform")
Function: spTransform (package rgdal)
x="SpatialGridDataFrame", CRSobj="CRS"
x="SpatialLines", CRSobj="CRS"
x="SpatialLinesDataFrame", CRSobj="CRS"
x="SpatialPixelsDataFrame", CRSobj="CRS"
x="SpatialPoints", CRSobj="CRS"
x="SpatialPointsDataFrame", CRSobj="CRS"
x="SpatialPolygons", CRSobj="CRS"
x="SpatialPolygonsDataFrame", CRSobj="CRS"
Hope this helps,
Jim Burke
Renaud Lancelot wrote:
Thank you Edzer. I was hoping there was a simpler solution, but it's still
fairly simple.
Renaud
2009/5/7 Edzer Pebesma <edzer.pebe...@uni-muenster.de>
Yes, but you will not like that call.
In R (package sp), each spatial data set can only have one single
projection. I'd suggest, in pseudo-code
- import the data into a data.frame
- for each UTM zone do:
select the locations
set their CRS
reproject to long/lat
- cbind the locations to a single data structure
- convert back to data.frame if needed.
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of M?nster
Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/
http://www.springer.com/978-0-387-78170-9 e.pebe...@wwu.de
Renaud Lancelot wrote:
Dear all,
I have a big dataset (> 200,000 lines) of georeferenced locations
where the coordinates are given in UTM, spanning over several zones.
Is is possible to convert all the UTM coordinates into longlat WGS84
with a single call ?
Renaud
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
------------------------------------------------------------------------
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo