Skip to content

Instantly share code, notes, and snippets.

View kokkytos's full-sized avatar
🏠
Working from home

Leonidas Liakos kokkytos

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@kokkytos
kokkytos / calc_median.R
Created November 22, 2019 19:23
Calculate median per day of week
# Calculate median per day of week
library(lubridate)
library(raster)
library(magrittr)
r <- raster(nrows = 10, ncols = 10, res = 1,
xmn = 0,
xmx = 10,
ymn = 0,
@kokkytos
kokkytos / calc_median_wrong_results.R
Created November 23, 2019 21:41
The purpose is to compare whether the indexes of names from the result of the stackApply function correspond to the indexes that were defined as parameter input. An alternative method (ver_median function) is used for comparison.
# Calculate median per day of week.
library(lubridate)
library(raster)
library(magrittr)
r <- raster(nrows = 300, ncols = 300, res = 500,
xmn = 0,
xmx = 150000,
ymn = 0,
# Calculate mean per day of week.
library(lubridate)
library(raster)
library(magrittr)
r <- raster(
nrows = 300,
--- stackApply.R 2019-11-27 09:12:08.000000000 +0200
+++ /home/leonidas/Desktop/raster_source/source/R/stackApply.R 2019-11-27 12:50:43.268272464 +0200
@@ -84,9 +84,9 @@
}
if (rowcalc) {
- v <- lapply(uin, function(i) fun(a[, ind==uin[i], drop=FALSE], na.rm=na.rm))
+ v <- lapply(uin, function(i) fun(a[, ind==i, drop=FALSE], na.rm=na.rm))
} else {
- v <- lapply(uin, function(i, ...) apply(a[, ind==uin[i], drop=FALSE], 1, fun, na.rm=na.rm))
@kokkytos
kokkytos / rgibs.R
Last active December 1, 2019 18:05
[Λήψη δορυφορικών εικόνων στην R μέσω του GIBS API] #GIBS
library(gdalUtils)
rGIBS<-function(date=Sys.Date(), EPSGCODE,PRODUCT,projwin, outputdir=file.path(Sys.getenv("HOME"),"gibs_downloads"),...){
dir.create(outputdir, showWarnings = FALSE)
setwd(outputdir)
#generate xml
makeXML <- function(date, EPSGCODE,PRODUCT){
myxml<- sprintf('<GDAL_WMS><Service name="TiledWMS"><ServerUrl>https://gibs.earthdata.nasa.gov/twms/epsg%s/best/twms.cgi?</ServerUrl><TiledGroupName>%s tileset</TiledGroupName><Change key="${time}">%s</Change></Service></GDAL_WMS>',EPSGCODE, PRODUCT, date)
tmp <- tempfile(fileext=".xml")
fileConn<-file(tmp)
@kokkytos
kokkytos / FOSS.md
Last active January 26, 2023 09:57
[FOSS] #uth #software

FOSS

  1. QGIS 3.22.xx LTR (Long Term Release) (with Grass, SAGA and Orfeo toolboxes)(https://www.qgis.org/en/site/)
  2. Grass GIS 8.2 LTS (Long Term Support) (https://grass.osgeo.org/download/)
  3. R 4.1.3 (www.r-project.org) με RStudio (https://posit.co/download/rstudio-desktop/)
  4. SNAP (All Sentinel Toolboxes) (http://step.esa.int/main/download/snap-download/)
  5. WebODM (WebOpenDroneMap) (https://www.opendronemap.org/webodm/)
  6. Fragstats (https://github.com/kmcgarigal/Fragstats)
  7. WhiteBox Geospatial Analysis Tools (https://jblindsay.github.io/ghrg/Whitebox/ --- https://www.whiteboxgeo.com/ )
  8. SAGA GIS ([http:
@kokkytos
kokkytos / resize.md
Last active September 2, 2023 18:43
[shrink home, extend root] #LVM
  1. Shrink /home partition to 800GB, (system will force you to check filesystem for errors by running e2fsck)
e2fsck -f /dev/mapper/gisbox--vg-home
resize2fs /dev/mapper/gisbox--vg-home 800G
  1. Reduce the LVM to 800G
@kokkytos
kokkytos / batch_edit_metadata.sh
Created September 6, 2023 17:07
[Batch edit metadata in pdf] #pdf #metadata #batch #exiftool
#! /usr/bin/env bash
while IFS="," read -r Filename Title Author Subject
do
echo "Filename:$Filename"
echo "Title: $Title"
echo "Author: $Author"
echo "Subject: $Subject"
echo ""
exiftool -Title="$Title" -Author="$Author" -Subject="$Subject" "$Filename"