Open jmarintur opened 6 years ago
Thanks a lot for the good bug report @jmarintur! Could you please give the output of crs.raster
for completeness?
This is it: CRS({'init': 'epsg:32718'})
Thanks @Juanlu001 !
It is expected that shapes in these cases are different (at least from code perspective). Let's see what is happening.
First case (crop first):
1 roi.envelope.get_bounds(self.crs) is called inside crop here 2 roi.envelope in original CRS epsg:3857 is not the same as bounds of the roi.envelope in epsg:32718 3 image after cropping in epsg:32718 and result image reprojected to epsg:3857, red polygon - roi.envelope:
Result image in the second case (reproject first):
If reprojecting first is not a solution you can use mask
method of GeoRaster:
buffer = GeoVector(roi.get_shape(WEB_MERCATOR_CRS).buffer(100), WEB_MERCATOR_CRS)
raster.crop(buffer).reproject(dst_crs=WEB_MERCATOR_CRS).mask(roi).save(output_raster)
Example of output:
Thanks @drnextgis! I have a couple of questions:
mask
instead of crop
as the last step?crop
parameter for mask
: raster.mask(vector, crop=True)
In the first case I perform crop and then reproject:
1)
raster.crop(roi.envelope).reproject(dst_crs=WEB_MERCATOR_CRS).save(output_raster)
In the second case I reproject and then I crop:
2)
raster.reproject(dst_crs=WEB_MERCATOR_CRS).crop(roi.envelope).save(output_raster)
The resulting images when I visualize them using Qgis 2.14.11-Essen look like this:
1)
And
2)
I am using a Sentinel-2 image Band 02 and tile T18HXB and the following roi:
Thanks for your support.