0–360 longitude to -180–180 longitude convention

Mostafa Farrag
Hydroinformatics
Published in
4 min readMay 16, 2023

360 Frequently, we come across raster (GeoTIFF/NetCDF) files that seem to be in the Latitude/Longitude projection, but their longitude values span from 0 to 360 degrees, instead of using the GIS-standard arrangement of -180 degrees to 180 degrees for longitude centered on the Prime Meridian, in this article we will use the pyramids package to convert the raster file to use the -180 to 180 longitude convention

Data sources that use 0–360 degree longitude convention

Some examples of raster files that use the 0 to 360-degree longitude convention include:

  1. NOAA Optimum Interpolation Sea Surface Temperature (OISST) dataset — this dataset provides a daily analysis of sea surface temperature on a 0.25-degree grid for the global ocean.
NOAA Daily precipitation plotted using Pyramids python package
  1. ECMWF ERA5 climate reanalysis dataset — this dataset provides a range of climate variables on a 0.25-degree grid for the global atmosphere and uses a 0 to 360 degree longitude convention.
  2. MODIS Level 3 global vegetation index (GVI) dataset — this dataset provides monthly composites of vegetation indices on a 0.05-degree grid.
  3. AVHRR Global Area Coverage (GAC) dataset — this dataset provides daily composites of sea surface temperature on a 4-km resolution grid for the global ocean.

It’s worth noting that some software and tools may be able to handle both 0 to 360 and -180 to 180 degree longitude conventions, so it’s important to check the data specifications and properties to ensure that the data is properly handled and analyzed

QGIS/ARC GIS Pro

Both QGIS and ARC GIS Pro are capable of opening rasters with longitude values ranging from 0 to 360 degrees. However, by default, they assumes that the data is in the standard latitude/longitude projection, which uses the -180 to 180 degree longitude range. Therefore, if you are working with data that uses 0 to 360 degree longitude values, you may need to adjust the projection settings in QGIS to correctly display the data.

NOAH daily precipitation raster opened in QGIS

Pyramids python package

  • The Pyramids is a Python package, that is built on top of GDAL, pyramids package uses a very similar API to Geopandas API to manipulate raster and vector data.
  • To install pyramids using conda
conda install -c conda-forge pyramids
  • or using pip
pip install pyramids-gis
  • for more details, you can check the package in GitHub.

Open the raster

  • we can now open the raster file using the read_file method from the Dataset class that represents rasters in the pyramids package.
  • After you read the raster, you can check the properties of the raster by printing the object.
properties of the NOAA precipitation raster

Lon attribute

  • By checking the max value in the lon attribute of the dataset object, you can check whether the raster has the 0–360 longitude convention.
Min and Max longitude in the raster

Plot the dataset

  • You can also plot the raster using the plot method which plots an RGB, if the raster has more than one band, and you can specify a specific band to plot.
NOAA Daily precipitation plotted using Pyramids python package

convert_longitude

  • Now use the convert_longitude to convert the longitude values to range between -180 and 180.
  • Now the longitude ranges from -180 to 180 (cell size is 0.25 degree)
new Min and Max longitude in the raster after converting the 0–360 degree to -180–180 degree.
new raster after converting the 0–360 degree to -180–180 degree.

Save the new raster

  • Now to save the converted dataset to disk, the data format of the raster will be inferred from the extension at the end of the path given to the to_file method

Check the raster with QGIS

  • Now if you open the new raster in QGIS and use any basemap to use it as a reference for the correct location
The converted raster visualized using QGIS.

So, to sum up, in this article, we have converted the 0–360 longitude projection in the NOAA raster to use the standard -180–180 longitude convention using the Pyramids python package and verified the new raster with GQIS.

You can find all the code used in this article in a Jupyter notebook here (https://github.com/Serapieum-of-alex/pyramids/blob/main/examples/notebooks/convert-longitude.ipynb)

References

--

--