'mask' does not seem to be working as expected?
Closed this issue · 1 comments
JimShady commented
I am trying to crop and mask a raster using a polygon layer.
admin_subset <- admins[1:10,]
a <- terra::crop(rast(input_file), admin_subset)
b <- terra::mask(a, admin_subset)
Then I plot like this using {tmap}:
tm_shape(admin_subset) + tm_polygons() +
tm_shape(b) + tm_raster(col_alpha = 0.5)
In the output I see raster values which have not been masked. I was expecting all values not covered by the polygons to be NA.
packageVersion("terra")
[1] '1.7.78'
terra::gdal(lib="all")
gdal proj geos
"3.8.4" "9.3.1" "3.12.1"
Thanks.
JimShady commented
Apologies. User error!