pyresample icon indicating copy to clipboard operation
pyresample copied to clipboard

`__contains__`, `overlaps`, `overlap_rate`, `intersection`, `get_area` methods provide errors/wrong results for geos AreaDef / SwathDef

Open ghiggi opened this issue 3 years ago • 1 comments

Problem description

The methods __contains__, overlaps, overlap_rate, intersection, contains, get_area implemented in BaseDefinition class employs a polygon defined by the centroid of the pixel corners of the SwathDef / AreaDef to perform the geometrical computations. While this works correctly for many classical AreaDefinition, for:

  • Geostationary AreaDef all methods crash (because of Inf values at the corners) (see also #393, #268) 3https://github.com/pytroll/pyresample/issues/393
  • SwathDefinition, the corners of lats/lons arrays does not provide meaningful values in the case of ascending and descending orbits within SwathDefinition ...

Code example for GEO AreaDef

import satpy
geometry_def = satpy.resample.get_area_def("goes_east_abi_f_1km")
geometry_def.corners   # --> Illegal (lon, lat) coordinates: (inf, inf)
geometry_def.outer_boundary_corners # --> Illegal (lon, lat) coordinates: (inf, inf)
geometry_def.get_area() # --> Illegal (lon, lat) coordinates: (inf, inf)
geometry_def.overlaps(geometry_def) # --> Illegal (lon, lat) coordinates: (inf, inf)
geometry_def.overlap_rate(geometry_def) # --> Illegal (lon, lat) coordinates: (inf, inf)
geometry_def.intersection(geometry_def) # --> Illegal (lon, lat) coordinates: (inf, inf)
(10,20) in geometry_def # __contains__ method  # --> Illegal (lon, lat) coordinates: (inf, inf)

Proposed solution:

  • [ ] Definition of boundary method for SwathDefinition and AreaDefinition to retrieve AreaBoundary class
  • [ ] Definition of SphPolygon from AreaBoundary using self.polygon()
  • [ ] Enhancement of spherical.py geometrical operations
  • [ ] Upgrade of BaseDefinition methods to use self.boundary().polygon().<method>(...)

Draft PR coming in the next days ...

ghiggi avatar Jan 04 '22 13:01 ghiggi

In your "see also" you referred once to #268 and twice to #393. Was there a third issue you meant to link?

gerritholl avatar Jan 06 '22 15:01 gerritholl