6.5 Modifying map projections

Established CRSs captured by EPSG codes are well-suited for many applications.However in some cases it is desirable to create a new CRS, using a custom proj4string.This system allows a very wide range of projections to be created, as we’ll see in some of the custom map projections in this section.

A long and growing list of projections has been developed and many of these these can be set with the +proj= element of proj4strings.28When mapping the world while preserving area relationships, the Mollweide projection is a good choice (Jenny et al. 2017) (Figure 6.2).To use this projection, we need to specify it using the proj4string element, "+proj=moll", in the st_transform function:

  1. world_mollweide = st_transform(world, crs = "+proj=moll")

Mollweide projection of the world.
Figure 6.2: Mollweide projection of the world.

On the other hand, when mapping the world, it is often desirable to have as little distortion as possible for all spatial properties (area, direction, distance).One of the most popular projections to achieve this is the Winkel tripel projection (Figure 6.3).29st_transform_proj() from the lwgeom package which allows for coordinate transformations to a wide range of CRSs, including the Winkel tripel projection:

  1. world_wintri = lwgeom::st_transform_proj(world, crs = "+proj=wintri")

Winkel tripel projection of the world.
Figure 6.3: Winkel tripel projection of the world.

The three main functions for transformation of simple features coordinates are sf::st_transform(), sf::sf_project(), and lwgeom::st_transform_proj().The st_transform function uses the GDAL interface to PROJ, while sf_project() (which works with two-column numeric matrices, representing points) and lwgeom::st_transform_proj() use the PROJ API directly.The first one is appropriate for most situations, and provides a set of the most often used parameters and well-defined transformations.The next one allows for greater customization of a projection, which includes cases when some of the PROJ parameters (e.g., +over) or projection (+proj=wintri) is not available in st_transform().

Moreover, PROJ parameters can be modified in most CRS definitions.The below code transforms the coordinates to the Lambert azimuthal equal-area projection centered on longitude and latitude of 0 (Figure 6.4).

  1. world_laea1 = st_transform(world,
  2. crs = "+proj=laea +x_0=0 +y_0=0 +lon_0=0 +lat_0=0")

Lambert azimuthal equal-area projection of the world centered on longitude and latitude of 0.
Figure 6.4: Lambert azimuthal equal-area projection of the world centered on longitude and latitude of 0.

We can change the PROJ parameters, for example the center of the projection, using the +lon_0 and +lat_0 parameters.The code below gives the map centered on New York City (Figure 6.5).

  1. world_laea2 = st_transform(world,
  2. crs = "+proj=laea +x_0=0 +y_0=0 +lon_0=-74 +lat_0=40")

Lambert azimuthal equal-area projection of the world centered on New York City.
Figure 6.5: Lambert azimuthal equal-area projection of the world centered on New York City.

More information on CRS modifications can be found in the Using PROJ documentation.