pyresample.grid module

Resample image from one projection to another using nearest neighbour method.

pyresample.grid.get_image_from_linesample(row_indices, col_indices, source_image, fill_value=0)

Sample from image based on index arrays.

Parameters:
  • row_indices (numpy array) – Row indices. Dimensions must match col_indices

  • col_indices (numpy array) – Col indices. Dimensions must match row_indices

  • source_image (numpy array) – Source image

  • fill_value (int or None, optional) – Set undetermined pixels to this value. If fill_value is None a masked array is returned with undetermined pixels masked

Returns:

image_data – Resampled image

Return type:

numpy array

pyresample.grid.get_image_from_lonlats(lons, lats, source_area_def, source_image_data, fill_value=0, nprocs=1)

Sample from image based on lon lat arrays using nearest neighbour method in cartesian projection coordinates.

Parameters:
  • lons (numpy array) – Lons. Dimensions must match lats

  • lats (numpy array) – Lats. Dimensions must match lons

  • source_area_def (object) – Source definition as AreaDefinition object

  • source_image_data (numpy array) – Source image data

  • fill_value (int or None, optional) – Set undetermined pixels to this value. If fill_value is None a masked array is returned with undetermined pixels masked

  • nprocs (int, optional) – Number of processor cores to be used

Returns:

image_data – Resampled image data

Return type:

numpy array

pyresample.grid.get_linesample(lons, lats, source_area_def, nprocs=1)

Return index row and col arrays for resampling.

Parameters:
  • lons (numpy array) – Lons. Dimensions must match lats

  • lats (numpy array) – Lats. Dimensions must match lons

  • source_area_def (object) – Source definition as AreaDefinition object

  • nprocs (int, optional) – Number of processor cores to be used

Returns:

(row_indices, col_indices) – Arrays for resampling area by array indexing

Return type:

tuple of numpy arrays

pyresample.grid.get_resampled_image(target_area_def, source_area_def, source_image_data, fill_value=0, nprocs=1, segments=None)

Resample image using nearest neighbour method in cartesian projection coordinate systems.

Parameters:
  • target_area_def (object) – Target definition as AreaDefinition object

  • source_area_def (object) – Source definition as AreaDefinition object

  • source_image_data (numpy array) – Source image data

  • fill_value ({int, None} optional) – Set undetermined pixels to this value. If fill_value is None a masked array is returned with undetermined pixels masked

  • nprocs (int, optional) – Number of processor cores to be used

  • segments ({int, None} optional) – Number of segments to use when resampling. If set to None an estimate will be calculated.

Returns:

image_data – Resampled image data

Return type:

numpy array