Change in rasterToPolygons() behaviour

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Change in rasterToPolygons() behaviour

Agustin Lobo
Recycling an old script, I've found that rasterToPolygons()
produces an error if not all stack bands are of the same type:

file <- system.file("external/test.grd", package="raster") s <-
stack(file, file, file)
s2 <- (s[[3]]-s[[2]])/(s[[3]]-s[[2]])
s1 <- stack(file, file, file)
s2 <- (s1[[3]]-s1[[2]])/(s1[[3]]-s1[[2]])
s <- addLayer(s1,s2)
sg <- rasterToPolygons(s,fun=NULL)
Error in `colnames<-`(`*tmp*`, value = c("x", "y", names(x))) :
  length of 'dimnames' [2] not equal to array extent

This used to work. The following works now:
 s <- addLayer(s1*1.0,s2)
 sg <- rasterToPolygons(s,fun=NULL)

Just reporting for other inattentive users like me (if any).


R-sig-Geo mailing list
[hidden email]