[R-sig-Geo] extract value of raster attribute with polygon
Fernando Gimeno
fe.gimeno at gmail.com
Tue Jul 12 21:22:04 CEST 2016
many thank.
i have a raster with attribute table of seven attributes, i want only
extract the sum value of one attribute with a poligon. I need assign value
in attribute table for those poligon
2016-07-11 23:07 GMT-03:00 Bacou, Melanie <mel at mbacou.com>:
> Also when summarizing classified rasters, it is usual to use the `mode`
> function (instead of `sum`) since you're typically interested in the
> dominant class.
>
>
> On 7/11/2016 5:48 PM, Fernando Gimeno wrote:
>
>> i have a raster with attribute table and i need extract values with a
>> polygon. Help me please.
>>
>> COMUNAS<-shapefile("COMUNAS.shp")
>> RAST<-raster("raster_23052016/for_GDB/comb_viii.tif")
>>
>> COMUNAS<-spTransform(COMUNAS,CRS("+proj=utm +zone=18 +south +ellps=WGS84
>> +datum=WGS84 +units=m +no_defs"))
>>
>> dbf<-read.dbf("raster_23052016/for_GDB/comb_viii.tif.vat.dbf")
>>
>> r <- ratify(RAST)
>> rat <- levels(r)[[1]]
>> rat<-c(rat,dbf)
>> rat<-as.data.frame(rat)
>> levels(r) <- rat
>>
>> COMUNAS$BAL_CO2_CO <- extract(r, COMUNAS, fun = sum, na.rm = TRUE)
>>
>>
>
--
*Fernando J. Gimeno Molina*
*Licenciado en Geografía, Universidad de Chile*
*Geógrafo, Universidad de Chile*
*Mc(c) Gestión y Planificación Ambiental, Universidad de Chile*
*Diploma en Geomática Aplicada, Universidad de Chile*
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list