# converting coordinates from utm to longitude / latitude

 Classic List Threaded
7 messages
Reply | Threaded
Open this post in threaded view
|

## converting coordinates from utm to longitude / latitude

 Hi, is there a function in R to convert data read with read.shape and which is originally in UTM coordinates into longitude / latitude coordinates? I found the convUL() function from the PBSmapping package but I have no idea how I could apply that to the read.shape object. Many thanks,   Werner __________________________________________________ Do sragenden Schutz gegen Massenmails. http://mail.yahoo.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: converting coordinates from utm to longitude / latitude

 It would be nicer to convert directly the entire shapefile object to long/lat coordinates but if that is not possible, I will convert the other points to UTM. Hence, I am playing around with rgdal. library(rgdal) SP <- SpatialPoints(cbind(32.29252, -0.3228500),   proj4string=CRS("+proj=longlat")) spTransform(SP, CRS("+proj=utm +zone=36")) > spTransform(SP, CRS("+proj=utm +zone=36")) SpatialPoints:      coords.x1 coords.x2 [1,]  421274.4 -35687.37 Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +ellps=WGS84 This result corresponds with what I get when using convUL() but my map of that area in UTM coordinates does not extend to the negative. An external program converts the point to x=420994   y=9964407 which also seems correct with respect to the map. Fore sure, I am using the function wrongly somehow. Can anyone give me a hint? That's very much appreciated! Thanks,    Werner ----- Ursprüngliche Mail ---- Von: Werner Wernersen <[hidden email]> An: [hidden email] Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr Betreff: converting coordinates from utm to longitude / latitude Hi, is there a function in R to convert data read with read.shape and which is originally in UTM coordinates into longitude / latitude coordinates? I found the convUL() function from the PBSmapping package but I have no idea how I could apply that to the read.shape object. Many thanks,   Werner ______________________________ fügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com__________________________________________________ Do ragenden Schutz gegen Massenmails. http://mail.yahoo.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: converting coordinates from utm to longitude / latitude

 If you would like to convert the entire shapfile check out GDAL: http://www.gdal.org/http://casoilresource.lawr.ucdavis.edu/drupal/node/98Cheers, Dylan On Tuesday 19 August 2008, Werner Wernersen wrote: > It would be nicer to convert directly the entire shapefile object to > long/lat coordinates but if that is not possible, I will convert the other > points to UTM. Hence, I am playing around with rgdal. > > library(rgdal) > SP <- SpatialPoints(cbind(32.29252, -0.3228500), >   proj4string=CRS("+proj=longlat")) > spTransform(SP, CRS("+proj=utm +zone=36")) > > > spTransform(SP, CRS("+proj=utm +zone=36")) > > SpatialPoints: >      coords.x1 coords.x2 > [1,]  421274.4 -35687.37 > Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 > +ellps=WGS84 > > This result corresponds with what I get when using convUL() but my map of > that area in UTM coordinates does not extend to the negative. An external > program converts the point to x=420994   y=9964407 which also seems correct > with respect to the map. Fore sure, I am using the function wrongly > somehow. Can anyone give me a hint? > > That's very much appreciated! > > Thanks, >    Werner > > > > ----- Ursprüngliche Mail ---- > Von: Werner Wernersen <[hidden email]> > An: [hidden email] > Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr > Betreff: converting coordinates from utm to longitude / latitude > > Hi, > > is there a function in R to convert data read with read.shape and which is > originally in UTM coordinates into longitude / latitude coordinates? I > found the convUL() function from the PBSmapping package but I have no idea > how I could apply that to the read.shape object. > > Many thanks, >   Werner > > > ______________________________ > fügt über einen herausragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > > __________________________________________________ > Do > ragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, minimal, > self-contained, reproducible code. -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/University of California at Davis 530.754.7341 ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: converting coordinates from utm to longitude / latitude

 In reply to this post by Werner Werner Wernersen wrote: > It would be nicer to convert directly the entire shapefile object to long/lat coordinates but if that is not possible, I will convert the other points to UTM. > Hence, I am playing around with rgdal. > > library(rgdal) > SP <- SpatialPoints(cbind(32.29252, -0.3228500), >   proj4string=CRS("+proj=longlat")) > spTransform(SP, CRS("+proj=utm +zone=36")) > > >> spTransform(SP, CRS("+proj=utm +zone=36")) > SpatialPoints: >      coords.x1 coords.x2 > [1,]  421274.4 -35687.37 > Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +ellps=WGS84 > > This result corresponds with what I get when using convUL() but my map of that area in UTM coordinates does not extend to the negative. > An external program converts the point to x=420994   y=9964407 which also seems correct with respect to the map. Fore sure, I am using the function wrongly somehow. Can anyone give me a hint? It looks like you are specifying 36S in your external program, and (implicitly) 36N in R. Using your SP from above, note the following:  > spTransform(SP, CRS("+proj=utm +zone=36 +north")) SpatialPoints:       coords.x1 coords.x2 [1,]  421274.4 -35687.37 Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +ellps=WGS84  > spTransform(SP, CRS("+proj=utm +zone=36 +south")) SpatialPoints:       coords.x1 coords.x2 [1,]  421274.4   9964313 Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +south +ellps=WGS84 The latter gets in the ballpark of output from your external program. I'd speculate that the remaining differences owe to different assumptions about e.g. the datum (WGS84 for the R statements given above), but I must admit I'm not a geographer. Hope that helps, Jim > That's very much appreciated! > > Thanks, >    Werner > > > > ----- Ursprüngliche Mail ---- > Von: Werner Wernersen <[hidden email]> > An: [hidden email] > Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr > Betreff: converting coordinates from utm to longitude / latitude > > Hi, > > is there a function in R to convert data read with read.shape and which is originally in UTM coordinates into longitude / latitude coordinates? > I found the convUL() function from the PBSmapping package but I have no idea how I could apply that to the read.shape object. > > Many thanks, >   Werner > > > ______________________________ > fügt über einen herausragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > > __________________________________________________ > Do > ragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: converting coordinates from utm to longitude / latitude

 In reply to this post by Werner You were absolutely right. If I use south everything is fine. That once again proves the danger of intuition. I simply assumed since almost all of the map is on the northern half that the projection should use north as well. But that is apparently wrong. I couldn't find any description of these definition string parameters which could have been informative. Since I am not a geographer either, I probably used the wrong terms for searching. Anyway, now it works. Thanks so much for the help, Jim! Best regards,   Werner ----- Ursprüngliche Mail ---- Von: Jim Regetz <[hidden email]> An: Werner Wernersen <[hidden email]> CC: [hidden email] Gesendet: Mittwoch, den 20. August 2008, 03:08:48 Uhr Betreff: Re: converting coordinates from utm to longitude / latitude Werner Wernersen wrote: > It would be nicer to convert directly the entire shapefile object to long/lat coordinates but if that is not possible, I will convert the other points to UTM. > Hence, I am playing around with rgdal. > > library(rgdal) > SP <- SpatialPoints(cbind(32.29252, -0.3228500), >   proj4string=CRS("+proj=longlat")) > spTransform(SP, CRS("+proj=utm +zone=36")) > > >> spTransform(SP, CRS("+proj=utm +zone=36")) > SpatialPoints: >      coords.x1 coords.x2 > [1,]  421274.4 -35687.37 > Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +ellps=WGS84 > > This result corresponds with what I get when using convUL() but my map of that area in UTM coordinates does not extend to the negative. > An external program converts the point to x=420994   y=9964407 which also seems correct with respect to the map. Fore sure, I am using the function wrongly somehow. Can anyone give me a hint? It looks like you are specifying 36S in your external program, and (implicitly) 36N in R. Using your SP from above, note the following: > spTransform(SP, CRS("+proj=utm +zone=36 +north")) SpatialPoints:       coords.x1 coords.x2 [1,]  421274.4 -35687.37 Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +ellps=WGS84 > spTransform(SP, CRS("+proj=utm +zone=36 +south")) SpatialPoints:       coords.x1 coords.x2 [1,]  421274.4   9964313 Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 +south +ellps=WGS84 The latter gets in the ballpark of output from your external program. I'd speculate that the remaining differences owe to different assumptions about e.g. the datum (WGS84 for the R statements given above), but I must admit I'm not a geographer. Hope that helps, Jim > That's very much appreciated! > > Thanks, >    Werner > > > > ----- Ursprüngliche Mail ---- > Von: Werner Wernersen <[hidden email]> > An: [hidden email] > Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr > Betreff: converting coordinates from utm to longitude / latitude > > Hi, > > is there a function in R to convert data read with read.shape and which is originally in UTM coordinates into longitude / latitude coordinates? > I found the convUL() function from the PBSmapping package but I have no idea how I could apply that to the read.shape object. > > Many thanks, >   Werner > > > ______________________________ > fügt über einen herausragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > > __________________________________________________ > Do > ragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > ________________________________________ ber einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: converting coordinates from utm to longitude / latitude

 In reply to this post by Werner After having figured out that I had to download the proj.dll file additionally (it would be nice if they actually added a note to their readme) and setting the "+south" parameter, the conversion of the shapfile from UTM to long/lat with the ogr2ogr utility from gdal worked perfectly. Thanks so much Dylan!   Werner ----- Ursprüngliche Mail ---- Von: Dylan Beaudette <[hidden email]> An: [hidden email] CC: Werner Wernersen <[hidden email]> Gesendet: Dienstag, den 19. August 2008, 23:29:34 Uhr Betreff: Re: [R] converting coordinates from utm to longitude / latitude If you would like to convert the entire shapfile check out GDAL: http://www.gdal.org/http://casoilresource.lawr.ucdavis.edu/drupal/node/98Cheers, Dylan On Tuesday 19 August 2008, Werner Wernersen wrote: > It would be nicer to convert directly the entire shapefile object to > long/lat coordinates but if that is not possible, I will convert the other > points to UTM. Hence, I am playing around with rgdal. > > library(rgdal) > SP <- SpatialPoints(cbind(32.29252, -0.3228500), >   proj4string=CRS("+proj=longlat")) > spTransform(SP, CRS("+proj=utm +zone=36")) > > > spTransform(SP, CRS("+proj=utm +zone=36")) > > SpatialPoints: >      coords.x1 coords.x2 > [1,]  421274.4 -35687.37 > Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 > +ellps=WGS84 > > This result corresponds with what I get when using convUL() but my map of > that area in UTM coordinates does not extend to the negative. An external > program converts the point to x=420994   y=9964407 which also seems correct > with respect to the map. Fore sure, I am using the function wrongly > somehow. Can anyone give me a hint? > > That's very much appreciated! > > Thanks, >    Werner > > > > ----- Ursprüngliche Mail ---- > Von: Werner Wernersen <[hidden email]> > An: [hidden email] > Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr > Betreff: converting coordinates from utm to longitude / latitude > > Hi, > > is there a function in R to convert data read with read.shape and which is > originally in UTM coordinates into longitude / latitude coordinates? I > found the convUL() function from the PBSmapping package but I have no idea > how I could apply that to the read.shape object. > > Many thanks, >   Werner > > > ______________________________ > fügt über einen herausragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > > __________________________________________________ > Do > ragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, minimal, > self-contained, reproducible code. -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/University of California at Davis 530.754.7341 __________________________________________________ Do You Yahoo!? Sie sind Massenmails. http://mail.yahoo.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: converting coordinates from utm to longitude / latitude

 In reply to this post by Werner I forgot one more potentially time-saving hint if someone else wants to use org2org for such a conversion: I found that only GDAL for Windows 1.4.4 works together with the proj.dll file which is downloadable from proj.4 but version 1.5 does not. ----- Ursprüngliche Mail ---- Von: Dylan Beaudette <[hidden email]> An: [hidden email] CC: Werner Wernersen <[hidden email]> Gesendet: Dienstag, den 19. August 2008, 23:29:34 Uhr Betreff: Re: [R] converting coordinates from utm to longitude / latitude If you would like to convert the entire shapfile check out GDAL: http://www.gdal.org/http://casoilresource.lawr.ucdavis.edu/drupal/node/98Cheers, Dylan On Tuesday 19 August 2008, Werner Wernersen wrote: > It would be nicer to convert directly the entire shapefile object to > long/lat coordinates but if that is not possible, I will convert the other > points to UTM. Hence, I am playing around with rgdal. > > library(rgdal) > SP <- SpatialPoints(cbind(32.29252, -0.3228500), >   proj4string=CRS("+proj=longlat")) > spTransform(SP, CRS("+proj=utm +zone=36")) > > > spTransform(SP, CRS("+proj=utm +zone=36")) > > SpatialPoints: >      coords.x1 coords.x2 > [1,]  421274.4 -35687.37 > Coordinate Reference System (CRS) arguments: +proj=utm +zone=36 > +ellps=WGS84 > > This result corresponds with what I get when using convUL() but my map of > that area in UTM coordinates does not extend to the negative. An external > program converts the point to x=420994   y=9964407 which also seems correct > with respect to the map. Fore sure, I am using the function wrongly > somehow. Can anyone give me a hint? > > That's very much appreciated! > > Thanks, >    Werner > > > > ----- Ursprüngliche Mail ---- > Von: Werner Wernersen <[hidden email]> > An: [hidden email] > Gesendet: Dienstag, den 19. August 2008, 20:28:29 Uhr > Betreff: converting coordinates from utm to longitude / latitude > > Hi, > > is there a function in R to convert data read with read.shape and which is > originally in UTM coordinates into longitude / latitude coordinates? I > found the convUL() function from the PBSmapping package but I have no idea > how I could apply that to the read.shape object. > > Many thanks, >   Werner > > > ______________________________ > fügt über einen herausragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > > __________________________________________________ > Do > ragenden Schutz gegen Massenmails. > http://mail.yahoo.com> > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, minimal, > self-contained, reproducible code. -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/University of California at Davis 530.754.7341 __________________________________________________ Do You Yahoo!? Sie sind Massenmails. http://mail.yahoo.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.