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

Tom Gottfried tom.gottfried at tum.de
Tue Dec 13 12:27:25 CET 2011


spplot(myLanduse, "GRIDCODE")

regards,
Tom

Am 13.12.2011 12:10, schrieb Georg Hörmann:
> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Alte Akademie 12
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax:   ++49 (0)8161 713243
email: tom.gottfried at wzw.tum.de
http://www.wzw.tum.de/gruenland



More information about the R-sig-Geo mailing list