satpy.resample module

Resampling in Satpy.

Satpy provides multiple resampling algorithms for resampling geolocated data to uniform projected grids. The easiest way to perform resampling in Satpy is through the Scene object’s resample() method. Additional utility functions are also available to assist in resampling data. Below is more information on resampling with Satpy as well as links to the relevant API documentation for available keyword arguments.

Resampling algorithms

Available Resampling Algorithms

Resampler

Description

Related

nearest

Nearest Neighbor

KDTreeResampler

ewa

Elliptical Weighted Averaging

DaskEWAResampler

ewa_legacy

Elliptical Weighted Averaging (Legacy)

LegacyDaskEWAResampler

native

Native

NativeResampler

bilinear

Bilinear

BilinearResampler

bucket_avg

Average Bucket Resampling

BucketAvg

bucket_sum

Sum Bucket Resampling

BucketSum

bucket_count

Count Bucket Resampling

BucketCount

bucket_fraction

Fraction Bucket Resampling

BucketFraction

gradient_search

Gradient Search Resampling

create_gradient_search_resampler()

The resampling algorithm used can be specified with the resampler keyword argument and defaults to nearest:

>>> scn = Scene(...)
>>> euro_scn = scn.resample('euro4', resampler='nearest')

Warning

Some resampling algorithms expect certain forms of data. For example, the EWA resampling expects polar-orbiting swath data and prefers if the data can be broken in to “scan lines”. See the API documentation for a specific algorithm for more information.

Resampling for comparison and composites

While all the resamplers can be used to put datasets of different resolutions on to a common area, the ‘native’ resampler is designed to match datasets to one resolution in the dataset’s original projection. This is extremely useful when generating composites between bands of different resolutions.

>>> new_scn = scn.resample(resampler='native')

By default this resamples to the highest resolution area (smallest footprint per pixel) shared between the loaded datasets. You can easily specify the lowest resolution area:

>>> new_scn = scn.resample(scn.coarsest_area(), resampler='native')

Providing an area that is neither the minimum or maximum resolution area may work, but behavior is currently undefined.

Caching for geostationary data

Satpy will do its best to reuse calculations performed to resample datasets, but it can only do this for the current processing and will lose this information when the process/script ends. Some resampling algorithms, like nearest and bilinear, can benefit by caching intermediate data on disk in the directory specified by cache_dir and using it next time. This is most beneficial with geostationary satellite data where the locations of the source data and the target pixels don’t change over time.

>>> new_scn = scn.resample('euro4', cache_dir='/path/to/cache_dir')

See the documentation for specific algorithms to see availability and limitations of caching for that algorithm.

Create custom area definition

See pyresample.geometry.AreaDefinition for information on creating areas that can be passed to the resample method:

>>> from pyresample.geometry import AreaDefinition
>>> my_area = AreaDefinition(...)
>>> local_scene = scn.resample(my_area)

Resize area definition in pixels

Sometimes you may want to create a small image with fixed size in pixels. For example, to create an image of (y, x) pixels :

>>> small_scn = scn.resample(scn.finest_area().copy(height=y, width=x), resampler="nearest")

Warning

Be aware that resizing with native resampling (resampler="native") only works if the new size is an integer factor of the original input size. For example, multiplying the size by 2 or dividing the size by 2. Multiplying by 1.5 would not be allowed.

Create dynamic area definition

See pyresample.geometry.DynamicAreaDefinition for more information.

Examples coming soon…

Store area definitions

Area definitions can be saved to a custom YAML file (see pyresample’s writing to disk) and loaded using pyresample’s utility methods (pyresample’s loading from disk):

>>> from pyresample import load_area
>>> my_area = load_area('my_areas.yaml', 'my_area')

Or using satpy.resample.get_area_def(), which will search through all areas.yaml files in your SATPY_CONFIG_PATH:

>>> from satpy.resample import get_area_def
>>> area_eurol = get_area_def("eurol")

For examples of area definitions, see the file etc/areas.yaml that is included with Satpy and where all the area definitions shipped with Satpy are defined. The section below gives an overview of these area definitions.

Area definitions included in Satpy

Area Definitions

Name

Description

Projection

msg_seviri_fes_3km

MSG SEVIRI Full Earth Scanning service area definition with 3 km resolution

geos

msg_seviri_fes_1km

MSG SEVIRI Full Earth Scanning service area definition with 1 km resolution

geos

msg_seviri_rss_3km

MSG SEVIRI Rapid Scanning Service area definition with 3 km resolution

geos

msg_seviri_rss_1km

MSG SEVIRI Rapid Scanning Service area definition with 1 km resolution

