More about areas and pyresample

Summary

In this tutorial, we will learn more about defining areas to work with in pytroll/satpy, and how to save them for later use.

Defining Area Definitions

The areas in pytroll/satpy are defined through the pyresample package.

To define an area, have a look at the pyresample documentation: https://pyresample.readthedocs.io/en/latest/geo_def.html

In this tutorial, we will create an area definition that covers Sweden, following the official SWEREF99TM.

The projection to use is transverse mercator, with the following parameter:

  • reference longitude is 15
  • scale factor is 0.9996

Sweden is included in a lon/lat box spanning approximately 10 to 25 degrees east and 55 to 70 degrees north. (If you're curious, look here: https://en.wikipedia.org/wiki/Geography_of_Sweden#Latitude_and_longitude)

Exercise 4.1

Use pyproj to determine the area extent in projection coordinate of the bounding box.

Pyproj documentation: https://jswhit.github.io/pyproj/

The transverse mercator projection parameters https://proj4.org/operations/projections/tmerc.html

Exercise 4.2

Create a pyresample AreaDefinition object using your computed parameters, with a resolution of ~1km

Exercise 4.3

Resample your metop data on your newly defined area definition.

Saving the area

The area definitions can be saved in yaml format. An areas.yaml file is provided in the satpy installation (https://github.com/pytroll/satpy/blob/feature-areas-yaml/satpy/etc/areas.yaml), but for areas you want to save, it is best to have an areas.yaml file in your working directory that will complete or replace the standard one. Alternatively, you can place your areas file in a directory pointed to by the PPP_CONFIG_DIR environment variable. To export the area you created, use the area's create_areas_def method.

Exercise 4.4

Save the area you just defined into your own areas.yaml file. Resample your metop data using the saved area definition, ie by refering to it by name in the scn.resample call.

In [ ]: