This file contains 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
fix_kml <- function(infile, outfile) { | |
intext <- readLines(con <- file(infile)) | |
out <- list() | |
ll = 1 | |
indout <- 1 | |
# cycle on lines of input | |
while(ll <= length(intext)){ | |
curline <- intext[ll] | |
# If a "hole block" is starting, check if there is only |
This file contains 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
# funzioni necessarie | |
find_UTM_zone <- function(longitude, latitude) { | |
# Special zones for Svalbard and Norway | |
if (latitude >= 72.0 && latitude < 84.0 ) | |
if (longitude >= 0.0 && longitude < 9.0) | |
return(31); | |
if (longitude >= 9.0 && longitude < 21.0) | |
return(33) |
This file contains 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
#install.packages("gdalUtilities") | |
library(gdalUtilities) | |
in_folder <- "/home/lb/nr_data/fire_cci/reference/Africa/Landsat8/Luini/178066/kml_lorenzo/" | |
out_folder <- file.path(in_folder, "shape_conversion") | |
dir.create(out_folder) | |
kml_files <- list.files(in_folder, pattern = "kml$", full.names = TRUE) | |
for(ff in kml_files) { | |
print(ff) | |
out_file <- file.path(out_folder, |
This file contains 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
ref_dir <- system.file("extdata/example_files/out_ref", package = "sen2r") | |
testthat::test_that( | |
"Tests on custom mask on TOA with smoothing and buffering, with save binary mask", { | |
outdir_6 <- file.path(tempdir(), "out_test6") | |
dir.create(dirname(outdir_6), showWarnings = FALSE) | |
exp_outpath_6 <- file.path(outdir_6, "TOA", "S2A1C_20170703_022_Barbellino_TOA_10.tif") | |
exp_outpath_msk <- file.path(outdir_6, "MSK", "S2A1C_20170703_022_Barbellino_MSK_10.tif") | |
unlink(exp_outpath_6) |
This file contains 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
#' @title bibtex_2academic | |
#' @description import publications from a bibtex file to a hugo-academic website | |
#' @author Lorenzo Busetto, phD (2017) <[email protected]> | |
bibtex_2academic <- function(bibfile, | |
outfold, | |
abstract = FALSE, | |
overwrite = FALSE) { | |
require(RefManageR) |
This file contains 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
points_in_distance_parallel <- function(in_pts, | |
maxdist, | |
ncuts = 10) { | |
require(doParallel) | |
require(foreach) | |
require(data.table) | |
require(sf) | |
# convert points to data.table and create a unique identifier | |
pts <- data.table(in_pts) |
This file contains 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
lint_package(".", | |
linters = with_defaults( | |
object_camel_case_linter = NULL, | |
object_snake_case_linter | |
) | |
) |
This file contains 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
From: | |
https://stackoverflow.com/questions/34416892/how-to-add-a-scale-bar-in-ggplot-map | |
library(maps) | |
library(maptools) | |
library(ggplot2) | |
library(grid) | |
# |
This file contains 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
# String manipulation | |
### Print an integer number with trailing zeroes | |
number = 1 | |
sprintf("%03i", number) | |
### use "easier" patterns with wildcards for regexp | |
glob2rx('*.tif') | |