Mapping Projected Datasets in R

map generated in R polar projection sea ice

1 Mapping Projected Datasets

notebook filename | projected_dataset_erddap.Rmd
history | Feb 2021, J. Sevadjian: updated links; Mar 2020, J. Sevadjian: built R notebook based on R script; Aug 2019, C. Wilson: created R script

This example demonstrates the following techniques for working with sea ice data served in polar projected coordinates:

  • Finding and previewing sea ice data in ERDDAP
  • Creating URL requests to download projected data from ERDDAP
  • Using the latitude/longitude grids associated with a projected dataset
  • Making maps of projected data with ggplot


This example works with data provided by ERDDAP with projected coordinates (polar stereographic). For an example of making projected maps of datasets provided in lat-lon coordinates see the projected maps exercise at:


The .Rmd code and html are available in the Github Repository at:


1.1 Install required packages and load libraries

# Function to check if pkgs are installed, install missing pkgs, and load
pkgTest <- function(x)
  if (!require(x,character.only = TRUE))
    if(!require(x,character.only = TRUE)) stop(x, " :Package not found")

list.of.packages <- c("ncdf4","openair","ggplot2","reshape2","scales","lubridate",
                      "cmocean","maps","mapdata","rgdal","raster","RColorBrewer", "sp")

# create list of installed packages
pkges = installed.packages()[,"Package"]
for (pk in list.of.packages) {


1.2 Find and explore the ice datasets online in ERDDAP

In this example, we will use the NSIDC Sea Ice Concentration Climate Data Record (CDR) as our demonstration projected dataset. This dataset is in a polar stereographic projection, where the coordinates are given as meters from a central point (the north pole) instead of as latitude and longitude. Corresponding latitude and longitude grids enable easily moving between projected coordinates and latitude/longitude.

Search for the NSIDC CDR sea ice datasets

Use a web browser to go to the PolarWatch ERDDAP at

In the search box type NSIDC CDR and click the Search button

A list of datasets will load, including:

  • Near-real-time data from the Northern and Southern Hemispheres
  • Science quality data from the Northern and Southern Hemispheres
  • The latitude and longitude grid for the Arctic

We will use the monthly science quality dataset for the Northern Hemisphere (ERDDAP ID = nsidcCDRiceSQnhmday) and the associated lat-lon grid dataset for the Arctic (ERDDAP ID = nsidcCDRice_nh_grid).

The dataset listing from a search for ‘NSIDC CDR’

The dataset listing from a search for ‘NSIDC CDR’

Preview the data

From the dataset listing, click on the graph link to the left of the dataset title. Using the selectors on the left you can quickly preview maps of the data for your times of interest.

You can generate a URL for a netCDF download of the data for the previewed image by setting the file type to .nc which will display a download URL which can be used in a script.