Skip to content

Instantly share code, notes, and snippets.

Avatar

José Ramón Martínez Batlle geofis

View GitHub Profile
View layers-in-perspective-3D-stack.py
# 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 Jan 30, 2021
Ejemplo de pagedreport
View ejemplo_pagedreport.Rmd
---
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 Jun 2, 2020
Performance comparison between two zonal statistics algorithms: R raster::extract vs. pkextractogr
View testing_performance_zonal_statistics_R_pktools.md

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
The global forest/non-forest map from TanDEM-X interferometric SAR data. Relative value of forest for the Dominican Republic
View TanDEM_X_FNF_50m_DR.R
# 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 Apr 25, 2019
Try all datums available in GDAL to determine an unknown projection
View try_all_gdal_datums.R
#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
Script de Ana: control de version
View script_ana.R
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 Mar 31, 2019
Script de Carolaine: control de version
View script_carolaine.R
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 Mar 26, 2019
Diagramas de caja e histogramas con ejes e índice de aplanamiento
View graficos_indice_aplanamiento_y_a_b_c.R
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 Feb 28, 2019
Bind CSV files of river particle axes length into a single one
View bind_csv.R
#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 Feb 28, 2019
Convert Excel files of river particle axes length to CSV format using R
View conversion_xlsx_to_csv.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