I am working with a raster map vegetation types. I have about 20 types with unique raster code values that can be sorted into three classes:
As inputs to the Nibble, I reclassified my veg layer so that the type 2 (static) values were nodata, since I didn't want them to nibble. That was my input layer. For the input MASK, I reclassified the original raster but made the type 3 values nodata, since they are the ones I want to eliminate through nibbling.
The catch is that I tend to have large amounts of type 3 clustered together, and on top of that there are several places where the type 2 and type 3 values are clustered near each other. The upshot is that the nibble gave me an incomplete output. It ran correctly, as far as I could tell, but it would stop before nibbling away all of the masked values.
I think the problem is that the nibble function has some predetermined search radius for the nearest neighbor, and if a cell is surrounded by type 2 and 3 cells then it can be so far away from a type 1 cell that the nibble doesn't reach it. However, looking into the tools, the whole Nibble tool is just one function that is called with those two inputs, so I can't modify the python code to change the search radius. I am not skilled enough in python to write a loop that would run the nibble over and over again.
So, is there a way to get the Nibble to fill in more of the masked values at a time? Is there a place I can get the Nibble code to try and modify it? I would imagine at some point a distance threshold was specified.
Thanks in advance! I hope my explanation was clear!
Edit: More information on the data I am using
+-------------+-------------------+--+-------------+--------+-------------+--------+-------------+---------+ | Name | Integer in Raster | | Static | Value | Dissolve | Value | Nibblers | Value | +-------------+-------------------+--+-------------+--------+-------------+--------+-------------+---------+ | SMCM | 0 | | URB | 4 | MCH | 3 | SMCM | 0 | | OCFW | 1 | | BAR | 8 | GRASS | 7 | OCFW | 1 | | SMCX | 2 | | WAT | 9 | MCP | 10 | SMCX | 2 | | MCH | 3 | | AGR | 11 | ADS | 19 | MHW | 5 | | URB | 4 | | MRIP | 12 | ASPE | 23 | BLU | 6 | | MHW | 5 | | MED | 13 | ASPW | 24 | DFTO | 14 | | BLU | 6 | | Pixel Count | 322591 | Pixel Count | 333625 | RF | 15 | | GRASS | 7 | | | | | | LPN | 16 | | BAR | 8 | | | | | | SCN | 17 | | WAT | 9 | | | | | | WWP | 18 | | MCP | 10 | | | | | | YPN | 20 | | AGR | 11 | | | | | | SAGE | 21 | | MRIP | 12 | | | | | | CMM | 22 | | MED | 13 | | | | | | LSG | 25 | | DFTO | 14 | | | | | | Pixel Count | 3744816 | | RF | 15 | | | | | | | | | LPN | 16 | | | | | | | | | SCN | 17 | | | | | | | | | WWP | 18 | | | | | | | | | ADS | 19 | | | | | | | | | YPN | 20 | | | | | | | | | SAGE | 21 | | | | | | | | | CMM | 22 | | | | | | | | | ASPE | 23 | | | | | | | | | ASPW | 24 | | | | | | | | | LSG | 25 | | | | | | | | | Pixel Count | 4401032 | | | | | | | | +-------------+-------------------+--+-------------+--------+-------------+--------+-------------+---------+ I tried the first answer below and it works, but doesn't necessarily solve the problem. Some of my patches of veg that need to be dissolved are pretty large. Therefore, I need an enormous neighborhood to eliminate the whole thing. Given this, it would seem I'm looking at using the raster calculator in an iterative way as well. So, now my question becomes, which is better, and if both, in what order?
For example, I could Nibble for a few iterations, then switch to the raster calculator and iterate that over some reasonable-sized neighborhood (not sure how big that would be - 10x10? 50x50) until I eliminated all the type 3 pixels. Or I could do things in the opposite way. Raster Calculator is a little faster, but does it do a better job with respect to landcover assessment if there is a large neighborhood?
أكثر...
- vegetation types I want to expand using the nibble function (e.g. forest)
- vegetation types I consider static that I do not want to either nibble or be nibbled (e.g. water, developed areas)
- vegetation types that I want to eliminate through the nibble function (early seral stages, such as grass and chaparral)
As inputs to the Nibble, I reclassified my veg layer so that the type 2 (static) values were nodata, since I didn't want them to nibble. That was my input layer. For the input MASK, I reclassified the original raster but made the type 3 values nodata, since they are the ones I want to eliminate through nibbling.
The catch is that I tend to have large amounts of type 3 clustered together, and on top of that there are several places where the type 2 and type 3 values are clustered near each other. The upshot is that the nibble gave me an incomplete output. It ran correctly, as far as I could tell, but it would stop before nibbling away all of the masked values.
I think the problem is that the nibble function has some predetermined search radius for the nearest neighbor, and if a cell is surrounded by type 2 and 3 cells then it can be so far away from a type 1 cell that the nibble doesn't reach it. However, looking into the tools, the whole Nibble tool is just one function that is called with those two inputs, so I can't modify the python code to change the search radius. I am not skilled enough in python to write a loop that would run the nibble over and over again.
So, is there a way to get the Nibble to fill in more of the masked values at a time? Is there a place I can get the Nibble code to try and modify it? I would imagine at some point a distance threshold was specified.
Thanks in advance! I hope my explanation was clear!
Edit: More information on the data I am using
+-------------+-------------------+--+-------------+--------+-------------+--------+-------------+---------+ | Name | Integer in Raster | | Static | Value | Dissolve | Value | Nibblers | Value | +-------------+-------------------+--+-------------+--------+-------------+--------+-------------+---------+ | SMCM | 0 | | URB | 4 | MCH | 3 | SMCM | 0 | | OCFW | 1 | | BAR | 8 | GRASS | 7 | OCFW | 1 | | SMCX | 2 | | WAT | 9 | MCP | 10 | SMCX | 2 | | MCH | 3 | | AGR | 11 | ADS | 19 | MHW | 5 | | URB | 4 | | MRIP | 12 | ASPE | 23 | BLU | 6 | | MHW | 5 | | MED | 13 | ASPW | 24 | DFTO | 14 | | BLU | 6 | | Pixel Count | 322591 | Pixel Count | 333625 | RF | 15 | | GRASS | 7 | | | | | | LPN | 16 | | BAR | 8 | | | | | | SCN | 17 | | WAT | 9 | | | | | | WWP | 18 | | MCP | 10 | | | | | | YPN | 20 | | AGR | 11 | | | | | | SAGE | 21 | | MRIP | 12 | | | | | | CMM | 22 | | MED | 13 | | | | | | LSG | 25 | | DFTO | 14 | | | | | | Pixel Count | 3744816 | | RF | 15 | | | | | | | | | LPN | 16 | | | | | | | | | SCN | 17 | | | | | | | | | WWP | 18 | | | | | | | | | ADS | 19 | | | | | | | | | YPN | 20 | | | | | | | | | SAGE | 21 | | | | | | | | | CMM | 22 | | | | | | | | | ASPE | 23 | | | | | | | | | ASPW | 24 | | | | | | | | | LSG | 25 | | | | | | | | | Pixel Count | 4401032 | | | | | | | | +-------------+-------------------+--+-------------+--------+-------------+--------+-------------+---------+ I tried the first answer below and it works, but doesn't necessarily solve the problem. Some of my patches of veg that need to be dissolved are pretty large. Therefore, I need an enormous neighborhood to eliminate the whole thing. Given this, it would seem I'm looking at using the raster calculator in an iterative way as well. So, now my question becomes, which is better, and if both, in what order?
For example, I could Nibble for a few iterations, then switch to the raster calculator and iterate that over some reasonable-sized neighborhood (not sure how big that would be - 10x10? 50x50) until I eliminated all the type 3 pixels. Or I could do things in the opposite way. Raster Calculator is a little faster, but does it do a better job with respect to landcover assessment if there is a large neighborhood?
أكثر...