- Home
- LibGuides
- R: Mapping and Geospatial
- Projections / CRS

Geospatial applications using the R programming language

- Overview of Coordinate Reference SystemsA four page cheat sheet about coordinate reference systems (CRSs), including projections, datums, and coordinate systems, and the use of these in R.

Left: Unprojected (Longitude/Latitude) using World Geodetic System 1984 Datum (WGS84) (EPSG = 4326)

Right: USA Contiguous Albers Equal Area Conic, USGS (EPSG = 5070 or 102003)

- st_transform() function in 'sf' packageTransform or convert coordinates of simple features.
- spTransform() function in 'sp' packageTransform for map projection and datum transformation using the sp package.
- projectRaster() in 'raster' packageProject the values of a Raster object to a new Raster* object with another projection (coordinate reference system, (CRS)).
- set_projection() function in 'tmaptools' packageThe function set_projection sets the projection of a shape file. It is a convenient wrapper of st_transform (or st_transform_proj, see details) and projectRaster, with shortcuts for commonly used projections
- Package 'proj4'A simple interface to the PROJ.4 cartographic projections libraryproject() function: Projection of lat/long coordinates or its inverse.

ptransform() function: Transformation of geographics coordinates from one projection to another, using PROJ.4 library - st_transform_proj() function in 'lwgeom' packageTransform or convert coordinates of simple features directly with Proj.4 (bypassing GDAL)

- Spatialreference.orgLists EPSG code numbers used in R to identify and change map projections.
- EPSG.ioAnother web service with a database of coordinates systems used in maps worldwide

**Planar and Geodesic: **Sometimes, you'll see these terms used with respect to geospatial data.

**Geodesic:**Unprojected data; measured in**degrees**; distance measurements follow curvature of earth's surface. The first two CRS's in the table below are examples.**Planar:**Projected data (earth is mathematically flattened); measured in**meters**or**feet**; distance is measured in straight lines on the flat surface.

**A Few Useful EPSG Codes
â€‹Use as the projection argument of tmaptools::set_projection()**

CRS |
Projection |
Datum |
Units |
EPSG code |

World Geodetic System 1984 | Unprojected | WGS84 | degrees | 4326 |

North American Datum 1983 [US Census data] | Unprojected | NAD83 | degrees | 4269 |

Pseudo-Mercator (Web Mercator; Spherical Mercator) [Google Maps, etc.] | Mercator | WGS84 | meters | 3857 |

World Robinson [Natl Geo world maps 1988-98] | Robinson | WGS84 | meters | 54030 |

World Van der Grinten [Natl Geo world maps 1922-88] | Van Der Grinten I | WGS84 | meters | 54029 |

World Eckert IV [equal area] | Eckert IV | WGS84 | meters | 54012 |

World Mollweide [equal area] | Mollweide | WGS84 | meters | 54009 |

World Equidistant Cylindrical | Equidistant Cylindrical | WGS84 | meters | 4087 |

North America Albers Equal Area Conic | Albers | NAD83 | meters | 102008 |

USA Contiguous Albers Equal Area Conic | Albers | NAD83 | meters | 5070 or 102003 |

North America Lambert Conformal Conic | Lambert Conformal Conic | NAD83 | meters | 102009 |

USA Contiguous Lambert Conformal Conic | Lambert Conformal Conic | NAD83 | meters | 102004 |

State Plane North Carolina Feet | Lambert Conformal Conic | NAD83 | feet | 2264 |

State Plane North Carolina Meters | Lambert Conformal Conic | NAD83 | meters | 32119 |

UTM zone 17N [good for NC] | Transverse Mercator | WGS84 | meters | 32617 |

British National Grid | Transverse Mercator | OSGB 1936 | meters | 27700 |

Asia North Albers Equal Area Conic [OK for China] | Albers | WGS84 | meters | 102025 |

- set_projection() function of tmaptoolsThis function has some shortcuts (besides just the EPSG codes) some for worldwide projections, a few of which don't have EPSG codes.

Some **set_projection() **shortcut codes for world maps or for UTM zones.

- "wintri" Winkel Tripel, a projection used in world maps made by National Geographic since 1998. Balances nicely the distortion of area, shape, distance, and angle.
- "igh" Interrupted Goode Homosoline, an equal-area projection for world maps that looks like an unpeeled orange peel, used in Rand McNally's Goode atlases.
- "gall" Gall Orthographic (a.k.a., Peters), an equal-area projection for world maps that dramatically distorts shape.
- "utmXX(s)" Universal Transverse Mercator. XX is the zone (see maps elsewhere in this guide). Add "s" for southern hemisphere. Using this with set_projection() is an alternative to looking up the EPSG code for the zone.

Example R code:

set_projection(shp, projection = "code")`set_projection(world_admin, projection = "wintri")`

where *shp* is your geographic file and *code* is the shortcut code. See the documentation for more important information.

- Last Updated: Apr 23, 2022 8:38 AM
- URL: https://guides.library.duke.edu/r-geospatial
- Print Page

411 Chapel Drive

Durham, NC 27708

Durham, NC 27708

(919) 660-5870

Perkins Library Service Desk

Perkins Library Service Desk