forked from IMERSS/howe-sound-mapping
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported cultural values grids and added new script for cultural valu…
…es Mollusca as sample
- Loading branch information
Showing
32 changed files
with
3,456 additions
and
15 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Map Galiano Island's marine animal diversity | ||
|
||
# Load libraries | ||
|
||
library(dplyr) | ||
library(leaflet) | ||
library(raster) | ||
library(reshape2) | ||
library(rjson) | ||
library(scales) | ||
library(sf) | ||
library(stringr) | ||
library(viridis) | ||
|
||
# Source dependencies | ||
|
||
source("scripts/utils.R") | ||
|
||
mx_diversityRowToOptions <- function (row) { | ||
return (list(mx_regionId = row$cell_id, mx_richness = row$richness)) | ||
} | ||
|
||
mx_cultural_map <- function (taxon) { | ||
title <- str_to_title(taxon); | ||
|
||
# Read gridded marine animal dataset | ||
|
||
gridded.records <- read.csv(str_glue("tabular_data/{taxon}_all_records_gridded.csv")) | ||
|
||
hulq <- read.csv("tabular_data/reintegrated-hulq.csv") | ||
hulqTaxa <- hulq$Taxon.name | ||
|
||
# Filter only those records with cultural values | ||
cultural.records <- gridded.records[gridded.records$scientificName %in% hulqTaxa, ] | ||
|
||
# Summarize species by grid cell and export to JSON file for viz | ||
|
||
culturalTaxa <- mx_griddedObsToHash(cultural.records) | ||
|
||
culturalData <- list(taxa = culturalTaxa, mapTitle = str_glue("Diversity for {title} with cultural values")) | ||
|
||
mx_writeJSON(culturalTaxa, str_glue("viz_data/Cultural-{taxon}PlotData.json")) | ||
|
||
# Load choropleth | ||
|
||
choropleth <- mx_read(str_glue("spatial_data/vectors/{taxon}_hulq_grid")) | ||
|
||
# Plot choropleth | ||
|
||
richness <- choropleth$richness | ||
t <- max(richness) | ||
values <- 0:t | ||
pal <- leaflet::colorNumeric(viridis_pal(option = "D")(t), domain = values) | ||
|
||
# Plot map | ||
|
||
culturalMap <- leaflet(options=list(mx_mapId="Cultural")) %>% | ||
fitBounds(-123.6, 48.85, -123.2917, 49.03) %>% | ||
addTiles(options = providerTileOptions(opacity = 0.5)) %>% | ||
addLegend(position = 'topright', | ||
pal = pal, | ||
bins = ifelse(t < 5, t, 5), | ||
values = values, | ||
title = "Richness", | ||
labels = values) | ||
|
||
# Draw the gridded data in a funny way so that richness, cell_id etc. can be tunnelled through options one at a time | ||
for (i in 1:nrow(choropleth)) { | ||
row <- choropleth[i,] | ||
culturalMap <- culturalMap %>% addPolygons(data = row, fillColor = pal(row$richness), fillOpacity = 0.4, weight = 0, | ||
popup = paste("Richness:", row$richness), | ||
popupOptions = popupOptions(closeButton = FALSE), | ||
options = mx_diversityRowToOptions(row)) | ||
} | ||
|
||
#Note that this statement is only effective in standalone R | ||
print(culturalMap) | ||
} |
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
Binary file not shown.
1 change: 1 addition & 0 deletions
1
spatial_data/vectors/crustacea_hulq_grid/crustacea_hulq_grid.prj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJCS["WGS_1984_UTM_Zone_10N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.47 KB
spatial_data/vectors/echinodermata_hulq_grid/echinodermata_hulq_grid.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions
1
spatial_data/vectors/echinodermata_hulq_grid/echinodermata_hulq_grid.prj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJCS["WGS_1984_UTM_Zone_10N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] |
Binary file added
BIN
+6.47 KB
spatial_data/vectors/echinodermata_hulq_grid/echinodermata_hulq_grid.shp
Binary file not shown.
Binary file added
BIN
+484 Bytes
spatial_data/vectors/echinodermata_hulq_grid/echinodermata_hulq_grid.shx
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJCS["WGS_1984_UTM_Zone_10N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJCS["WGS_1984_UTM_Zone_10N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJCS["WGS_1984_UTM_Zone_10N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.