Skip to content

Instantly share code, notes, and snippets.

@geografif
geografif / MKtrend.R
Created May 14, 2022 15:44 — forked from hakimabdi/MKtrend.R
This function performs a Mann-Kendall trend test with associated p-values on a time seris of gridded satellite data
#############################################################################################
# title : Perform a Mann-Kendall trend test of satellite image time series
# purpose : Mann-Kendall test of monotonic trend and associated statistical significance
# author : Abdulhakim Abdi (@HakimAbdi)
# input : Raster stack/brick comprising a time series of observations
# output : Raster object of monotoic trend (Kendall's tau), significance or both (i.e. brick)
# data : Test data: https://www.dropbox.com/sh/bz0fxvtm27mf4w8/AADE8kOPKnx1c84QxJDSAoyAa?dl=0
# notes : Depending on the time series, it is might be useful prewhiten the data to remove serial correlation
# : prior to extracting the trend. See blog post on www.hakimabdi.com for more information.
#############################################################################################
@geografif
geografif / Landcover_classification.R
Created May 24, 2022 15:44
Remote sensing image classification, spectral signature evaluation, and accuracy assessment
## Modified from Babak Mohammadi's script
## Set working folder so you don't have to type the whole address when loading file
setwd("D:/MSc/LU/NGEN08_Satellite_RS/Exercise/3_Lunds_kommun/Module_3/Classification")
#getwd()
## Uncomment to install required packages below
#install.packages("RStoolbox")
#install.packages("monmlp")
#install.packages("readxl") #read excel spreadsheet instead of csv
@geografif
geografif / Rleaflet.R
Last active June 9, 2022 11:24
Plot points, labelling, set icon, set layer groups of basemap using leaflet package in R
rm(list = ls())
setwd("D:/Learn/Rleaflet")
install.packages("shiny")
install.packages("leaflet")
library(leaflet)
library(htmltools)
library(sp)
library(rgdal)
@geografif
geografif / Trend_climateNetCDF.R
Created May 24, 2022 15:51
Open NetCDF climate variable data, create monthly average, plot, and trend analysis
## Set working directory
setwd("D:/MSc/LU/NGEN08_Satellite_RS/Exercise/4_Time_series/Climate")
getwd() #Print wd
rm(list=ls()) #Clear Environment
## Load library
library(sp)
library(rgdal)
library(raster)
library(writexl)
@geografif
geografif / NetCDF_GeoTiff_BatchExportIndividual.R
Last active January 31, 2023 17:49
Load NetCDF raster, stack, and batch export individual layer in GeoTiff format
#-----------------------------------------------------------------------
# SET WORKING DIRECTORY
#-----------------------------------------------------------------------
setwd("D:/Side/")
getwd() #Print wd
#rm(list=ls()) #Clear Environment
#-----------------------------------------------------------------------
@geografif
geografif / RF_DensityPlot_SAR_PolSAR.R
Last active January 31, 2023 17:48
Classify SAR intensity and polarimetric decomposition features with Random Forest, create Joyplot/Density Plot
getwd()
setwd("/path/RadarRemoteSensing/")
dev.off(dev.list()["RStudioGD"])
rm(list= ls(all.names=TRUE))
library(rgdal)
library(sp)
library(sf)
library(raster)
@geografif
geografif / CNN_UNet_Binary.R
Last active November 20, 2022 17:37
Trying UNet neural networks for semantic segmentation task with binary class in R
# materials: https://forloopsandpiepkicks.wordpress.com/2021/04/09/image-segmentation-in-r-automatic-background-removal-like-in-a-zoom-conference/
getwd()
setwd("D:/Learn/DL/oxford_pets/")
library(tidyverse)
library(keras)
library(tensorflow)
#remotes::install_github("maju116/platypus")
library(platypus)
@geografif
geografif / TS_DOP_bfastSpatial.R
Last active January 26, 2023 17:56
Running bfastSpatial. Unlike bfast, bfastSpatial was able to perform analysis on time-series gridded data with frequency=1 (annual data).
library(raster)
library(rasterVis)
library(stringr)
library(zoo) # time series handling
library(strucchange) # break detection
library(colorspace)
devtools:::install_github("gearslaboratory/gdalUtils")
devtools:::install_github('loicdtx/bfastSpatial')
library(gdalUtils)
library(bfastSpatial)
@geografif
geografif / build_unet.py
Created February 7, 2023 19:02 — forked from ad-1/build_unet.py
Semantic Segmentation of MBRSC Aerial Imagery of Dubai using a TensorFlow U-Net model in Python. https://towardsdatascience.com/semantic-segmentation-of-aerial-imagery-using-u-net-in-python-552705238514
# =====================================================
# define U-Net model architecture
def build_unet(img_shape):
# input layer shape is equal to patch image size
inputs = Input(shape=img_shape)
# rescale images from (0, 255) to (0, 1)
rescale = Rescaling(scale=1. / 255, input_shape=(img_height, img_width, img_channels))(inputs)
previous_block_activation = rescale # Set aside residual