Timeline for Calculating Shannon's diversity using moving window in R
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 27, 2018 at 15:53 | comment | added | whuber |
p is irrelevant to you: it's used in the code only to create simulated data.
|
|
May 27, 2018 at 15:28 | comment | added | mace | Ok, then I am wondering what values I should have for ´p´ ? Is that the amount of unique values in my NDVI image? I also tried all sort of values for radius din't really get anywhere. | |
May 27, 2018 at 11:38 | comment | added | whuber | @mace That reflects a problem in your code rather than a problem with this algorithm. Indicator functions don't care whether values are "continuous" or discrete or colors or anything else. | |
May 27, 2018 at 7:18 | comment | added | mace | I tried to run this over an NDVI image, but always get a raster with only one value or a small spot on a small part of the raster. Is there any way to make this work over a continuous raster dataset? | |
Jun 29, 2015 at 17:35 | comment | added | whuber |
I suspect your problem might have been that the example code assumes the pixel values are the same as the indexes in 1:length(p) . When that is not the case, you need to loop over the values themselves rather than over the indexes. Nothing else needs to change.
|
|
Jun 29, 2015 at 16:28 | comment | added | KevinB | I voted this response as the answer because not only did it provide an solution but was also did so in a reasonable time (for large landscapes) compared to the other answer that was provided. | |
Jun 29, 2015 at 16:15 | vote | accept | KevinB | ||
Jun 26, 2015 at 21:46 | comment | added | KevinB | thanks for the code. It appears to do exactly what I was hoping to do. One question, when I was first testing it I retained the original pixel values, which ranged from 0 to 20000 (though there were only 13 unique values in that range). When I ran it with those values the result would be 0 across the entire raster. I went back and changed the values to be in sequential order (i.e. 0-13) and the code seemed to function correctly. Why did the value of the pixel matter for the calculation? | |
Jun 23, 2015 at 21:44 | history | edited | whuber | CC BY-SA 3.0 |
added 59 characters in body
|
Jun 23, 2015 at 21:38 | history | answered | whuber | CC BY-SA 3.0 |