-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstation_ownership.R
52 lines (39 loc) · 1.73 KB
/
station_ownership.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
38
39
40
41
42
43
44
45
46
47
48
49
library(magrittr)
library(tidyverse)
library(arcgislayers)
con <- DBI::dbConnect(drv = RPostgres::Postgres(),
host = "fcfc-mesonet-db2.cfc.umt.edu",
dbname = "mesonet",
user = "mesonet",
password = keyring::key_get("mesonet-db"))
stations <-
dplyr::tbl(con, RPostgres::Id(schema = "data", table = "stations")) %>%
dplyr::select(station, name, sub_network, status, longitude, latitude) %>%
dplyr::collect() %>%
dplyr::filter(!is.na(longitude)) %>%
sf::st_as_sf(coords = c("longitude", "latitude"),
crs = 4326)
stations %>%
dplyr::group_by(sub_network, status) %>%
sf::st_drop_geometry() %>%
dplyr::count()
esri_stations <-
prepare_spatial_filter(stations$geometry, predicate = "intersects", crs = 4326)
mt_cadastral <-
arcgislayers::arc_open(
"https://gisservicemt.gov/arcgis/rest/services/MSDI_Framework/Parcels/MapServer/0"
)
parcels <-
httr::modify_url("https://gisservicemt.gov/arcgis/rest/services/MSDI_Framework/Parcels/MapServer/0/query",
query = list(where = "1=1",
geometry = esri_stations$geometry,
geometryType = esri_stations$geometryType,
spatialRel = esri_stations$spatialRel,
outFields = "PARCELID,PropertyID,PropType,OwnerName,CareOfTaxpayer,OwnerAddress1,OwnerAddress2,OwnerAddress3,OwnerCity,OwnerState,OwnerZipCode,AssessmentCode,LegalDescriptionShort,LevyDistrict",
returnGeometry = TRUE,
f = "geojson")) %>%
sf::read_sf() %>%
sf::st_make_valid()
sf::st_join(stations, parcels) %>%
dplyr::select()
mapview::mapview(parcels) + mapview::mapview(stations)