Skip to content

Instantly share code, notes, and snippets.

View pecard's full-sized avatar

Paulo E. Cardoso pecard

  • www.bioinsight.pt
  • Lisbon
View GitHub Profile
@pecard
pecard / imp_berlin.R
Created November 8, 2022 00:18 — forked from z3tt/imp_berlin.R
Imperviousness levels in and around Berlin, Germany
library(tidyverse)
library(sf)
library(terra)
library(stars)
library(ggspatial)
library(systemfonts)
library(patchwork)
register_variant(
name = "Input Mono Light",
@pecard
pecard / .md
Last active February 20, 2021 11:14
Wind trajectory with ECMWF ERA-5 hourly wind data

GEE Code script

/**
 * @license
 * Copyright 2020 Google LLC.
 * SPDX-License-Identifier: Apache-2.0
 * 
 * Generates wind trajectory maps and animations from ECMWF ERA-5 hourly wind
 * data. A set of random points are drawn within an area of interest; a path is
@pecard
pecard / Land Cover change with Corine CLC
Created December 16, 2020 16:38
Land Cover Change with rgee
# packages
pacman::p_load('ps', "rgee", "tidyverse", "sf", "ggplot2", "patchwork",
'reticulate', 'googledrive', 'stars', 'plotKML', 'readxl',
'networkD3', 'OpenLand', 'ggtern')
ee_Initialize(email = '[email protected]')
# CORINE
clc18 = ee$Image('COPERNICUS/CORINE/V20/100m/2018')$select('landcover');
clc12 = ee$Image('COPERNICUS/CORINE/V20/100m/2012')$select('landcover');
@pecard
pecard / Forest Loss with rgee
Last active December 11, 2020 14:23
Forest Loss with rgee
# packages
pacman::p_load('ps', "rgee", "tidyverse", "sf", "ggplot2", "patchwork",
'reticulate')
ee_Initialize(email = '[email protected]')
# Hansen Global Forest Change
forestloss <- ee$Image("UMD/hansen/global_forest_change_2019_v1_7")
flossyear <- forestloss$select('lossyear')
@pecard
pecard / bird_vertical_profile.R
Last active February 20, 2021 11:13
Create bird vertical profile with data from ENRAM repository.
# Packages ----
library(bioRad)
library(rhdf5)
library(tidyverse)
library(lubridate)
library(zoo)
library(RColorBrewer)
library(patchwork)
@pecard
pecard / gmb_forestloss.R
Created June 12, 2020 11:32
gnb forest loss with gfc v1.7
library(tidyverse)
library(lubridate)
library(forcats)
library(janitor)
library(ggplot2)
library(ggthemr)
ggthemr('grape')
# Read Tables ----
refs <- read_csv('path to reference wdpa csv file') %>%
@pecard
pecard / getExif.R
Last active May 16, 2020 00:07
Get Metadata (EXIF) from Smartphone photos
# Paulo E. Cardoso 2020-05-15
# Read EXIF Metadata from Photos obtained with SmarthPhone
# Initial instructions ----------------------------------
# Download ExifTool executable from https://exiftool.org/ and
# unzip the exiftool(-k).exe to Rstudio Project root folder
# Download your fotos to (this case) data-raw folder
# Assuming .jpg image files
# Install packages ----------------------------------------
# Unsupervided Classification of Landsat images
# !UTIL http://bioinf.wehi.edu.au/marray/ibc2004/lab4/lab4.html
# !UTIL http://www.digital-geography.com/unsupervised-classification-of-a-landsat-image-in-r-the-whole-story-or-part-two/
# !UTIL http://www.jstatsoft.org/v15/i09/paper
# !UTIL http://cran.r-project.org/web/packages/e1071/e1071.pdf
# Packages
kpacks <- c('raster', 'sp', 'rgdal', 'cluster')
new.packs <- kpacks[!(kpacks %in% installed.packages()[,"Package"])]
if(length(new.packs)) install.packages(new.packs)
#! Gráfico de Barras GGPLOT
#! Paulo Eduardo Cardoso
library(chron)
library(ggplot2)
horas <- read.table("clipboard",header=T)
horas <- strptime(as.character(horas[,1]),"%H:%M:%S")
horaH <- data.frame("Hora"=hours(horas))
horasdia <- data.frame("Hora"=c(0:23))
postsH <- as.data.frame(table(horaH))
postsDia <- merge(horasdia,postsH,by.x="Hora",by.y="horaH",all.x=T)
#! Compositional Analysis
#! Paulo Eduardo Cardoso
library(adehabitat)
#! Análise Compana para matrizes lidas a partir do clipboard.
usado <- read.delim("clipboard", sep = "\t", dec = ".", header = T)
#! Remove linhas sem dados - NA
usado <- usado[!is.na(usado[1]),]
#! Constroi a matriz de disponiveis alterando os valores em dispo
dispo <- as.data.frame(cbind(rep(27.3,nrow(usado)),rep(19.8,nrow(usado)),rep(80.2,nrow(usado))))