geos

msg_seviri_iodc_3km

MSG SEVIRI Indian Ocean Data Coverage service area definition with 3 km resolution

geos

msg_seviri_iodc_1km

MSG SEVIRI Indian Ocean Data Coverage service area definition with 1 km resolution

geos

msg_seviri_fes_9km

MSG SEVIRI Full Earth Scanning service area definition with 9 km resolution

geos

msg_seviri_rss_9km

MSG SEVIRI Rapid Scanning Service area definition with 9 km resolution

geos

msg_seviri_iodc_9km

MSG SEVIRI Indian Ocean Data Coverage service area definition with 9 km resolution

geos

msg_seviri_fes_9km_ext

MSG SEVIRI Full Earth Scanning service area definition with 9 km resolution (extended outside original 3km grid)

geos

msg_seviri_rss_9km_ext

MSG SEVIRI Rapid Scanning Service area definition with 9 km resolution (extended outside original 3km grid)

geos

msg_seviri_iodc_9km_ext

MSG SEVIRI Indian Ocean Data Coverage service area definition with 9 km resolution (extended outside original 3km grid)

geos

msg_seviri_fes_48km

MSG SEVIRI Full Earth Scanning service area definition with 48 km resolution

geos

msg_seviri_rss_48km

MSG SEVIRI Rapid Scanning Service area definition with 48 km resolution

geos

msg_seviri_iodc_48km

MSG SEVIRI Indian Ocean Data Coverage service area definition with 48 km resolution

geos

himawari_ahi_fes_500m

Himawari-8/9 full disk area definition at 500m resolution

geos

himawari_ahi_fes_1km

Himawari-8/9 full disk area definition at 1km resolution

geos

himawari_ahi_fes_2km

Himawari-8/9 full disk area definition at 2km resolution

geos

EuropeCanary

Northern disk MSG image 0 degrees

geos

EastEurope

Eastern part of Northern disk MSG image 0 degrees

geos

AfHorn_geos

Eastern disk MSG image 0 degrees

geos

SouthAmerica_geos

Lower West part of Southern disk MSG image 0 degrees

geos

mtg_fci_fdss_500m

MTG FCI Full Disk Scanning Service area definition with 500 m SSP resolution

geos

mtg_fci_fdss_1km

MTG FCI Full Disk Scanning Service area definition with 1 km SSP resolution

geos

mtg_fci_fdss_2km

MTG FCI Full Disk Scanning Service area definition with 2 km SSP resolution

geos

mtg_fci_fdss_4km

MTG FCI Full Disk Scanning Service area definition with 4 km SSP resolution

geos

mtg_fci_fdss_6km

MTG FCI Full Disk Scanning Service area definition with 6 km SSP resolution

geos

mtg_fci_fdss_32km

MTG FCI Full Disk Scanning Service area definition with 32 km SSP resolution

geos

goes_east_abi_f_500m

GOES East ABI Full Disk at 500 m SSP resolution

geos

goes_east_abi_f_1km

GOES East ABI Full Disk at 1 km SSP resolution

geos

goes_east_abi_f_2km

GOES East ABI Full Disk at 2 km SSP resolution

geos

goes_west_abi_f_500m

GOES West ABI Full Disk at 500 m SSP resolution

geos

goes_west_abi_f_1km

GOES West ABI Full Disk at 1 km SSP resolution

geos

goes_west_abi_f_2km

GOES West ABI Full Disk at 2 km SSP resolution

geos

goes_east_abi_c_500m

GOES East ABI CONUS at 500 m SSP resolution

geos

goes_east_abi_c_1km

GOES East ABI CONUS at 1 km SSP resolution

geos

goes_east_abi_c_2km

GOES East ABI CONUS at 2 km SSP resolution

geos

goes_west_abi_p_500m

GOES West ABI PACUS at 500 m resolution

geos

goes_west_abi_p_1km

GOES West ABI PACUS at 1 km SSP resolution

geos

goes_west_abi_p_2km

GOES West ABI PACUS at 2 km resolution

geos

australia

australia

merc

mali

mali

merc

mali_eqc

mali

eqc

sve

Sweden and baltic sea

utm

brazil2

brazil, platecarree

eqc

sudeste

sudeste, platecarree

eqc

SouthAmerica_flat

South America flat

eqc

south_america

south_america, platecarree

eqc

brazil

brazil, platecarree

eqc

worldeqc3km70

World in 3km, platecarree

eqc

worldeqc30km70

World in 3km, platecarree

eqc

worldeqc3km73

World in 3km, platecarree

eqc

worldeqc3km

World in 3km, platecarree

eqc

