[R-sig-Geo] How to plot attributes of a shapefile?

Georg Hörmann ghoermann at hydrology.uni-kiel.de
Tue Dec 13 12:10:17 CET 2011


Hello World,

I am somehow stuck with a simple GIS problem.
I have a landuse map imported from ArcGIS in
shapefile format. Everything is ok,
but if I plot the map. it only plots the polygons
without attributes.
I want to plot the map with the attribute
"GRIDCODE", which is the code for the landuse.
The only solution I found was to convert everything
to a raster file, but then I lose information...


The structure is:
 > str(myLanduse at data)
'data.frame':   7716 obs. of  6 variables:
  $ ID       : int  31469 31470 31471 31472 31473 31474 31475 31476 
31477 31478 ...
  $ GRIDCODE : int  1 2 6 1 1 6 4 2 6 2 ...
  $ AREA     : num  1720 1718 907 636 1232 ...
  $ PERIMETER: num  169 169 123 107 161 ...
  $ ACRES    : num  0.425 0.424 0.224 0.157 0.305 0.777 0.363 0.411 0.18 
0.354 ...
  $ HECTARES : num  0.172 0.172 0.091 0.064 0.123 0.314 0.147 0.166 
0.073 0.143 ...
  - attr(*, "data_types")= chr  "N" "N" "N" "N" ...

Actually I am using this solution:

LUTemplate <- raster(ncol=110, nrow=110, crs=as.character(NA))
extent(LUTemplate)  <-  extent(myLanduse)
LUraster <- rasterize(myLanduse, LUTemplate, field="GRIDCODE")

I would like a solution like :-)

plot(myLanduse, attribute="GRIDCODE")

Any hints?

Thanks,
Georg



More information about the R-sig-Geo mailing list