Transforming satellite data from one map projection to another
History | Create July 2023 | Updated August 2023
Background
Map projections try to portray the earth’s spherical surface on a flat surface. A coordinate reference system (CRS) defines how the two-dimensional, projected map relates to real places on the earth. Which map projection and CRS to use depends on the region in which you are working and the analysis you will do.
NOAA PolarWatch distributes gridded and tabular oceanographic data for polar regions.
Most of the satellite data in the PolarWatch data catalog use a projection based on a Geographic Coordinate Reference System, where the X and Y coordinates are longitude and latitude, respectively. Geographical coordinates work well in many parts of the globe, but within polar regions, features tend to be very distorted. A Polar Stereographic projection often is a better choice for polar regions. For example, the NSIDC’s Polar Stereographic Projections, which were developed to optimize mapping of sea ice, have only a 6% distortion of the grid at the poles and no distortion at 70º, a latitude close to where the marginal ice zones occur. The NOAA NSIDC Sea Ice Concentration Climate Data Record dataset, for example, is in a polar stereographic projection.
When working with satellite datasets with a mix of map projections, it is often necessary to transform all the data to a common projection.
Objective
In this tutorial, we will learn to transform dataset coordinates from one projection to another.
This tutorial demonstrates the following techniques
Downloading and saving a netCDF file from PolarWatch ERDDAP data server
Accessing satellite data and metadata in polar stereographic projection
Transforming coordinates using EPSG codes
Mapping data using the transformed coordinates
Datasets used
Sea Ice Concentration, NOAA/NSIDC Climate Data Record V4, Southern Hemisphere, Science Quality, 1978-2022, Monthly
The sea ice concentration (SIC) dataset used in this exercise is produced by NOAA NSIDC from passive microwave sensors as part of the Climate Data Record. It is a science quality dataset of monthly averages that extends from 1978-2022. SIC is reported as the fraction (0 to 1) of each grid cell that is covered by ice. The data are mapped in the Southern Polar Stereographic projection (EPSG:3031). The resolution is 25km, meaning each pixel in this data set represents a value that covers a 25km by 25km area. The dataset can be downloaded directly from the PolarWatch ERDDAP at the following link: https://polarwatch.noaa.gov/erddap/griddap/nsidcG02202v4shmday
Import packages
import cartopy.crs as ccrsimport urllib.requestimport xarray as xrimport numpy as npfrom pyproj import CRSfrom pyproj import Transformerfrom matplotlib import pyplot as plt import cmocean
## Get data from ERDDAP
# request data from polarwatch.noaa.gov erddap and save it to sic.nc fileurl =''.join(["https://polarwatch.noaa.gov/erddap/griddap/","nsidcG02202v4shmday.nc?cdr_seaice_conc_monthly","[(2022-12-01T00:00:00Z):1:(2022-12-01T00:00:00Z)]", "[(4350000.0):1:(-3950000.0)][(-3950000.0):1:(3950000.0)]" ])urllib.request.urlretrieve(url, "sic.nc")
('sic.nc', <http.client.HTTPMessage at 0x1a7e0cca0>)
# open and assign data from the file to a variable ds using xarrayds = xr.open_dataset("sic.nc")# view metadata ds
<xarray.Dataset>
Dimensions: (time: 1, ygrid: 332, xgrid: 316)
Coordinates:
* time (time) datetime64[ns] 2022-12-01
* ygrid (ygrid) float32 4.338e+06 4.312e+06 ... -3.938e+06
* xgrid (xgrid) float32 -3.938e+06 -3.912e+06 ... 3.938e+06
Data variables:
cdr_seaice_conc_monthly (time, ygrid, xgrid) float32 ...
Attributes: (12/65)
acknowledgement: This project was sup...
cdm_data_type: Grid
cdr_variable: cdr_seaice_conc_monthly
contributor_name: Walter N. Meier, Flo...
contributor_role: principal investigat...
Conventions: CF-1.6, ACDD-1.3, CO...
... ...
summary: This data set provid...
time_coverage_duration: P1M
time_coverage_end: 2022-12-01T00:00:00Z
time_coverage_resolution: P1M
time_coverage_start: 2022-12-01T00:00:00Z
title: Sea Ice Concentratio...
This project was supported in part by a grant from the NOAA Climate Data Record Program. Production of original NASA Team and Bootstrap algorithm estimates supported by the NASA Polar Distributed Active Archive Center. The sea ice concentration algorithms were developed by Donald J. Cavalieri, Josefino C. Comiso, Claire L. Parkinson, and others at the NASA Goddard Space Flight Center in Greenbelt, MD.
cdm_data_type :
Grid
cdr_variable :
cdr_seaice_conc_monthly
contributor_name :
Walter N. Meier, Florence Fetterer, Ann Windnagel, J. Scott Stewart, Trey Stafford, Matt Fisher
contributor_role :
principal investigator, author, author, software developer, software developer, software developer
PROJCS["NSIDC Sea Ice Polar Stereographic South",GEOGCS["Unspecified datum based upon the Hughes 1980 ellipsoid",DATUM["Not_specified_based_on_Hughes_1980_ellipsoid",SPHEROID["Hughes 1980",6378273,298.279411123061,AUTHORITY["EPSG","7058"]],AUTHORITY["EPSG","6054"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4054"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",-70],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","3412"],AXIS["X",UNKNOWN],AXIS["Y",UNKNOWN]]
The proj_crs_code attribute references a registered projection identifier (i.e. EPSG) when available. If the projection is not registered, non-standard then this attribute references a PolarWatch assigned internal identifier.
project :
NOAA/NSIDC passive microwave sea ice concentration climate data record
references :
Comiso, J. C., and F. Nishio. 2008. Trends in the Sea Ice Cover Using Enhanced and Compatible AMSR-E, SSM/I, and SMMR Data. Journal of Geophysical Research 113, C02S07, doi:10.1029/2007JC0043257. ; Comiso, J. C., D. Cavalieri, C. Parkinson, and P. Gloersen. 1997. Passive Microwave Algorithms for Sea Ice Concentrations: A Comparison of Two Techniques. Remote Sensing of the Environment 60(3):357-84. ; Comiso, J. C. 1984. Characteristics of Winter Sea Ice from Satellite Multispectral Microwave Observations. Journal of Geophysical Research 91(C1):975-94. ; Cavalieri, D. J., P. Gloersen, and W. J. Campbell. 1984. Determination of Sea Ice Parameters with the NIMBUS-7 SMMR. Journal of Geophysical Research 89(D4):5355-5369. ; Cavalieri, D. J., C. l. Parkinson, P. Gloersen, J. C. Comiso, and H. J. Zwally. 1999. Deriving Long-term Time Series of Sea Ice Cover from Satellite Passive-Microwave Multisensor Data Sets. Journal of Geophysical Research 104(7): 15,803-15,814. ; Comiso, J.C., R.A. Gersten, L.V. Stock, J. Turner, G.J. Perez, and K. Cho. 2017. Positive Trend in the Antarctic Sea Ice Cover and Associated Changes in Surface Temperature. J. Climate, 30, 2251–2267, https://doi.org/10.1175/JCLI-D-16-0408.1
This data set provides a passive microwave sea ice concentration climate data record (CDR) based on gridded brightness temperatures (TBs) from the Defense Meteorological Satellite Program (DMSP) series of passive microwave radiometers: the Nimbus-7 Scanning Multichannel Microwave Radiometer (SMMR), the Special Sensor Microwave Imager (SSM/I) and the Special Sensor Microwave Imager/Sounder (SSMIS). The sea ice concentration CDR is an estimate of sea ice concentration that is produced by combining concentration estimates from two algorithms developed at the NASA Goddard Space Flight Center (GSFC): the NASA Team algorithm and the Bootstrap algorithm. The individual algorithms are used to process and combine brightness temperature data at National Snow and Ice Data Center (NSIDC). This product is designed to provide a consistent time series of sea ice concentrations (the fraction, or percentage, of ocean area covered by sea ice) from November 1978 to the present which spans the coverage of several passive microwave instruments. The data are gridded on the NSIDC polar stereographic grid with 25 x 25 km grid cells, and are available in Network Common Data Format (NetCDF) file format. Each file contains a variable with the CDR concentration values as well as variables that hold the NASA Team and Bootstrap concentrations for reference. Variables containing standard deviation, quality flags, and projection information are also included. Data are available from NSIDC via FTP see https://nsidc.org/data/G02202/versions/4/. Data are also distributed via the PolarWatch ERDDAP at https://polarwatch.noaa.gov/erddap. Note that the data format available through PolarWatch is different from the NSIDC FTP NetCDF files. The PolarWatch data server stores projection information as global attributes (with the prefix grid_mapping) instead of as a variable; and the timestamp is served in different units (seconds since 1970).
time_coverage_duration :
P1M
time_coverage_end :
2022-12-01T00:00:00Z
time_coverage_resolution :
P1M
time_coverage_start :
2022-12-01T00:00:00Z
title :
Sea Ice Concentration, NOAA/NSIDC Climate Data Record V4, Southern Hemisphere, 25km, Science Quality, 1978-Present, Monthly
Inspect CRS definitions and the transformation function
When transforming from one CRS to another, it is important to inspect CRS definitions and the transformation function for proper transformation. We will transform from CRS EPSG: 3031 (NSIDC Polar Stereographic South) to EPSG: 4326 (geographic coordinate system) .
There are several ways to specify CRS as shown below. For this exercise, we will use EPSG code.
For this exercise, we will use method 1, the EPSG code.
Get the projection information from the EPSG code
Geographic
crs_4326 = CRS.from_epsg(4326)crs_4326
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
NSIDC Polar Stereographic South
crs_3031 = CRS.from_epsg(3031)crs_3031
<Projected CRS: EPSG:3031>
Name: WGS 84 / Antarctic Polar Stereographic
Axis Info [cartesian]:
- E[north]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- name: Antarctica.
- bounds: (-180.0, -90.0, 180.0, -60.0)
Coordinate Operation:
- name: Antarctic Polar Stereographic
- method: Polar Stereographic (variant B)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
Inspect CRS definitions
crs_4326 * order of axis: latitude first, and longitude in degree * bounds (-180, -90, 180, 90) global coverage
crs_3031 * order of axis: X then Y in meter * bounds (-180, -90, 180, -60)
based on the crs definitions * transformation input should be in the order of latitude and longitude * transformation input/output should be within the bounds
NOTE: if you prefer to use lon and lat (or x, y) axis order, you can set transformer parameter always_xy to True
# transformer converts lon and lat values to x, y transformer = Transformer.from_crs(crs_3031, crs_4326)# create a rectangular grid x, y = np.meshgrid(ds.xgrid, ds.ygrid)# pass x and y grid values to transformlat, lon = transformer.transform(x,y)
Add latitude and longitude values to the dataset
For adding the new coordinates to the dataset, create a tuple with its dimension and values then add to the dataset.
create a tuple (dimension, value)
add to the dataset (ds) ds.coord['name']=(dimension, value)
Because the data were in the polar stereographic projection, mapping the data onto a different projection (global map projection) below, doesn’t make the data fit well on the map.
# set the map sizeplt.figure(figsize=(13,5))# set map projection (PlateCarree(): global map projection)ax = plt.axes(projection=ccrs.PlateCarree())# plot data with new coordinatesds.cdr_seaice_conc_monthly[0][:].plot.pcolormesh('lon', 'lat', ax=ax, transform=ccrs.PlateCarree(), cmap=cmocean.cm.ice, add_colorbar=False)# add coastlines to the mapax.coastlines()
Plot data with new coordinates on a polar stereographic projection map