[R-sig-Geo] raster values disappear in polygonsToRaster

Robert J. Hijmans r.hijmans at gmail.com
Mon Nov 22 06:44:48 CET 2010


Jochen,

It seems you forgot to "catch" the result of the function, and that
you want to do something like:

x <- polygonsToRaster(UE_spdf, UE2rot, field=2, updateRaster=FALSE)
plot(x)

Please note that in the current version of 'raster' this function is
deprecated and you will be warned to use the new function 'rasterize'
in stead.

Robert

On Sun, Nov 21, 2010 at 8:52 PM, Jochen Albrecht <jochen at hunter.cuny.edu> wrote:
>
> This is an odd one. I have used polygonsToRaster repeatedly and
> successfully.
> But this evening I am stumped by the fact that the raster values are
> properly reported as part of the function output but seem not to make it
> into the raster object. What went wrong here?
> Cheers,
>    Jochen
>
>> polygonsToRaster(UE_spdf, UE2rot, field=2, updateRaster=FALSE)
> Found 7050 region(s) and 14648 polygon(s)
> class       : RasterLayer
> filename    : C:/Temp/R_raster_tmp/raster_tmp_56110763822.grd
> nrow        : 3600
> ncol        : 7200
> ncell       : 25920000
> min value   : 53
> max value   : 94649
> projection  : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
> +towgs84=0,0,0
> xmin        : -180
> xmax        : 180
> ymin        : -90
> ymax        : 90
> xres        : 0.05
> yres        : 0.05
>
>> plot(UE2rot, col='red')
> Error in .plotraster(x, col = col, maxpixels = maxpixels, ...) :
>  no values associated with this RasterLayer
>
>> UE2rot
> class       : RasterLayer
> filename    :
> nrow        : 3600
> ncol        : 7200
> ncell       : 25920000
> min value   :
> max value   :
> projection  : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
> +towgs84=0,0,0
> xmin        : -180
> xmax        : 180
> ymin        : -90
> ymax        : 90
> xres        : 0.05
> yres        : 0.05
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list