adding plots with simplification
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 268 KiB |
Before Width: | Height: | Size: 304 KiB After Width: | Height: | Size: 304 KiB |
Before Width: | Height: | Size: 299 KiB After Width: | Height: | Size: 298 KiB |
Before Width: | Height: | Size: 307 KiB After Width: | Height: | Size: 306 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 199 KiB |
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 376 KiB After Width: | Height: | Size: 376 KiB |
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 332 KiB |
Before Width: | Height: | Size: 309 KiB After Width: | Height: | Size: 308 KiB |
Before Width: | Height: | Size: 311 KiB After Width: | Height: | Size: 310 KiB |
Before Width: | Height: | Size: 305 KiB After Width: | Height: | Size: 304 KiB |
|
@ -1103,6 +1103,16 @@ write.csv(forest_inventory_counts_merged, "derivedData/forest_inventory_counts_m
|
||||||
# TODO: Add ggplot overlaying all three wilderness area types with different colours for polygons + points of ecs with different colouration and colour intensity at 3 bins for dots within buffers at each level (0/50/500m)
|
# TODO: Add ggplot overlaying all three wilderness area types with different colours for polygons + points of ecs with different colouration and colour intensity at 3 bins for dots within buffers at each level (0/50/500m)
|
||||||
# Note: there seems to be a problem with ggplot rendering these shapefiles - as it takes well over 10 hours to plot currently even on the smaller sssi shapefile.
|
# Note: there seems to be a problem with ggplot rendering these shapefiles - as it takes well over 10 hours to plot currently even on the smaller sssi shapefile.
|
||||||
|
|
||||||
|
# Simplify geometries for plotting
|
||||||
|
|
||||||
|
sssi_simple <- sf::st_simplify(sssi_sf)
|
||||||
|
|
||||||
|
# Plot SSSI polygons with ECS points (using sp, for now)
|
||||||
|
|
||||||
|
plot(sssi_simple, col='#aaaaaa', border=0)
|
||||||
|
plot(ecs_sf, col = 'red', add=TRUE)
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@ require(sp) # needed for proj4string, deprecated by sf()
|
||||||
require(rgdal) # version version: 1.3-6
|
require(rgdal) # version version: 1.3-6
|
||||||
require(rgeos) # used for buffering below
|
require(rgeos) # used for buffering below
|
||||||
require(devtools)
|
require(devtools)
|
||||||
|
require(ggplot2)
|
||||||
|
|
||||||
setwd("~/Downloads/test")
|
# setwd("~/Downloads/test")
|
||||||
# load data
|
# load data
|
||||||
|
|
||||||
transition_wgs <- read.csv(text=getURL("https://zenodo.org/record/165519/files/SCCAN_1.4.csv"))
|
transition_wgs <- read.csv(text=getURL("https://zenodo.org/record/165519/files/SCCAN_1.4.csv"))
|
||||||
|
@ -23,16 +24,47 @@ unzip("SSSI_SCOTLAND_ESRI.zip")
|
||||||
|
|
||||||
unzip("National_Forest_Inventory_Woodland_Scotland_2017.zip")
|
unzip("National_Forest_Inventory_Woodland_Scotland_2017.zip")
|
||||||
|
|
||||||
sssi_sf <- st_read("SSSI_SCOTLAND.shp")
|
sssi_sf <- st_read("./data/SSSI_SCOTLAND.shp")
|
||||||
sssi_sp <- readOGR("./", "SSSI_SCOTLAND")
|
sssi_sp <- readOGR("./data", "SSSI_SCOTLAND")
|
||||||
|
|
||||||
forest_inventory_sf <- st_read("National_Forest_Inventory_Woodland_Scotland_2017.shp")
|
forest_inventory_sf <- st_read("./data/National_Forest_Inventory_Woodland_Scotland_2017.shp")
|
||||||
forest_inventory_sp <- readOGR("./", "National_Forest_Inventory_Woodland_Scotland_2017")
|
forest_inventory_sp <- readOGR("./data", "National_Forest_Inventory_Woodland_Scotland_2017")
|
||||||
|
|
||||||
|
# Test validity of geometry
|
||||||
|
|
||||||
|
rgeos::gIsValid(sssi_sp)
|
||||||
|
valid <- st_is_valid(sssi_sf)
|
||||||
|
valid[valid == FALSE]
|
||||||
|
|
||||||
|
# Alternative approach from stackexchange using simplified geometry
|
||||||
|
|
||||||
|
sssi_sp2 <- rgeos::gSimplify(sssi_sp, tol=3)
|
||||||
|
par(mfrow=c(1,2))
|
||||||
|
plot(sssi_sp[1,])
|
||||||
|
plot(sssi_sp2[1,])
|
||||||
|
|
||||||
|
system.time(
|
||||||
|
sssi_b1000 <- rgeos::gBuffer(sssi_sp2, width = 20, quadsegs = 30)
|
||||||
|
)
|
||||||
|
|
||||||
|
sssi_sf2 <- sf::st_simplify(sssi_sf)
|
||||||
|
system.time(
|
||||||
|
sssi_b1000 <- sf::st_buffer(sssi_sf2, dist = 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Render ggplot2 plot on simplified geometry
|
||||||
|
|
||||||
|
ggplot(sssi_sf2) + geom_sf(aes(fill = PA_CODE))
|
||||||
|
plot(sssi_sf2)
|
||||||
|
|
||||||
# First test out plots using spatialfeatures and spdf with core R
|
# First test out plots using spatialfeatures and spdf with core R
|
||||||
|
|
||||||
system.time(
|
system.time(
|
||||||
plot(sssi_sf)
|
plot(sssi_sf2)
|
||||||
|
)
|
||||||
|
|
||||||
|
system.time(
|
||||||
|
plot()
|
||||||
)
|
)
|
||||||
|
|
||||||
system.time(
|
system.time(
|
||||||
|
|