-
Notifications
You must be signed in to change notification settings - Fork 1
/
data_units.R
37 lines (29 loc) · 1.07 KB
/
data_units.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library(sf)
library(tidyverse)
library(ggplot2)
# MSFD Marine regions and subregions
# https://dd.eionet.europa.eu/vocabulary/msfd/regions/view
# https://github.com/ices-taf/eea-topic-centre-wise6-dataflow/issues/2
unitsFile <- "Input/MSFD_Publication_20181129_incl_WISE6_units.gdb"
st_layers(unitsFile)
# MSFD Marine regions and subregions
# North East Atlantic Ocean (ATL) modified (cut against other units instead of coast with overlaps)
# Unwanted 'region' removed
units <- st_read(unitsFile, layer = "EuropeSeas_20181129_WISE6_units")
ggplot() + geom_sf(data = units) + coord_sf()
# Rename columns
units %>%
rename(Code = Id, Region = name)
# Identify invalid geometries
st_is_valid(units)
# Make geometries valid by doing the buffer of nothing trick
units <- sf::st_buffer(units, 0.0)
# Transform projection into ETRS_1989_LAEA
#units <- st_transform(units, crs = 3035)
# Write to database
# st_write(
# units,
# dsn = "MSSQL:server=SQL08;database=OceanCSI_19802019;trusted_connection=yes;",
# layer = "SeaRegion1",
# layer_options = c("LAUNDER=NO", "GEOM_NAME=GEOM")
# )