[R-sig-Geo] projection for image processing

Rafael Wüest rafael.wueest at wsl.ch
Sat Oct 27 16:09:08 CEST 2012


Dear List

I'm trying to do some image processing with the help of the raster package. I'm getting close to what I need. However, the last step involves raster::rastreToPolygons, with the option dissolve=T. That's where I'm running into an error: 

> Error in function (classes, fdef, mtable) : unable to find an inherited method for function "proj4string", for signature "NULL"

I figured out that the rgeos function gUnaryUnion is called in the background and requires the raster to be projected. Well, my raster is not projected, it's a jpeg image. Is there a projection I can use for this or does anyone see a workaround?

Here is a small reproducible example:
library(raster)
m<-matrix(NA,50,50)
r<-raster(m,xmn=0,xmx=ncol(m),ymn=0,ymx=nrow(m))
r[]<-runif(ncell(r),1,100)
clmps<-clump(r<20)
polys<-rasterToPolygons(clmps,dissolve=T)

My sessionInfo() output:
> R version 2.14.2 (2012-02-29)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
> 
> locale:
> [1] de_CH.UTF-8/de_CH.UTF-8/de_CH.UTF-8/C/de_CH.UTF-8/de_CH.UTF-8
> 
> attached base packages:
> [1] tcltk     tools     stats     graphics  grDevices utils     datasets  methods  
> [9] base     
> 
> other attached packages:
> [1] rgeos_0.2-7     plyr_1.7.1      stringr_0.6     igraph0_0.5.5-2 rgdal_0.7-8    
> [6] raster_2.0-08   sp_0.9-99       SciViews_0.9-2  ellipse_0.3-7   MASS_7.3-17    
> [11] svGUI_0.9-50    svSocket_0.9-53 svMisc_0.9-65  
> 
> loaded via a namespace (and not attached):
> [1] grid_2.14.2    lattice_0.20-6

Any help is greatly appreciated,
Rafael


--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

+41 44 7392126
rafael.wueest at wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest/index_EN



More information about the R-sig-Geo mailing list