worldeqc30km

World in 3km, platecarree

eqc

libya

libya area

merc

phil

kuwait area

merc

phil_small

kuwait area

merc

kuwait

kuwait area

merc

afghanistan

Afghanistan

merc

maspalomas

Western Africa and Canary Islands

merc

afhorn_merc

Africa horn 3km resolution

merc

spain

Spain

stere

germ

Germany

stere

germ2

Germany

stere

euro4

Euro 4km area - Europe

stere

euro1

Euro 4km area - Europe

stere

scan

Scandinavia

stere

scan2

Scandinavia - 2km area

stere

scan1

Scandinavia - 1km area

stere

scan500m

Scandinavia - 500m area

stere

mesanX

Mesan-X rotated lon/lat 1.8km

ob_tran

mesanE

Europe Mesan rotated lon/lat 1.8km

ob_tran

baws

BAWS

aea

eurotv

Europe TV - 6.2x5.0km

stere

eurotv4n

Europe TV4 - 4.1x4.1km

stere

eurol

Euro 3.0km area - Europe

stere

eurol1

Euro 3.0km area - Europe

stere

scanl

Scandinavia - Large

stere

euron1

Northern Europe - 1km

stere

euron0250

Northern Europe - 1km

stere

nsea

North Baltic Sea

merc

ssea

South Baltic Sea

merc

nsea250

North Baltic Sea

merc

ssea250

South Baltic Sea

merc

bsea250

South Baltic Sea

merc

test250

South Baltic Sea

merc

bsea1000

South Baltic Sea

merc

euro

Euro area - Europe

stere

baltrad_lambert

Baltrad Lambert

laea

eport

eport

stere

eport1

eport

stere

eport10

eport reduced resolution

stere

eport4

eport reduced resolution

stere

eport2

eport reduced resolution

stere

npp_sample_m

North America - NPP sample data - M-bands

laea

arctic_europe_1km

Arctic and Europe

laea

arctic_europe_9km

Arctic and Europe

laea

sswe

Southern Sweden

stere

nswe

Northern Sweden

stere

sval

Svalbard

stere

ease_sh

Antarctic EASE grid

laea

ease_nh

Arctic EASE grid

laea

barents_sea

Barents and Greenland seas

stere

antarctica

Antarctica - 1km

laea

arctica

arctica - 1km

laea

euroasia

Euroasia - Global 1km USGS Landuse database

laea

euroasia_10km

Euroasia - Global 1km USGS Landuse database

laea

euroasia_asia

Euroasia - optimised for Asia - Global 1km USGS Landuse database

laea

euroasia_asia_10km

Euroasia - optimised for Asia - Global 1km USGS Landuse database

laea

australia_pacific

Austalia/Pacific - Global 1km USGS Landuse database

laea

australia_pacific_10km

Austalia/Pacific - Global 1km USGS Landuse database

laea

africa

Africa - Global 1km USGS Landuse database

laea

africa_10km

Africa - Global 1km USGS Landuse database

laea

southamerica_laea

South America - Global 1km USGS Landuse database

laea

southamerica_10km

South America - Global 1km USGS Landuse database

laea

northamerica

North America - Global 1km USGS Landuse database

laea

northamerica_10km

North America - Global 1km USGS Landuse database

laea

romania

Romania - 3km

stere

stere_asia_test

stere

stere

bocheng_test

stere

stere

nsper_swe

nsper_swe

nsper

new_bsea250

new_bsea250

stere

scanice

Scandinavia and Iceland

laea

baws250

BAWS, 250m resolution

aea

moll

moll

moll

robinson

robinson

robin

met07globe

Full disk IODC image 57 degrees

geos

met09globe

Cropped disk MSG image 0 degrees

geos

met09globeFull

Full disk MSG image 0 degrees

geos

seviri_0deg

Full disk MSG image 0 degrees

geos

seviri_iodc

Full disk MSG image 41.5 degrees

geos

msg_resample_area

Full disk MSG image 20.75 degrees

geos

EPSG_4326_36000x18000

Global equal latitude/longitude grid at 0.01 degree resolution

longlat

EPSG_4326_7200x3600

Global equal latitude/longitude grid at 0.05 degree resolution

longlat

EPSG_4326_3600x1800

Global equal latitude/longitude grid at 0.1 degree resolution

longlat

EPSG_4326_1440x720

Global equal latitude/longitude grid at 0.25 degree resolution

longlat

EPSG_4326_720x360

Global equal latitude/longitude grid at 0.5 degree resolution

longlat

EPSG_4326_360x180

Global equal latitude/longitude grid at 1 degree resolution

longlat