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
Resampler |
Description |
Related |
---|---|---|
nearest |
Nearest Neighbor |
|
ewa |
Elliptical Weighted Averaging |
|
ewa_legacy |
Elliptical Weighted Averaging (Legacy) |
|
native |
Native |
|
bilinear |
Bilinear |
|
bucket_avg |
Average Bucket Resampling |
|
bucket_sum |
Sum Bucket Resampling |
|
bucket_count |
Count Bucket Resampling |
|
bucket_fraction |
Fraction Bucket Resampling |
|
gradient_search |
Gradient Search Resampling |
|
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
Name |
Description |
Projection |
---|---|---|
MSG SEVIRI Full Earth Scanning service area definition with 3 km resolution |
geos |
|
MSG SEVIRI Full Earth Scanning service area definition with 1 km resolution |
geos |
|
MSG SEVIRI Rapid Scanning Service area definition with 3 km resolution |
geos |
|
MSG SEVIRI Rapid Scanning Service area definition with 1 km resolution |
geos |
|
MSG SEVIRI Indian Ocean Data Coverage service area definition with 3 km resolution |
geos |
|
MSG SEVIRI Indian Ocean Data Coverage service area definition with 1 km resolution |
geos |
|
MSG SEVIRI Full Earth Scanning service area definition with 9 km resolution |
geos |
|
MSG SEVIRI Rapid Scanning Service area definition with 9 km resolution |
geos |
|
MSG SEVIRI Indian Ocean Data Coverage service area definition with 9 km resolution |
geos |
|
MSG SEVIRI Full Earth Scanning service area definition with 9 km resolution (extended outside original 3km grid) |
geos |
|
MSG SEVIRI Rapid Scanning Service area definition with 9 km resolution (extended outside original 3km grid) |
geos |
|
MSG SEVIRI Indian Ocean Data Coverage service area definition with 9 km resolution (extended outside original 3km grid) |
geos |
|
MSG SEVIRI Full Earth Scanning service area definition with 48 km resolution |
geos |
|
MSG SEVIRI Rapid Scanning Service area definition with 48 km resolution |
geos |
|
MSG SEVIRI Indian Ocean Data Coverage service area definition with 48 km resolution |
geos |
|
Himawari-8/9 full disk area definition at 500m resolution |
geos |
|
Himawari-8/9 full disk area definition at 1km resolution |
geos |
|
Himawari-8/9 full disk area definition at 2km resolution |
geos |
|
Northern disk MSG image 0 degrees |
geos |
|
Eastern part of Northern disk MSG image 0 degrees |
geos |
|
Eastern disk MSG image 0 degrees |
geos |
|
Lower West part of Southern disk MSG image 0 degrees |
geos |
|
MTG FCI Full Disk Scanning Service area definition with 500 m SSP resolution |
geos |
|
MTG FCI Full Disk Scanning Service area definition with 1 km SSP resolution |
geos |
|
MTG FCI Full Disk Scanning Service area definition with 2 km SSP resolution |
geos |
|
MTG FCI Full Disk Scanning Service area definition with 4 km SSP resolution |
geos |
|
MTG FCI Full Disk Scanning Service area definition with 6 km SSP resolution |
geos |
|
MTG FCI Full Disk Scanning Service area definition with 32 km SSP resolution |
geos |
|
GOES East ABI Full Disk at 500 m SSP resolution |
geos |
|
GOES East ABI Full Disk at 1 km SSP resolution |
geos |
|
GOES East ABI Full Disk at 2 km SSP resolution |
geos |
|
GOES West ABI Full Disk at 500 m SSP resolution |
geos |
|
GOES West ABI Full Disk at 1 km SSP resolution |
geos |
|
GOES West ABI Full Disk at 2 km SSP resolution |
geos |
|
GOES East ABI CONUS at 500 m SSP resolution |
geos |
|
GOES East ABI CONUS at 1 km SSP resolution |
geos |
|
GOES East ABI CONUS at 2 km SSP resolution |
geos |
|
GOES West ABI PACUS at 500 m resolution |
geos |
|
GOES West ABI PACUS at 1 km SSP resolution |
geos |
|
GOES West ABI PACUS at 2 km resolution |
geos |
|
australia |
merc |
|
mali |
merc |
|
mali |
eqc |
|
Sweden and baltic sea |
utm |
|
brazil, platecarree |
eqc |
|
sudeste, platecarree |
eqc |
|
South America flat |
eqc |
|
south_america, platecarree |
eqc |
|
brazil, platecarree |
eqc |
|
World in 3km, platecarree |
eqc |
|
World in 3km, platecarree |
eqc |
|
World in 3km, platecarree |
eqc |
|
World in 3km, platecarree |
eqc |
|
World in 3km, platecarree |
eqc |
|
libya area |
merc |
|
kuwait area |
merc |
|
kuwait area |
merc |
|
kuwait area |
merc |
|
Afghanistan |
merc |
|
Western Africa and Canary Islands |
merc |
|
Africa horn 3km resolution |
merc |
|
Spain |
stere |
|
Germany |
stere |
|
Germany |
stere |
|
Euro 4km area - Europe |
stere |
|
Euro 4km area - Europe |
stere |
|
Scandinavia |
stere |
|
Scandinavia - 2km area |
stere |
|
Scandinavia - 1km area |
stere |
|
Scandinavia - 500m area |
stere |
|
Mesan-X rotated lon/lat 1.8km |
ob_tran |
|
Europe Mesan rotated lon/lat 1.8km |
ob_tran |
|
BAWS |
aea |
|
Europe TV - 6.2x5.0km |
stere |
|
Europe TV4 - 4.1x4.1km |
stere |
|
Euro 3.0km area - Europe |
stere |
|
Euro 3.0km area - Europe |
stere |
|
Scandinavia - Large |
stere |
|
Northern Europe - 1km |
stere |
|
Northern Europe - 1km |
stere |
|
North Baltic Sea |
merc |
|
South Baltic Sea |
merc |
|
North Baltic Sea |
merc |
|
South Baltic Sea |
merc |
|
South Baltic Sea |
merc |
|
South Baltic Sea |
merc |
|
South Baltic Sea |
merc |
|
Euro area - Europe |
stere |
|
Baltrad Lambert |
laea |
|
eport |
stere |
|
eport |
stere |
|
eport reduced resolution |
stere |
|
eport reduced resolution |
stere |
|
eport reduced resolution |
stere |
|
North America - NPP sample data - M-bands |
laea |
|
Arctic and Europe |
laea |
|
Arctic and Europe |
laea |
|
Southern Sweden |
stere |
|
Northern Sweden |
stere |
|
Svalbard |
stere |
|
Antarctic EASE grid |
laea |
|
Arctic EASE grid |
laea |
|
Barents and Greenland seas |
stere |
|
Antarctica - 1km |
laea |
|
arctica - 1km |
laea |
|
Euroasia - Global 1km USGS Landuse database |
laea |
|
Euroasia - Global 1km USGS Landuse database |
laea |
|
Euroasia - optimised for Asia - Global 1km USGS Landuse database |
laea |
|
Euroasia - optimised for Asia - Global 1km USGS Landuse database |
laea |
|
Austalia/Pacific - Global 1km USGS Landuse database |
laea |
|
Austalia/Pacific - Global 1km USGS Landuse database |
laea |
|
Africa - Global 1km USGS Landuse database |
laea |
|
Africa - Global 1km USGS Landuse database |
laea |
|
South America - Global 1km USGS Landuse database |
laea |
|
South America - Global 1km USGS Landuse database |
laea |
|
North America - Global 1km USGS Landuse database |
laea |
|
North America - Global 1km USGS Landuse database |
laea |
|
Romania - 3km |
stere |
|
stere |
stere |
|
stere |
stere |
|
nsper_swe |
nsper |
|
new_bsea250 |
stere |
|
Scandinavia and Iceland |
laea |
|
BAWS, 250m resolution |
aea |
|
moll |
moll |
|
robinson |
robin |
|
Full disk IODC image 57 degrees |
geos |
|
Cropped disk MSG image 0 degrees |
geos |
|
Full disk MSG image 0 degrees |
geos |
|
Full disk MSG image 0 degrees |
geos |
|
Full disk MSG image 41.5 degrees |
geos |
|
Full disk MSG image 20.75 degrees |
geos |
|
Global equal latitude/longitude grid at 0.01 degree resolution |
longlat |
|
Global equal latitude/longitude grid at 0.05 degree resolution |
longlat |
|
Global equal latitude/longitude grid at 0.1 degree resolution |
longlat |
|
Global equal latitude/longitude grid at 0.25 degree resolution |
longlat |
|
Global equal latitude/longitude grid at 0.5 degree resolution |
longlat |
|
Global equal latitude/longitude grid at 1 degree resolution |
longlat |