Skip to content

Commit

Permalink
Overcome .jp2 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
drnextgis committed Aug 31, 2018
1 parent e44056b commit 69fdb8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions telluric/georaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,11 @@ def get_window(self, window, bands=None,
:param masked: boolean, if `True` the return value will be a masked array. Default is True
:return: GeoRaster2 of tile
"""

# HACK: We have to overcome https://github.com/mapbox/rasterio/issues/1449 here
if self._filename.endswith('.jp2'):
masked = False

bands = bands or list(range(1, self.num_bands + 1))

# requested_out_shape and out_shape are different for out of bounds window
Expand Down
9 changes: 9 additions & 0 deletions tests/test_georaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,3 +742,12 @@ def test_georaster_save_emits_warning_if_uneven_mask(recwarn):
"Saving different masks per band is not supported, the union of the masked values will be performed."
in str(w.message)
)


def test_georaster_crop_jp2():
# https://github.com/mapbox/rasterio/issues/1449
raster = GeoRaster2.open("tests/data/raster/nomask.jp2")
bounds = [-6530057, -3574558, -6492196, -3639376]
roi = GeoVector(Polygon.from_bounds(*bounds), crs=WEB_MERCATOR_CRS)
cropped = raster.crop(roi)
assert(cropped.image.mask[0, -1, -1])

0 comments on commit 69fdb8e

Please sign in to comment.