Yuanchao, I think this should work if you update the raster package to its current version. If something does not seem to work, include your sessionInfo() in your message. Robert
On Fri, Jul 20, 2012 at 8:43 AM, Fan, Yuanchao <[email protected]> wrote: > Dear everyone, > > I try to use the rasterize function to do a polygon-to-raster conversion > and transfer the polygon attribute field column values to the output > raster, but it always used the polygon index as raster values. Have anyone > else experienced this issue? > > Example: > den.map <- raster("den.img") > towns <- readShapePoly("town_county.shp") > den.map <- rasterize(towns, den.map, field='AREA') > > > towns > class : SpatialPolygonsDataFrame > nfeatures : 351 > extent : 33863.73, 777606.4, 330837, 959743 (xmin, xmax, ymin, ymax) > coord. ref. : NA > data dims : 351, 6 (nrow, ncol) > min values : (f), (f), (f), 32335.8, 82897.5, 3249309.50568 > max values : (f), (f), (f), 241617, 852081, 266181688.716 > variables : TOWN, COUNTY, Parcel_YN, Med_income, HS_Value, AREA > > In this example, the field='AREA' of towns didn't take any effect, instead > the polygon index 1:351 was used as raster values. I tried all the > possibilities and couldn't figure out the problem. > > Could anyone please help? > Thanks, > Yuanchao > > Yuanchao Fan, M.S.| Ecological Research Assistant > Smithsonian Conservation Biology Institute > Smithsonian Institution > 1500 Remount Road, Front Royal, VA 22630 > T 540-551-2053 | F 540-635-6506 | Email [email protected]<mailto:[email protected]> > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
