pytroll / pytroll/pyresample

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

Open
#412 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
385
Forks
102
Avg merge
4d 2h
Merged PRs (30d)
9

Description

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 ...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the BaseDefinition methods listed in the issue and inspect spherical.py, then trace the proposed AreaBoundary and polygon() entry points for AreaDefinition and SwathDefinition. Done means the listed geometry methods no longer fail on geostationary AreaDef inputs or produce wrong results for the described SwathDefinition cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.