2.2 Coordinate reference systems

Spatial data representation is represented with projected coordinate reference systems (CRS).

What the CRS do?

  • set the origin and the unit of measurement of the coordinates
  • allows transformation of all data to a common CRS

Locations can be:

  • unprojected (geographic reference systems) use longitude and latitude
world<-map_data("world")
ggplot(world,aes(long,lat,group=group))+
  geom_polygon(fill="#e1a95f",color="grey30",size=0.3)+
  coord_map(projection = "ortho",orientation = c(10,-80,0))+
  theme_void()+
  theme(panel.grid = element_line(color="grey80"))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.

  • projected use easting and northing Cartesian coordinates
world<-map_data("world")
ggplot(world,aes(long,lat,group=group))+
  geom_polygon(fill="#e1a95f",color="grey30",size=0.3)+
  coord_sf()+
  theme_void()+
  theme(panel.grid = element_line(color="grey80"))

2.2.1 Geographic coordinate systems

Latitude and longitude are angles in decimal degrees (DD) or in degrees, minutes, and seconds (DMS).

2.2.2 Projected coordinate systems

“A map projection is a transformation of the Earth’s three-dimensional surface as a flat two-dimensional plane.”

  • Universal Transverse Mercator (UTM): divides the Earth into 60 zones of 6 degrees of longitude in width. Each of the zones uses a transverse Mercator projection that maps a region of large north-south extent.

2.2.3 Setting Coordinate Reference Systems in R

The Earth’s shape can be approximated by an oblate ellipsoid model,bulges at the equator and is flattened at the poles.

The most common reference ellipsoids in use is World Geodetic System (WGS84) which is used for example by the Global Positioning System (GPS).

Elements in the CRS proj4 attributes:

  • +init = epsg: 4326 (the Earth’s center of mass)
  • +proj = longlat/utm
  • +zone = there are 60 zones
  • +ellps = WGS84 (most common)
  • +datum = WGS84 (define the position of the ellipsoid relative to the center of the Earth, it provides the origin point and defines the direction of the coordinate axes)
  • units = m (if meters)

To check all the available CRS in R:

# View(rgdal::make_EPSG())

EPSG Geodetic Parameter Dataset (also EPSG registry) is a public registry of geodetic datums, spatial reference systems, Earth ellipsoids, coordinate transformations and related units of measurement. Originally created by European Petroleum Survey Group (EPSG).

# setting the projections
# proj4string(d) <- CRS(projection)

# create data with coordinates given by longitude and latitude
d <- data.frame(long = rnorm(100, 0, 1), 
                lat = rnorm(100, 0, 1))

coordinates(d) <- c("long", "lat")

# assign CRS WGS84 longitude/latitude
proj4string(d) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")

# reproject data from longitude/latitude to UTM zone 35 south
d_new <- spTransform(d, CRS("+proj=utm +zone=35 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +south"))
st_crs(4326)
## Coordinate Reference System:
##   User input: EPSG:4326 
##   wkt:
## GEOGCRS["WGS 84",
##     ENSEMBLE["World Geodetic System 1984 ensemble",
##         MEMBER["World Geodetic System 1984 (Transit)"],
##         MEMBER["World Geodetic System 1984 (G730)"],
##         MEMBER["World Geodetic System 1984 (G873)"],
##         MEMBER["World Geodetic System 1984 (G1150)"],
##         MEMBER["World Geodetic System 1984 (G1674)"],
##         MEMBER["World Geodetic System 1984 (G1762)"],
##         MEMBER["World Geodetic System 1984 (G2139)"],
##         ELLIPSOID["WGS 84",6378137,298.257223563,
##             LENGTHUNIT["metre",1]],
##         ENSEMBLEACCURACY[2.0]],
##     PRIMEM["Greenwich",0,
##         ANGLEUNIT["degree",0.0174532925199433]],
##     CS[ellipsoidal,2],
##         AXIS["geodetic latitude (Lat)",north,
##             ORDER[1],
##             ANGLEUNIT["degree",0.0174532925199433]],
##         AXIS["geodetic longitude (Lon)",east,
##             ORDER[2],
##             ANGLEUNIT["degree",0.0174532925199433]],
##     USAGE[
##         SCOPE["Horizontal component of 3D system."],
##         AREA["World."],
##         BBOX[-90,-180,90,180]],
##     ID["EPSG",4326]]
# add columns UTMx and UTMy
d_new$UTMx <- coordinates(d_new)[, 1]
d_new$UTMy <- coordinates(d_new)[, 2]