Skip to content

Instantly share code, notes, and snippets.

View jlehtoma's full-sized avatar

Joona Lehtomäki jlehtoma

  • Helsinki
View GitHub Profile
@jlehtoma
jlehtoma / count_raster_cells.R
Last active January 22, 2024 21:20
Count non-zero raster cells in R
library(raster)
# Määritä tulostiedosto
results_csv <- "original_areas.csv"
# Aseta työkansio
setwd("[TYÖKANSIO]")
# Listaa kaikki tif-tiedostot kansiossa
feature_files <- list.files(pattern = "*.tif$")
# Apufunktio solulukumäärien laskemiseen
@jlehtoma
jlehtoma / wfs_tests.R
Created October 28, 2016 08:59
Testing different variants of accessing WFS data in R
library(gdalUtils)
library(rgdal)
library(rwfs)
library(sp)
dsn_espoo <- "WFS:http://kartat.espoo.fi/TeklaOgcWeb/WFS.ashx?service=WFS&REQUEST=GetCapabilities&maxFeatures=100000"
dsn_vantaa <- "WFS:http://gis.vantaa.fi/geoserver/wfs"
# Variant 1 ----------------------------------------------------------------
3. Please select the workshop you are attending. Events are listed in chronological order.
4. Will this be your first time attending a Data Carpentry workshop (as a learner)?
5. Which of the following describes your current status?
Undergraduate student
Graduate Student
Post-doc
Faculty
Industry
@jlehtoma
jlehtoma / ceph.md
Last active October 14, 2016 11:55
Mount Ceph datablock on SURFsara HPC Cloud VM

Mount the datadisk in the VM

In this section we show you how you can start using the new disk.

  1. On the UI, from the menu at the left pane select the Virtual Machines page under Virtual Resources. Create a new VM by selecting the Template you created in the previous step.
  2. Once the VM is in RUNNING state, ssh as root to the machine using your SSH-key.
  3. Run fdisk -l and see that your new datablock is there (Disk /dev/vdb: 10.5 GB).
  4. Mount the datadisk in the VM:
GNoTPA-expansion
├── 001_GNoTPA_caz_noadmu_2000_ecor
├── 002_GNoTPA_abf_noadmu_2000_ecor
├── 101_GNoTPA_caz_noadmu_2040_ecor
├── 102_GNoTPA_abf_noadmu_2040_ecor
├── GNoTPA_output
│ ├── 001_caz_noadmu_2000_ecor
│ │ ├── 001_caz_noadmu_2000_ecor.CAZ_MDE.curves.oct.txt
│ │ ├── 001_caz_noadmu_2000_ecor.CAZ_MDE.curves.txt
│ │ ├── 001_caz_noadmu_2000_ecor.CAZ_MDE.features_info.txt
### Keybase proof
I hereby claim:
* I am jlehtoma on github.
* I am jlehtoma (https://keybase.io/jlehtoma) on keybase.
* I have a public key whose fingerprint is 724B 39EE 612B B0A1 E518 5087 44DF 9D93 ED41 6438
To claim this, I am signing this object:
@jlehtoma
jlehtoma / scp_vocabulary_fin_eng.md
Created February 28, 2016 16:19
Spatial conservation prioritization vocabulary Finnish - English

Small English - Finnish vocabulary for spatial conservation planning

Translating the vocabulary is a work in progress, and not every word has a well-established Finnish translation. Suggestions to develop the translations further are welcome!

English Finnish
adaptive management sopeutuva hoito; mukautuva hoito
adequacy riittävä edustavuus, suojelutason riittävyys
ambiguity monimerkityksisyys
benefit hyöty
# Originally from http://rfunctions.blogspot.fi/2015/03/bivariate-maps-bivariatemap-function.html
# Install:
#install.packages("classInt")
#install.packages("raster")
#install.packages("rgdal")
#install.packages("dismo")
#install.packages("XML")
#install.packages("maps")
#install.packages("sp")
@jlehtoma
jlehtoma / print_warning.R
Created December 7, 2015 13:32
Print warnings as they happen with a for-loop in R
war <- function(x) {
suppressWarnings(w <- warning("There's a problem with: ", x))
message(w)
return(x)
}
for (i in 1:5) {
Sys.sleep(1)
war(i)
}
library(dplyr)
library(tidyr)
library(maps)
library(rworldmap)
library(mapdata)
library(rgdal)
library(shape)
medians <- read.csv("wintershifts_median.csv", header = TRUE, sep = ";",
stringsAsFactors = FALSE)