This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(readr) | |
library(rgbif) | |
library(taxize) | |
library(CoordinateCleaner) | |
# 4 Odonata scientific names | |
name_list = | |
c( | |
"Cordulegaster charpentieri Kolenati, 1846", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys.process._ | |
import org.apache.spark.sql.SaveMode | |
val save_table_name = "ocean_export_france" | |
df_export. | |
write.format("csv"). | |
option("sep", "\t"). | |
option("header", "false"). // add header later | |
mode(SaveMode.Overwrite). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# null island figure | |
library(ggplot2) | |
library(sf) | |
library(rnaturalearth) | |
worldmap = ne_countries(scale = 'medium', type = 'map_units',returnclass = 'sf') | |
cropped = st_crop(worldmap, xmin = -20, xmax = 45,ymin = -35, ymax = 40) | |
point_data = data.frame(long=0,lat=0,NAME="null island") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sqlContext = new org.apache.spark.sql.SQLContext(sc) | |
val df_occ = sqlContext.sql("SELECT * FROM prod_h.occurrence"). | |
select( | |
"gbifid", | |
"datasetkey", | |
"occurrenceid", | |
"kingdom", | |
"phylum", | |
"class", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val table_name = "gridded_datasets.tsv" | |
val df = spark.read. | |
option("sep", "\t"). | |
option("header", "true"). | |
option("inferSchema", "true"). | |
csv(table_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
library(rnaturalearth) | |
worldmap = ne_countries(scale = 'medium', type = 'map_units',returnclass = 'sf') | |
zoom_to = c(70, 40) # Berlin | |
zoom_level = 1 | |
lon_span = 360 / 2^zoom_level | |
lat_span = 180 / 2^zoom_level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gbifID datasetKey occurrenceID kingdom phylum class order family genus species infraspecificEpithet taxonRank scientificName verbatimScientificName verbatimScientificNameAuthorship countryCode locality stateProvince occurrenceStatus individualCount publishingOrgKey decimalLatitude decimalLongitude coordinateUncertaintyInMeters coordinatePrecision elevation elevationAccuracy depth depthAccuracy eventDate day month year taxonKey speciesKey basisOfRecord institutionCode collectionCode catalogNumber recordNumber identifiedBy dateIdentified license rightsHolder recordedBy typeStatus establishmentMeans lastInterpreted mediaType issue | |
2988338871 50c9509d-22c7-4a22-a47d-8c48425ef4a7 https://www.inaturalist.org/observations/64782270 Animalia Arthropoda Insecta Odonata Calopterygidae Mnais Mnais mneme SPECIES Mnais mneme Ris, 1916 Mnais mneme VN Cao Bằng PRESENT 28eb1a3f-1c15-4a95-931a-4af90ecb574d 22.616667 105.866667 2002.0 2018-06-05T10:26:00 5 6 2018 1427284 1427284 HUMAN_OBSERVATION iNaturalist Observatio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql.Column | |
import org.apache.spark.sql.catalyst.expressions.aggregate.ApproximatePercentile | |
import org.apache.spark.sql.functions.lit | |
import org.apache.spark.SparkContext | |
import org.apache.spark.mllib.random.RandomRDDs._ | |
import org.apache.spark.sql.functions._ | |
import org.apache.spark.sql.functions.sqrt | |
import org.apache.spark.sql.expressions.Window | |
val sqlContext = new org.apache.spark.sql.SQLContext(sc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rjack in scala spark | |
import org.apache.spark.sql.Column | |
import org.apache.spark.sql.catalyst.expressions.aggregate.ApproximatePercentile | |
import org.apache.spark.sql.functions.lit | |
import org.apache.spark.SparkContext | |
import org.apache.spark.mllib.random.RandomRDDs._ | |
import org.apache.spark.sql.functions._ | |
import org.apache.spark.sql.functions.sqrt | |
import org.apache.spark.sql.expressions.Window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geotidy) | |
library(sf) | |
x = "POLYGON((-111.10988792012594 45.01964833538098,-104.12258323262594 45.01964833538098,-104.12258323262594 40.97209835959628,-111.10988792012594 40.97209835959628,-111.10988792012594 45.01964833538098))" | |
geotidy::st_geomfromtext(x, crs = 4326) %>% | |
sf::st_area() %>% | |
units::set_units(km^2) # approximate area of wyoming | |
# 256028.3 [km^2] |