Dear Adam,

Thanks for reporting this bug in the current version of raster (1.9-92).
You have identified a valid work-around:

rasvals<-raster:::.polygonsToRaster(gSRDF, rasdef, field=gSRDF$TotPop90)

or

rasvals<-raster:::.polygonsToRaster(gSRDF, rasdef, field='TotPop90')


The bug occurs because rasterize has these arguments: function(x, y, field,
...)
and then calls polygonsToRaster(x, y, ...)

'field' should either not be an argument, or it should be passed on to
.polygonsToRaster

Robert


On Sun, May 13, 2012 at 7:28 PM, Adam Slez <aslez@princeton.edu> wrote:

> I'm using the rasterize command in the raster package to rasterize polygon
> data and can't seem to get the rasterize routine to recognize the field
> parameter.  Here's a working example which illustrates the problem:
>
> #load libraries
> library(raster)
> library(spgwr)
>
> #load data
> data(georgia)
>
> #confirm TotPop90 values
> range(gSRDF$TotPop90)
>
> #build raster data
> rasdef<-raster(extent(gSRDF), nrow = 100, ncol = 100)
> rasvals<-rasterize(gSRDF, rasdef, field = gSRDF$TotPop90)
> rasvals
>
> If we compare the minimum and maximum values reported in the rasvals output
> to the values reported in the range(gSRDF$TotPop90), it is clear that they
> aren't the same.  Simply put, the rasterize command seems to be spitting
> out the observation numbers rather than the values associated with the
> TotPop90 variable.
>
> In the case of SpatialPolygon data, the values input via the field
> parameter are passed to the .polygonsToRaster function.  Playing around
> with this, I've discovered that I get the expected results by doing the
> following:
>
> rasvals<-raster:::.polygonsToRaster(gSRDF, rasdef, gSRDF$TotPop90)
>
> Any thoughts as to why I can't do this using rasterize in the usual way?
>
> Adam
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

