[R-sig-Geo] Reading and projecting lat/long point coordinates using R?

Sander Oom slist at oomvanlieshout.net
Thu Mar 31 13:32:31 CEST 2005


Hi Rick,

Map projections can be done with the package proj4R developed by Roger 
Bivand (http://spatial.nhh.no/R/Devel/). Roger send me a development 
version to use with R2.0.1.

This is the code I use to project to Albers equal area and UTM in South 
Africa (the projection settings listed in the comments come from GRASS):

   ## Project data with proj4R
   datSable.XY <- cbind(datSable$Longitude, datSable$Latitude)
   ## Albers Equal Area projection for SA
   ## elipse or datum    WGS84
   ## false eastings     0
   ## false northing     0
   ## central meridian   24
   ## stand parr_1       -18
   ## stand parr_2       -32
   ## lat of origin      0
   ## output of project is a matrix!
   datSable.XYaea <- project(datSable.XY, "+proj=aea +ellps=WGS84 
+lon_0=24 +lat_0=0 +lat_1=18s +lat_2=32s +x_0=0 +y_0=0 ")
   nrow(datSable.XYaea)
   tmp <- data.frame(datSable.XYaea)
   datSable <- data.frame(datSable, Xaea=tmp$X1, Yaea=tmp$X2)
# name: UTM
# datum: WGS84
# towgs84: 0.000,0.000,0.000
# proj: utm
# ellps: wgs84
# a: 6378137.0000000000
# es: 0.0066943800
# f: 298.2572235630
# zone: 36
# south: defined
   datSable.XYutm <- project(datSable.XY, "+proj=utm +ellps=WGS84 
+zone=36S +south +units=m ")

This should work on polygon coordinates to!

The packages maps and maptools might provide a solution to the area of 
the polygons.

Let me know what you manage to do. I am trying similar things: see 
earlier posts on the r-geo list.

Cheers,

Sander.

Rick Reeves wrote:
> 
> Hello: 
> 
> I've searched the literature, havent found an answer, so here goes? 
> 
> We have a set of polygon features defined as a series of unprojected
> vertices represented by lat/long pairs, in an ASCII-format file.
> 
> We need to display (on a map-like plot) and then calculate the areas 
> of the polygons, and would like to do this entirely within R if
> possible.
> Is there a map projection package for R? Or, has anyone solved this
> or a related problem using R? I could do this with the MATLAB mapping
> toolbox, but prefer to use R if possible....
> 
> 
> Thanks, 
> 
> Rick Reeves
> 
> Scientific Programmer / Quantitative Analyst
> National Center for Ecological Analysis and Synthesis
> University of California, Santa Barbara
> 805 892 2534
> reeves at nceas.ucsb.edu
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
--------------------------------------------
Dr. Sander P. Oom
Animal, Plant and Environmental Sciences,
University of the Witwatersrand
Private Bag 3, Wits 2050, South Africa
Tel (work)      +27 (0)11 717 64 04
Tel (home)      +27 (0)18 297 44 51
Fax             +27 (0)18 299 24 64
Email   sander at oomvanlieshout.net
Web     www.oomvanlieshout.net/sander




More information about the R-sig-Geo mailing list