Skip to content

Commit

Permalink
fix #27 actieve haarden (WIP) + replace sp,rgdal,rgeos functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarewyck committed Aug 22, 2023
1 parent e906533 commit 2cdfa8e
Show file tree
Hide file tree
Showing 19 changed files with 22,613 additions and 46 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ alienSpecies/man/

# Large data files
alienSpecies/inst/extdata/full_timeseries.csv

# Tmp files for #27
/verspaVelutina/
8 changes: 3 additions & 5 deletions alienSpecies/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: alienSpecies
Type: Package
Title: Portal for alien and invasive species indicators
Version: 0.0.3
Version: 0.0.4
Date: 2023-02-01
Author: Machteld Varewyck
Maintainer: Machteld Varewyck <machteld.varewyck@openanalytics.eu>
Expand All @@ -16,14 +16,12 @@ Imports:
INBOtheme (<= 0.5.9),
jsonlite,
leaflet,
leaflet.extras,
plotly,
rgbif,
rgdal,
rgeos,
shiny,
shiny,
shinycssloaders,
sf,
sp,
tidyverse,
trias (>= 2.0.3),
webshot
Expand Down
12 changes: 8 additions & 4 deletions alienSpecies/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export(loadTabularData)
export(mapCube)
export(mapCubeServer)
export(mapCubeUI)
export(mapHeat)
export(mapHeatServer)
export(mapHeatUI)
export(mapOccurrence)
export(mapRegions)
export(mapRegionsServer)
Expand Down Expand Up @@ -92,11 +95,15 @@ importFrom(htmltools,div)
importFrom(htmlwidgets,saveWidget)
importFrom(jsonlite,toJSON)
importFrom(leaflet,`%>%`)
importFrom(leaflet,addCircleMarkers)
importFrom(leaflet,addLegend)
importFrom(leaflet,addMarkers)
importFrom(leaflet,addScaleBar)
importFrom(leaflet,addTiles)
importFrom(leaflet,leaflet)
importFrom(leaflet,leafletOutput)
importFrom(leaflet,markerClusterOptions)
importFrom(leaflet.extras,addHeatmap)
importFrom(plotly,ggplotly)
importFrom(plotly,layout)
importFrom(plotly,plotlyOutput)
Expand All @@ -106,17 +113,14 @@ importFrom(rgbif,occ_download_get)
importFrom(rgbif,occ_download_import)
importFrom(rgbif,occ_download_wait)
importFrom(rgbif,pred)
importFrom(rgdal,readOGR)
importFrom(rgeos,gUnaryUnion)
importFrom(sf,st_as_sf)
importFrom(sf,st_drop_geometry)
importFrom(sf,st_read)
importFrom(sf,st_transform)
importFrom(sf,st_union)
importFrom(shiny,runApp)
importFrom(shiny,singleton)
importFrom(shinycssloaders,withSpinner)
importFrom(sp,CRS)
importFrom(sp,spTransform)
importFrom(stats,aggregate)
importFrom(utils,read.csv)
importFrom(utils,read.table)
Expand Down
9 changes: 3 additions & 6 deletions alienSpecies/R/data_createOccupancy.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#' @return TRUE if creation succeeded
#'
#' @author mvarewyck
#' @importFrom rgdal readOGR
#' @importFrom sp spTransform CRS
#' @importFrom sf st_read
#' @importFrom data.table as.data.table
#' @export
Expand All @@ -21,16 +19,15 @@ createOccupancyCube <- function(dataDir = "~/git/alien-species-portal/data/trend

# geojson: https://zenodo.org/record/3835756#.Yoc5oLxBw5m
data_t0 <- lapply(seq(2016, 2020, by = 2), function(iYear) {
dataYear <- rgdal::readOGR(dsn = file.path(dataDir, paste0("ias_belgium_t0_", iYear, ".geojson")), verbose = TRUE)
dataYear <- sp::spTransform(dataYear, sp::CRS("+proj=longlat +datum=WGS84"))
dataYear <- sf::st_read(file.path(dataDir, paste0("ias_belgium_t0_", iYear, ".geojson")), quiet = TRUE)
# inconsistent colnames over the years
colnames(dataYear@data) <- c("cellcode", "reference", "data_partn", "accepted", "species", "notes")
colnames(dataYear) <- c("cellcode", "reference", "data_partn", "accepted", "species", "notes")
dataYear$year <- iYear
dataYear
})
# sp::plot(data_t0[[1]])

data_t0_all <- do.call(rbind, data_t0)@data
data_t0_all <- do.call(rbind, data_t0)
data_t0_all$source <- "t0"
# table(data_t0_all)

Expand Down
5 changes: 1 addition & 4 deletions alienSpecies/R/data_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#' @return list with sf objects
#'
#' @author mvarewyck
#' @importFrom rgdal readOGR
#' @importFrom sp spTransform
#' @importFrom sf st_read
#' @export
readShapeData <- function(extension = c(".gpkg", ".shp", ".geojson"),
Expand All @@ -29,8 +27,7 @@ readShapeData <- function(extension = c(".gpkg", ".shp", ".geojson"),

toReturn <- lapply(shapeFiles, function(iFile) {

spatialData <- readOGR(dsn = file.path(dataDir, iFile), verbose = FALSE)
sp::spTransform(spatialData, CRS("+proj=longlat +datum=WGS84"))
sf::st_read(file.path(dataDir, iFile), layer = gsub(extension, "", iFile), quiet = TRUE)

})

Expand Down
Loading

0 comments on commit 2cdfa8e

Please sign in to comment.