I want to get area estimation for each polygon by using pixel counting method. The original landcover map was raster data that come with a distinctive class assigned to each pixel (landcover map legend). However, to get area estimation by using pixel counting is not intuitive to me. Perhaps, the first things I can do is extract all the pixels for each polygon which present information about the distribution of land cover classes within each polygon. After that, I need to use pixel counting method to get area estimation and aggregate all land/soil coverage for the city, agriculture area for each polygon. For me, using pixel counting to obtain area estimation is not straightforward and don't have a solid idea how to get this done in R.
Note that original landcover map is rather big (about 92mb
) and it is difficult to produce reproducible example for landcover raster, so forgive me for such inconveniece. Here is the R
script to acquire landcover raster:
library(raster)
library(R.utils)
url = "https://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/LUISA/PrimaryOutput/Europe/REF-2014/JRC_LUISA_Input_Corine_land_cover_2006_r_ref_2014.zip"
download.file(url, basename(url))
gunzip(basename(url))
rname <- list.files(getwd(), "tif$")
land_cover <- raster::raster("~/LUISA_CLC_land_coverage/clc06_r.tif")
I want to aggregate all land/soil coverage information for each polygon (total 403 polygon that land cover information to be aggregated); Here are polygons I am gonna use for area estimation: shapefile with polygons are available on the fly:
I cropped original landcover raster as follow:
deu_shp = maptools::readShapePoly("~/adm2.shp",
proj4string=crswgs84,verbose=TRUE)
deu_proj <- spTransform(deu_shp, CRSobj = land_cover@crs)
land_cover_deu <- crop(land_cover, deu_proj )
To understand area estimation with pixel counting, I googled related article and found this : Using remote sensing for crop area estimation and idea that presented in this article is closely match with my interest, but to implement presented method is purely theoretical and hard for me to do it in R
. I am quite okay if there is any quick and dirty way to get area estimation with pixel counting where land/soil coverage information (such as city, forest, agricultural land) must be aggregated to each polygon (shapefile with polygons are available on the fly).
for pixel extraction, I could simply use raster::extract
as follow (the code down below is trial):
lapply(deu_proj, function(x) {
pixel_extract = raster::extract(land_cover_deu, deu_proj[x,])
pixel_extract= as.data.frame(pixel_extract)
})
and above simple pixel extraction is not very efficient for original land cover raster. I don't know how to make pixel counting for the extracted pixel in each polygon and get corresponding area estimation (such as land coverage of the city, forest, agriculture area and so on).
Any idea to make this happen in R? How can I get area estimation with pixel counting approach for given land cover raster? Is that possible to aggregate land/soil coverage information to each polygon? Thanks in advance