[R-sig-Geo] projection for image processing

Rafael Wüest rafael.wueest at wsl.ch
Sat Oct 27 18:25:17 CEST 2012


Robert and Barry

thank you very much! Updating raster to version 2.0-12 did the job!

Rafael

On 27.10.2012, at 17:53, Robert J. Hijmans wrote:

> Rafael, 
> 
> Your example works for me with raster 2.0-12 (on CRAN). As far as I know rgeos only gives warnings, not errors, about projections and you could turn that off with any projection description as it is not interpreted (except for lon/lat as it will warn about that). 
> 
> Robert
> 
> On Sat, Oct 27, 2012 at 7:09 AM, Rafael Wüest <rafael.wueest at wsl.ch> wrote:
> 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
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 



--
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