Skip to content
Prev 24203 / 29559 Next

problem with rasterToPolygons x worldclim

On Wed, 6 Apr 2016 at 23:45 Karla Shikev <karlashikev at gmail.com> wrote:

            
I see the issue, the fun argument to rasterToPolygons is masking out values
from that interval, but it's not setting them all to the same value - so
you still get individual pixel polygons unless you mask on presence in the
interval or not (as a binary):

library(raster)

r<-getData('worldclim', var='bio', res=10)$bio1

e <- extent(-140,-100, 50, 60)

xx <- crop(r,e)
## mask out pixel values first
xx <- xx > 40 & xx < 60

## 576 polygons
slice1<- rasterToPolygons(xx, fun = function(x) {x == 1})
## 1 polygon
slice2 <- rasterToPolygons(xx,  fun = function(x) {x == 1}, dissolve = TRUE)


Still it's not a very nice polygon, if I can I'll try a different way.

Cheers, Mike.
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia