Skip to content

Reading and projecting lat/long point coordinates using R?

1 message · Anthony Westerling

#
If you want a base map to add your polygons to, you can use the Maps 
package in R, or plot a map from a shapefile or arcinfo coverage using 
Rmap or maptools libraries (for shapefile format) or RArcInfo (for e00 
or avc formats) in R.  To add your polygons to the figure just use 
polygon().  If you need to reproject the coordinates in your polygons 
you can use mapproject() in the mapproj library or project() in Rmap(). 
  I prefer project() (it can convert from a projection to geographic 
coordinates (ie, lat/lon), while I think mapproject() just takes 
geographic coordinates) but mapproject() has more documentation.  Both 
use proj4 library (libproj), so you will need to install that.  To use 
shapefiles you need libshp.

I think Rmap is still not distributed via CRAN.  You can find it at 
http://www.maths.lancs.ac.uk/Software/Rmap/

I've linked the documentation for the proj4 library to Barry 
Rowlingson's Rmap documentation, which can be useful when you are 
re-projecting coordinates.  If you want it,  the zipped html files are 
~9 MB.  The original sources are on the web of course.

areapl() in the splancs library can calculate the area of a polygon.

Anthony L. Westerling
Climate Research Division
Scripps Institution of Oceanography
University of California, San Diego
858 822 4057
leroy at ucsd.edu