I'm using rasterio.mask.mask to mask a raster with a shapefile.
import rasterio
import fiona
image_object = rasterio.open('/home/cate/image_name.img')
aoi_shapefile = fiona.open('/home/cate/AOI.shp', "r")
aoi = [polygon["geometry"] for polygon in aoi_shapefile]
image_aoi, image_aoi_transform = rasterio.mask.mask(image_object, aoi)
and I get UserWarning: shapes are outside bounds of raster. Are they in different coordinate reference systems?
As far as I can tell the shape is definitely within the raster bounds..
image_object.bounds
BoundingBox(left=117.4095061135422, bottom=33.73209332058161, right=120.49755473423146, top=35.64128279392083)
aoi_shapefile.bounds
(119.82677788035676, 34.076577156414714, 120.37042708436398, 34.575927115244426)
image_object.crs
CRS({'init': 'epsg:4326'})
aoi_shapefile.crs
{'init': 'epsg:4326'}
I'm using rasterio 1.0a10 – any ideas what is happening here?
Best Answer
Cate, this is a rasterio bug that is fixed in version 1.0a12 (on PyPI now).
pip install --pre -U rasterio