Robert,

Thanks for looking at this. Unfortunately, updating R and Raster did not 
help. Here is info you requested. Hope that helps!

Gustaf

 > tt<-rasterize(SpPDF,tes,field="idd")
Error in writeValues(out, fun(n), tr$row[i]) :
   error in evaluating the argument 'v' in selecting a method for 
function 'writeValues': Error in fun(n) : unused argument(s) (n)
 > traceback()
6: writeValues(out, fun(n), tr$row[i])
5: init(rstr, function() NA)
4: .polygonsToRaster(x, y, field = field, fun = fun, background = 
background,
        mask = mask, update = update, updateValue = updateValue,
        filename = filename, getCover = getCover, silent = silent,
        ...)
3: .local(x, y, ...)
2: rasterize(SpPDF, tes, field = "idd")
1: rasterize(SpPDF, tes, field = "idd")
 >

 > show(SpPDF)
class       : SpatialPolygonsDataFrame
nfeatures   : 58824
extent      : -11.08333, 31.91753, 33.91667, 71.91743  (xmin, xmax, 
ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84
nvariables  : 92
names       :   X.Lon,     Lat, JulT00, P1900, NH1900,  N1900, JulT10, 
P1910, NH1910,  N1910, JulT20, P1920, NH1920,  N1920, JulT30, ...
min values  :   -10.5, 34.8333,    0.3,   260,  0.103, 0.0163, 0,   
261,  0.103, 0.0184,    0.1,   245,  0.118, 0.0215,    0.3, ...
max values  : 31.8333,      71,   27.2,  3267, 14.837, 1.5572, 27.2,  
3226, 11.927, 1.2981,   27.8,  3303, 12.945, 1.4166,   27.5, ...
Warning messages:
1: closing unused connection 4 
(C:/Users/veGustaf/AppData/Local/Temp/R_raster_tmp/veGustaf/raster_tmp_2012-12-18_192108_37929.gri)
 

2: closing unused connection 3 
(C:/Users/veGustaf/AppData/Local/Temp/R_raster_tmp/veGustaf/raster_tmp_2012-12-18_191936_11753.gri)
 

 >

 > show(tes)
class       : RasterLayer
dimensions  : 12768, 11050, 141086400  (nrow, ncol, ncell)
resolution  : 250, 250  (x, y)
extent      : 2782250, 5544750, 2220250, 5412250  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84


 > sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252
[3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Sweden.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

other attached packages:
[1] raster_2.0-31 sp_1.0-2

loaded via a namespace (and not attached):
[1] grid_2.15.2     lattice_0.20-10 tools_2.15.2
 >


On 2012-12-17 07:32, Robert J. Hijmans wrote:
> Gustaf,
>
> When reporting that something does not work, please include the result 
> of your
>
> sessionInfo()
>
> Just after the error occurs.
>
> traceback()
>
> can also be helpful. In this case it would appear that that you are 
> not using the current version of raster. If that is the case, please 
> update.packages() first (perhaps after getting the most recent version 
> of R). Some more info on the SpatialPolygonsDataFrame that causes the 
> error would also be helpful (use the show function after raster is 
> loaded).
>
>
> Robert
>
>
> On Wed, Dec 12, 2012 at 11:55 PM, Gustaf Granath 
> <gustaf.gran...@ebc.uu.se <mailto:gustaf.gran...@ebc.uu.se>> wrote:
>
>     Hi,
>     I have used the rasterize function to get values from a
>     spatialPolyDataFrame variable (@data$variable) to raster:
>     rasterize(SPDFobj, rasterObj, field="variable")
>
>     For a specific case a get a, to me, strange error message .
>     "Error in writeValues(out, fun(n), tr$row[i]) :
>       error in evaluating the argument 'v' in selecting a method for
>     function 'writeValues': Error in fun(n) : unused argument(s) (n)"
>
>     It works with one SpatialPolyDataFrame that Im working with, but
>     not with another one and I cannot figure out why. Any ideas of
>     what is going on?
>
>     Unfortunately, I have not been able to reproduce the error with
>     simulated data (and my data files are huge) but this is
>     essentially what I have done (but the code below works - actually
>     the raster layer in this code works with my SPDFobj):
>     p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60),
>     c(-180,-20))
>     p2 <- rbind(c(-10,0), c(140,60), c(160,0), c(140,-55), c(-10,0))
>     p3 <- rbind(c(-125,0), c(0,60), c(40,5), c(15,-45), c(-125,0))
>     pols <- SpatialPolygons( list(  Polygons(list(Polygon(p1),
>     Polygon(hole)), 1),
>                     Polygons(list(Polygon(p2)), 2),
>     Polygons(list(Polygon(p3)), 3)))
>     pols <-SpatialPolygonsDataFrame(pols, data.frame("W"=1:3))
>     r <- raster(ncol=80, nrow=90)
>     test<-rasterize(pols, r, field="W")
>
>     Here is an overview of the objects I am using.
>
>     > summary(SPDFobj)
>     Object of class SpatialPolygonsDataFrame
>     Coordinates:
>             min      max
>     x -11.08333 31.91753
>     y  33.91667 71.91743
>     Is projected: FALSE
>     proj4string : [+proj=longlat +datum=WGS84]
>     Data attributes:
>          variable
>     ...
>     ...
>
>     > rasterObj_orig
>     class       : RasterLayer
>     dimensions  : 12768, 11050, 141086400  (nrow, ncol, ncell)
>     resolution  : 250, 250  (x, y)
>     extent      : 2782250, 5544750, 2220250, 5412250  (xmin, xmax,
>     ymin, ymax)
>     coord. ref. : +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000
>     +y_0=3210000 +ellps=GRS80 +units=m +no_defs
>     data source : C:\Users\veGustaf\Desktop\phd\Where is Ndep neg\bogs.grd
>     names       : layer
>     values      : 36, 36  (min, max)
>
>     > rasterObj #projection fixed etc through an extent object, raster
>     --> extent --> raster
>     class       : RasterLayer
>     dimensions  : 12768, 11050, 141086400  (nrow, ncol, ncell)
>     resolution  : 250, 250  (x, y)
>     extent      : 2782250, 5544750, 2220250, 5412250  (xmin, xmax,
>     ymin, ymax)
>     coord. ref. : +proj=longlat +datum=WGS84
>
>
>     Cheers,
>
>     Gustaf
>
>     -- 
>     Gustaf Granath (PhD)
>
>     Dept of Plant Ecology and Evolution
>     Uppsala University
>
>     _______________________________________________
>     R-sig-Geo mailing list
>     R-sig-Geo@r-project.org <mailto:R-sig-Geo@r-project.org>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

-- 
Gustaf Granath (PhD)
Dept of Plant Ecology and Evolution
Uppsala University


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to