Open gerritholl opened 4 years ago
Are the input coordinates (the ones passed to contains) meant to be X/Y or lon/lat?
Side note: I didn't know this existed.
It's supposed to be (lon, lat)
. From https://pyresample.readthedocs.io/en/latest/geo_def.html:
It can be tested if a (lon, lat) point is inside a GeometryDefinition
>>> print((0, -90) in area_def) True
It's missing from the API documentation though, perhaps due to special methods such as __contains__
being excluded in the sphinx configuration?
Although that doc applies to GeometryDefinition
, I assume that AreaDefinition
uses the same units (the docstring for AreaDefinition.__contains__
doesn't say).
Is this full disk ABI data?
I have a feeling a check needs to be added to see if the corners are valid lon/lats:
The AreaDefinition
is a subclass of BaseDefinition
where these methods are defined.
Yes, it's full disk ABI, but I also encountered the problem with less-than-full-disk areas, probably whenever not all corners are valid lat/lons.
probably whenever not all corners are valid lat/lons.
Exactly
Code Sample, a minimal, complete, and verifiable piece of code
Problem description
The code fails with a
ValueError: Illegal (lon, lat) coordinates: (inf, inf)
, thrown by pyresample'sspherical_geometry
module. This happens both when the coordinates are inside or outside the area.Expected Output
I would expect the output to be either
True
orFalse
depending on to whether the coordinates(0, 40)
are within the area, in other words, visible by ABI. I can still achieve this by attemptingarea.get_xy_from_lonlat(...)
and catching the possibly resultingValueError
, as follows:I would expect an OverflowError or ValueError if lat/lon passed are out of valid range, a ValueError if they are nan, and a TypeError if they are not numbers.
Actual Result, Traceback if applicable
Versions of Python, package at hand and relevant dependencies
Python 3.8.2, pyresample 1.15.0.