Skip to content

Commit

Permalink
Allow cropping non-geos areas
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed May 23, 2023
1 parent 3fa9529 commit 4e245a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2587,11 +2587,9 @@ def get_area_slices(self, area_to_cover, shape_divisible_by=None):
return x_slice, y_slice

if not self.is_geostationary:
raise NotImplementedError("Source projection must be 'geos' if "
"source/target projections are not "
"equal.")

data_boundary = Boundary(*get_geostationary_bounding_box_in_lonlats(self))
data_boundary = self.boundary(frequency=100)
else:
data_boundary = Boundary(*get_geostationary_bounding_box_in_lonlats(self))
if area_to_cover.is_geostationary:
area_boundary = Boundary(
*get_geostationary_bounding_box_in_lonlats(area_to_cover))
Expand Down
12 changes: 12 additions & 0 deletions pyresample/test/test_geometry/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,18 @@ def test_on_flipped_geos_area(self, create_test_area):
assert slice_lines == expected_slice_lines
assert slice_cols == expected_slice_cols

def test_non_geos_can_be_cropped(self, create_test_area):
"""Test that non-geos areas can be cropped also."""
src_area = create_test_area(dict(proj="utm", zone=33),
10980, 10980,
(499980.0, 6490200.0, 609780.0, 6600000.0))
crop_area = create_test_area({'proj': 'latlong'},
100, 100,
(15.9689, 58.5284, 16.4346, 58.6995))
slice_x, slice_y = src_area.get_area_slices(crop_area)
assert slice_x == slice(5630, 8339)
assert slice_y == slice(9261, 10980)


class TestBoundary:
"""Test 'boundary' method for AreaDefinition classes."""
Expand Down

0 comments on commit 4e245a9

Please sign in to comment.