I would like to obtain the extent of raster layer conditional on certain cell values. Consider the following example:
raster1
is a large raster object, filled with values between 1 and 1000. However, I only want to obtain the extent
for pixels with value 100. Since this subset of cells should crowd in a small region, the extent
should be rather narrow. Once I know the coordinates of that box, I can crop
this minor area.
My approach so far is to replace all values != 100 with NA
- as suggested in related questions. Considering the raster object's overall size, this step takes an enormous amount of time and invests a lot of computational capacity in regions that I would like to crop
anyways.
Does anyone know how to obtain the extent
conditional on a certain pixel value which does not require to reclassify the entire object beforehand?