Skip to content

Instantly share code, notes, and snippets.

View mikkohei13's full-sized avatar

Mikko Heikkinen mikkohei13

View GitHub Profile
Lähde:
Talvilintulaskenta - http://tun.fi/HR.39 [metadata], Creative Commons Nimeä
Aineistolataus Lajitietokeskuksesta http://tun.fi/HBF.59676
id yearDecember WBC.sorbusBerriesAtCensus
http://tun.fi/JX.100009 1990 1
http://tun.fi/JX.100131 1990 1
http://tun.fi/JX.100396 1990 1
http://tun.fi/JX.100605 1990 1
http://tun.fi/JX.100902 1990 2
# Code courtesy of William Morris
# Requires setting your personal token, and installing this:
# apt-get install libcurl4-openssl-dev libssl-dev
install.packages("finbif")
install.packages("ggplot2")
library(finbif)
library(ggplot2)
@mikkohei13
mikkohei13 / handle_birdnet_csv.py
Last active June 26, 2022 07:46
Tool to concatenate and extend BirdNET CSV files
import os
import pandas as pd
import datetime
import re
def get_datafile_list(directory, limit):
datafile_list = []
objects = os.listdir(directory)
i = 0
@mikkohei13
mikkohei13 / crop.py
Created November 23, 2022 12:42
Crop images in a folder
import os
from os import listdir
from PIL import Image
# get the path/directory
source_dir = "images/Carpocoris_fuscispinus"
target_dir = "images/carp_fusc_crop"
limit = 300
@mikkohei13
mikkohei13 / inat-sound.py
Created February 6, 2023 14:11
Python script to fetch sound files from iNaturalist API
'''
Script to download sound files from iNaturalist.
Mikko Heikkinen / Luomus, 2023-02-06
Requires "requests" library.
input: iNat API URL with parameters
output: files divided into folders by taxon
@mikkohei13
mikkohei13 / minimaps.py
Last active February 12, 2023 09:09
Generates small PNG maps of Finland with a dot at given coordinates.
# Generates small maps of Finland with a dot at given coordinates.
import geopandas as gpd
import matplotlib.pyplot as plt
from pyproj import Proj, transform
# Load a GeoJSON file with outline of Finland into a GeoDataFrame
geojson = gpd.read_file('fin.geojson')
@mikkohei13
mikkohei13 / finland_simple_outline.geojson
Created February 11, 2023 22:10
GeoJSON file of the outline of Finland, simplified for very small maps.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikkohei13
mikkohei13 / birdatlas-treevolume.csv
Created February 13, 2023 16:45
Data from Finnish bird atlas: observations with 100 m accuracy compared to tree volume data (gaussian filtered) from Luke. Data CC-BY 4.0.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 13 in line 1.
fid;common_name_finnish;count;unique;min;max;range;sum;mean;median;stddev;minority;majority;q1;q3;iqr
187;tulipäähippiäinen;1;1;255,7875214;255,79;0,00;255,79;255,79;255,79;0,00;255,79;255,7875214;255,79;255,79;0,00
201;puukiipijät;1;1;235,3859253;235,39;0,00;235,39;235,39;235,39;0,00;235,39;235,3859253;235,39;235,39;0,00
222;hömötiainen × lapintiainen;1;1;210,9716034;210,97;0,00;210,97;210,97;210,97;0,00;210,97;210,9716034;210,97;210,97;0,00
175;pikkusieppo;29;29;79,25;303,37;224,11;5629,43;194,12;185,46;64,38;79,25;79,25;148,34;245,10;96,77
180;kanahaukka (alalaji gentilis);1;1;165,2255707;165,23;0,00;165,23;165,23;165,23;0,00;165,23;165,2255707;165,23;165,23;0,00
195;idänuunilintu;13;13;9,39;293,14;283,74;2079,52;159,96;175,33;79,21;9,39;9,39;104,69;209,42;104,73
8;hippiäinen;376;359;0,00;354,92;354,92;54432,47;144,77;142,78;77,85;0,67;0,00;94,62;193,35;98,73
82;peukaloinen;353;347;0,00;357,88;357,88;50821,14;143,97;144,19;76,40;0,02;0,00;90,73;198,19;107,46
69;sirittäjä;190;188;0,00;318,41;318,41;27312,49
@mikkohei13
mikkohei13 / weekly_species_charts.py
Created June 1, 2023 08:34
Script reads laji.fi citatable data file, and creates Excel file and a line chart of weekly species distribution.
import pandas as pd
import matplotlib.pyplot as plt
# Load the csv file
df = pd.read_csv('rows_HBF.75704.tsv', sep='\t')
# Remove those without a day of year
df = df.dropna(subset=['Gathering.Conversions.DayOfYearBegin'])
@mikkohei13
mikkohei13 / weekly_species_heatmaps.py
Created June 1, 2023 08:39
Script reads laji.fi data file, and a heatmap of weekly species distribution.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
rarity_threshold = 100
# Read datafile that has number of observations for each species
df = pd.read_csv('species_rarity.csv', sep='\t')