Skip to content

Instantly share code, notes, and snippets.

View geofis's full-sized avatar

José Ramón Martínez Batlle geofis

View GitHub Profile
# Generate tiles from image, then create a layered/stacked 3D perspective.
# Modified from: https://stackoverflow.com/questions/56279466/how-do-i-create-a-figure-displaying-a-stack-of-images-at-an-angle
# Modules
import cv2
import numpy as np
# Load source image
im = cv2.imread('yearly_forest_loss_patches_1_ha_per_100_sq_km.jpg')
im
@geofis
geofis / ejemplo_pagedreport.Rmd
Created January 30, 2021 20:23
Ejemplo de pagedreport
---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
pagedreport::paged_grid
# pagedown::html_paged:
# toc: true
# # change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
# self_contained: false
@geofis
geofis / testing_performance_zonal_statistics_R_pktools.md
Last active June 2, 2020 19:07
Performance comparison between two zonal statistics algorithms: R raster::extract vs. pkextractogr

Performance comparison between two zonal statistics algorithms: R raster::extract vs. pkextractogr

Packages

library(raster)
@geofis
geofis / TanDEM_X_FNF_50m_DR.R
Last active May 8, 2019 16:46
The global forest/non-forest map from TanDEM-X interferometric SAR data. Relative value of forest for the Dominican Republic
# Gobal forest/non-forest map from TanDEM-X interferometric SAR data.
# Percentages of classes (forest, non-forest, urban) in the Dominican Republic
# Author: José Ramón Martínez Batlle, Universidad Autónoma de Santo Domingo (UASD)
# Related article paper: https://www.sciencedirect.com/science/article/pii/S0034425717305795
# Source data via web: https://download.geoservice.dlr.de/FNF50/
wd <- tempdir()
setwd(wd)
getwd()
#Download and merge tiles
@geofis
geofis / try_all_gdal_datums.R
Last active April 25, 2019 13:14
Try all datums available in GDAL to determine an unknown projection
#Packages
library(sf)
# If GDAL is installed locally...
# listsrs <- read.csv('/usr/share/gdal/2.2/pcs.csv')
# If not:
# Source: https://trac.osgeo.org/gdal/browser/trunk/gdal/data/pcs.csv
# Revision 41888, trunk:
listsrs <- read.csv(
'https://trac.osgeo.org/gdal/export/41888/trunk/gdal/data/pcs.csv'
@geofis
geofis / script_ana.R
Last active May 23, 2019 16:19
Script de Ana: control de version
setwd(tempdir())
getwd()
urldatos <- 'http://www.geografiafisica.org/sem201901/geo112/datos_campo_201901/'
clastosatrana <- read.csv(
paste0(
urldatos,
'clastosatr_ana.csv'
),
encoding = "UTF-8",
@geofis
geofis / script_carolaine.R
Last active March 31, 2019 01:48
Script de Carolaine: control de version
setwd(tempdir())
getwd()
urldatos <- 'http://www.geografiafisica.org/sem201901/geo112/datos_campo_201901/'
clastosatr <- read.csv(
paste0(
urldatos,
'clastosatr_carolaine.csv'
@geofis
geofis / graficos_indice_aplanamiento_y_a_b_c.R
Last active March 26, 2019 23:12
Diagramas de caja e histogramas con ejes e índice de aplanamiento
wd <- tempdir()
setwd(wd)
urldatos <- 'http://www.geografiafisica.org/sem201901/geo112/datos_campo_201901/'
clastosall <- read.csv(
paste0(
urldatos,
'joined_csv_files.csv'
),
check.names = F,
encoding = 'UTF-8')
@geofis
geofis / bind_csv.R
Created February 28, 2019 13:09
Bind CSV files of river particle axes length into a single one
#Working directory
wd <- '/home/jr/Documentos/clases_UASD/sem201901/datos_campo/'
alumnas <- list.dirs(wd, full.names = F, recursive = F)
csvfiles <- sapply(
alumnas,
function(x){
fuente <- list.files(
paste0(
wd,
x
@geofis
geofis / conversion_xlsx_to_csv.R
Created February 28, 2019 12:24
Convert Excel files of river particle axes length to CSV format using R
#Convert Excel files of river particle axes length to CSV format using R
#Packages
library(dplyr)
library(readxl)
#Working directory
wd <- '/home/jr/Documentos/clases_UASD/sem201901/datos_campo/'
alumnas <- list.dirs(wd, full.names = F, recursive = F)
i <- NULL