GitLab at IIASA

01_PreparePolygonFiles.R 1.67 KiB
Newer Older
Martin Jung's avatar
Martin Jung committed
library(sf)
library(tidyverse)
library(stringr)
source("Scripts/00_Functions.R") # Some Convenience functions

# Paths
path_input <- "Inputs/" # Note that inputs and other files need to be downloaded separately
path_output <- "Outputs/"
path_scripts <- "Scripts/"

# CRS proj4strings
crs.latlong <- "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0" # Latitude longitude
crs.laea <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"
crs.mollweide <- "+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs" # For global equal area projections

# ------------- #
#### Split EEA reference grid for a harmonized grid for rasterization ####
# Ideally we ensure that the reference grid is consistent with the 
# EEA reference grid https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2

# Since the reference grid is for Europe only available at a 10km resolution, 
# we will use the original EEA grid and split it into smaller parts.

# Download European reference grids
# Source: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/grids
for(grain in c("1km", "2km", "5km", "10km", "20km", "50km", "100km")){
  print(grain)
  url <- paste0("https://gisco-services.ec.europa.eu/grid/grid_",grain,"_surf.gpkg")
  curl::curl_download(
    url,
    paste0(path_input, basename(url) )
  )
}


Martin Jung's avatar
Martin Jung committed
#### Prepare European countries layer ####
# Specifically take the various European countries and

# Now select all countries with this information
sf::st_drop_geometry() |> filter(CONTINENT == "Europe") 

sub <- p |> filter(COUNTRY %in% co$SOVEREIGN)

write_sf(sub, "/home/martin/GADM_Europesubset.gpkg")

# --- #