pyresample
pyresample copied to clipboard
outer_boundary_corners and __contains__ raise ValueError on some areas
Checking the outer boundary corners of some areas fails with ValueError. In this case, checking if a certain point is contained also fails.
Code Sample, a minimal, complete, and verifiable piece of code
from pyresample.area_config import parse_area_file
area = parse_area_file(
"/data/gholl/checkouts/satpy/satpy/etc/areas.yaml",
"seviri_0deg")[0]
print((0, 0) in area)
print(area.outer_boundary_corners)
Problem description
raises ValueError, probably because the Earth is round and has no corners.
Expected Output
For the outer_boundary_corners
, maybe NaN would be appropriate, or maybe a ValueError
is actually correct. However, I don't think (lon, lat) in area
should raise a ValueError
for any valid lon/lat (see also #268). For valid input, this should always return either True or False.
Actual Result, Traceback if applicable
Traceback (most recent call last):
File "/data/gholl/checkouts/protocode/mwe/outer-corners.py", line 5, in <module>
print(area.outer_boundary_corners)
File "/data/gholl/checkouts/pyresample/pyresample/geometry.py", line 2134, in outer_boundary_corners
return [Coordinate(corner_lons[0], corner_lats[0]),
File "/data/gholl/checkouts/pyresample/pyresample/spherical_geometry.py", line 50, in __init__
raise ValueError('Illegal (lon, lat) coordinates: (%s, %s)'
ValueError: Illegal (lon, lat) coordinates: (inf, inf)
Versions of Python, package at hand and relevant dependencies
pyresample v1.22.0-8-gee7c1b9
This also affects __contains__
:
from pyresample.area_config import parse_area_file
area = parse_area_file(
"/data/gholl/checkouts/satpy/satpy/etc/areas.yaml",
"seviri_0deg")[0]
print((0, 0) in area)
print(area.outer_boundary_corners)
fails already at the (0, 0) in area
line:
Traceback (most recent call last):
File "/data/gholl/checkouts/protocode/mwe/outer-corners.py", line 5, in <module>
print((0, 0) in area)
File "/data/gholl/checkouts/pyresample/pyresample/geometry.py", line 371, in __contains__
corners = self.corners
File "/data/gholl/checkouts/pyresample/pyresample/geometry.py", line 360, in corners
return [Coordinate(*self.get_lonlat(0, 0)),
File "/data/gholl/checkouts/pyresample/pyresample/spherical_geometry.py", line 50, in __init__
raise ValueError('Illegal (lon, lat) coordinates: (%s, %s)'
ValueError: Illegal (lon, lat) coordinates: (inf, inf)
See also issue #268 which is specifically about __contains__
.