This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if("fasterize" %in% rownames(installed.packages()) == FALSE) {install.packages("fasterize")} | |
| if("raster" %in% rownames(installed.packages()) == FALSE) {install.packages("raster")} | |
| clip_raster_with_sf <- function(rast, sf){ | |
| r_mask <- fasterize::fasterize(sf, rast) | |
| r_masked <- raster::mask(rast, r_mask) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Create catchment areas based on travel time ## | |
| # Code by Giacomo Falchetta # | |
| # 11/02/2021 # | |
| ############## | |
| library(sf) | |
| library(raster) | |
| library(gdistance) | |
| library(tidyverse) | |
| library(data.table) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(raster) | |
| library(rhdf5) | |
| library(rgdal) | |
| library(maps) | |
| # manually define the working directory containing the Black Marble VNP46A1 files | |
| wd <- "C:\\myblackmarblefiles" | |
| # List h5 files in the specified directory | |
| setwd(wd) |