Add raw.mr_eez for USA EEZ, including territories

Author

Ben Best

1 MarineRegions.org

1.1 Fetching

Code
librarian::shelf(
  here, leaflet, leaflet.extras, # mapview, 
  marinesensitivity/msens, 
  sf, tibble,
  quiet = T)

source(here("libs/db.R")) # define: con

eez_url <- URLencode(
  "https://geo.vliz.be/geoserver/MarineRegions/wfs?service=WFS&version=1.0.0&request=GetFeature&typeNames=eez&cql_filter=sovereign1='United States'&outputFormat=SHAPE-ZIP")
eez_zip <- here("tmp/eez.zip")
eez_dir <- here("tmp/eez")
eez_shp <- here("tmp/eez/eez.shp")
download.file(eez_url, destfile = eez_zip, quiet = T)
unzip(eez_zip, exdir = eez_dir)

eez <- read_sf(eez_shp)
st_geometry(eez) = "geom" # rename
mapview::mapView(eez)

schema <- "raw"
table  <- "mr_eez"
field  <- "geom" 

st_write(
  eez,
  dsn           = con,
  layer         = Id(schema=schema, table = table),
  driver        = "PostgreSQL",
  layer_options = "OVERWRITE=true")

# enforce SRID so shows up in tile.marinesensivity.org
dbExecute(con, glue("SELECT UpdateGeometrySRID('{schema}','{table}','{field}',4326);"))

View of raw.mr_eez at tile.marinesensitivity.org