{"id":24384,"library":"pyresample","title":"pyresample","description":"Pyresample is a Python library for geospatial image resampling, supporting both area-to-area and swath-to-area resampling. It is part of the PyTroll ecosystem. Current version is 1.35.0, with regular releases approximately every 2-3 months.","status":"active","version":"1.35.0","language":"python","source_language":"en","source_url":"https://github.com/pytroll/pyresample","tags":["geospatial","resampling","satellite","pytroll","image processing","remote sensing"],"install":[{"cmd":"pip install pyresample","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Core dependency for array operations","package":"numpy","optional":false},{"reason":"Geodetic projections and coordinate transformations","package":"pyproj","optional":false},{"reason":"Optional but recommended for large dataset resampling","package":"dask","optional":true},{"reason":"Often used with pyresample for labeled arrays","package":"xarray","optional":true}],"imports":[{"note":"AreaDefinition is importable directly from pyresample since v1.10.0; old path still works but is deprecated.","wrong":"from pyresample.area_config import AreaDefinition","symbol":"AreaDefinition","correct":"from pyresample import AreaDefinition"},{"note":"","wrong":"","symbol":"SwathDefinition","correct":"from pyresample import SwathDefinition"},{"note":"Resampling functions are in submodules like kd_tree, bilinear, etc. Direct import from pyresample may work in some versions but is not guaranteed.","wrong":"from pyresample import resample_nearest","symbol":"resample_nearest","correct":"from pyresample.kd_tree import resample_nearest"},{"note":"","wrong":"","symbol":"load_area","correct":"from pyresample.area_config import load_area"}],"quickstart":{"code":"import numpy as np\nfrom pyresample import AreaDefinition, SwathDefinition\nfrom pyresample.kd_tree import resample_nearest\n\n# Define source swath (e.g., satellite granule)\nlon = np.array([[-10, -9], [-10, -9]])\nlat = np.array([[40, 40], [41, 41]])\nswath_def = SwathDefinition(lons=lon, lats=lat)\n\n# Define target area (regular grid)\narea_def = AreaDefinition(\n    area_id='test',\n    description='Test area',\n    proj_id='test',\n    projection='+proj=eqc +lon_0=0 +lat_0=0',\n    width=100,\n    height=100,\n    area_extent=[-20, 30, 10, 50]\n)\n\n# Source data (same shape as swath)\ndata = np.random.rand(2, 2)\n\n# Resample using nearest neighbor\nresult = resample_nearest(swath_def, data, area_def, radius_of_influence=50000)\nprint(result.shape)  # (100, 100)","lang":"python","description":"Basic swath-to-area resampling with nearest neighbor method."},"warnings":[{"fix":"Always provide `radius_of_influence` in meters.","message":"In pyresample v1.20.0, the function `resample_nearest` and others changed their `radius_of_influence` default from 5000 to None. You must specify it explicitly to avoid errors.","severity":"breaking","affected_versions":">=1.20.0"},{"fix":"Use `from pyresample import parse_area_file` instead of `load_area`.","message":"The module `pyresample.area_config` is partially deprecated. Direct usage of `load_area` and `get_area_def` from `pyresample.area_config` is being replaced by `pyresample.parse_area_file` and similar functions in `pyresample.geometry`.","severity":"deprecated","affected_versions":">=1.30.0"},{"fix":"Ensure lon/lat arrays have shape (n_scans, n_pixels) for swath data.","message":"SwathDefinition's `lons` and `lats` must be 2D arrays (even for single scan lines). Using 1D arrays will cause cryptic errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Transform your geographic extent to the projection coordinates using pyproj before defining AreaDefinition.","message":"AreaDefinition's `area_extent` expects (xmin, ymin, xmax, ymax) in the projection's coordinate system, not geographic lon/lat. Common mistake: passing lon/lat directly.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from pyresample.kd_tree import resample_nearest","cause":"Attempting to import resampling functions from the top-level pyresample module instead of the correct submodule.","error":"AttributeError: module 'pyresample' has no attribute 'resample_nearest'"},{"fix":"Include area_id='my_area' in AreaDefinition constructor.","cause":"Missing required keyword when creating AreaDefinition; area_id is mandatory.","error":"KeyError: 'area_id'"},{"fix":"Add radius_of_influence=50000 (or appropriate value) to the call.","cause":"In pyresample >=1.20.0, radius_of_influence is not set by default and must be provided.","error":"ValueError: radius_of_influence must be defined for kd_tree based resampling"},{"fix":"Use: from pyresample.area_config import load_area (still works in 1.35) but prefer: from pyresample import parse_area_file","cause":"Using deprecated import path for area functions (e.g., from pyresample.area_config import load_area) after internal refactoring.","error":"TypeError: 'NoneType' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}