I have land coverage raster data that downloaded from JRC data catalogue (JRC website and JRC land coverage data download link), where data file like shapefiles at a very high degree of resolution, with information of land/soil coverage, for example, information on agricultural land coverage, information about mountain, city coverage and so on. I want to extract all information on agricultural and city land coverage only for Germany and render them in my final output as
However, I tried to read those data in R by using
raster::stack function and I intend to crop the raster of only Germany. I got some idea from
SO community (useful post), Using Jeffrey Evans' solution, here is runnable R code down below:
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)) # got some problem to unzip the file in R; better to use decompress the file in local site tifDat <- list.files(getwd(), "tif$") # tif file was located in two nested folder land_cover = raster::stack(tifDat)
I plotted this
tif format raster in R down below:
My goal is I want to crop this raster only for land coverage of Germany, so I did approximate projection in R, here is the possible R code I could give it try down below:
germany_territory <- readOGR("germany_landCover",layer="germany_landCover") # read Germany NUTS3 level polygon (by district level) proj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" proj_raster_landcover <- projectRaster(land_cover, crs = proj) germany_landCover_city <- extract(x = proj_raster_landcover, y = germany_territory)
but these don't work for me, so I also tried something like this down below:
data(wrld_simpl) germany <- wrld_simpl[wrld_simpl@data$NAME == "Germany",] ex_deu <- extent(raster::area(land_cover)) germany_land <- crop(land_cover, ex_deu)
still can't achieve what I want.
in cropped raster, I want a plot something like this down below:
I want to extract all information on agricultural and city land coverage only for Germany and render them in my final output as
How can I easily deal with
TIFF format raster in R?
How can I correctly crop the land coverage for Germany?
Any way to make this happen easily?
How can I correct my implementation on above?
Any more thoughts?