Helsingin kaupungilla on (ainakin) kaksi WFS-rajapintaa paikkatiedon jakamiseen: geoserver.hel.fi/geoserver/ows
ja kartta.hel.fi/ws/geoserver/avoindata/wfs
. Tässä katsauksessa käydään läpi rajapintojen sisältöä eri aluerajojen/-jakojen osalta.
1 Aluerajapinnat
1.1 Rajapinta: geoserver.hel.fi/geoserver/ows
Tämän rajapinnan aluejaot käsittävät sekä Helsingin, mutta etenkin koko pääkaupunkiseudun ja Uudenmaan muiden kuntien sisäisiä aluejakoja. Taulukkoon ja karttaan on otettu mukaan jaot, joiden nimi sisältää jonkin seuraavista alue|piiri|raja|kaupunginosa
sanoista, mutta EI sisällä mitään näistä viher|melu|vesi|meri|nuohous|katu|lento|teollisuus|suojelu|nimet|postinume|asuinal
. Kaikenkaikkiaan 109 aluejaosta 52 täyttävät nämä ehdot. Hoveroimalla osoitinta alueen päällä näet kerroksen tiedot!
if (FALSE){
library(ows4R)
<- WFSClient$new("http://geoserver.hel.fi/geoserver/ows",
wfs serviceVersion = "1.0.0",
logger = "INFO")
<- wfs$getCapabilities()
caps <- caps$findFeatureTypeByName("", exact = FALSE)
ft <- list()
data_lst if (length(ft) == 0) next()
for (i in 1:length(ft)){
<- tibble(name = ft[[i]]$getName(),
data_lst[[i]] title = ft[[i]]$getTitle())
}<- do.call(bind_rows, data_lst)
api_df01
# suodatetaan
# api_df01 <- readRDS("./api_df01.RDS")
<- api_df01[grepl("alue|piiri|raja|kaupunginosa", api_df01$name, ignore.case = T),]
apitmp <- apitmp[!grepl("viher|melu|vesi|meri|nuohous|katu|lento|teollisuus|suojelu|nimet|postinume|asuinal", apitmp$name, ignore.case = T),]
apitmp2 # print(apitmp2, n = 200)
saveRDS(apitmp2, "./api_df01.RDS")
<- list()
shapelist # rm(shape)
for (i in 1:nrow(apitmp2)){
if (!exists("shape")) rm(shape)
<- caps$findFeatureTypeByName(apitmp2$name[i], exact = TRUE)
ft try(shape <- ft$getFeatures())
if (!exists("shape")) next()
st_crs(shape) <- ft$getDefaultCRS()
# Jos ei yhtään riviä
if (nrow(shape) == 0) next()
# Jos rivejä mutta ei sf-objekti
if (!any(is(shape) %in% "sf")) next()
<- as.character(unique(sf::st_geometry_type(shape)))
geometry_type if (geometry_type == "CURVEPOLYGON") next()
if (geometry_type %in% "MULTISURFACE"){
<- st_cast(shape, "GEOMETRYCOLLECTION") %>%
shape st_collection_extract("POLYGON")
}<- as.character(unique(sf::st_geometry_type(shape)))
geometry_type # print(geometry_type)
# try(shape %>% select(1) %>% plot())
# if (geometry_type %in% "CURVEPOLYGON") next()
# if (F){
# espoo <- "+proj=tmerc +lat_0=0 +lon_0=25 +k=1 +x_0=25500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
# sf::st_crs(shape) <- espoo
# shape <- sf::st_transform(x = shape, crs = espoo)
# sf::st_crs(shape) <- "+init=epsg:3067"
# shape <- sf::st_transform(x = shape, crs = "+init=epsg:3067")
<- sf::st_transform(x = shape, crs = "+proj=longlat +datum=WGS84")
shape leaflet(shape) %>% addTiles() %>% addPolygons()
<- list("name" = apitmp2$name[i],
shapelist[[i]] "title" = apitmp2$title[i],
"shape" = shape,
"geometry_original" = geometry_type#,
# "geometry_converted" = geometry_type_new
)
}names(shapelist) <- seq_along(shapelist)
<- Filter(Negate(is.null), shapelist)
shapelist01 saveRDS(shapelist01, "./shapelist01.RDS")
}<- readRDS("./api_df01.RDS")
api_df01 ::datatable(api_df01) DT
<- readRDS("./shapelist01.RDS")
shapelist01 library(leaflet)
<- leaflet() %>%
lflet addTiles()
<- vector()
basegroups # for (ii in 32){
for (ii in 1:length(shapelist01)){
if (ii %in% c(32)) next()
# if (ii > 30) next()
<- shapelist01[[ii]]$shape
shape_wgs84 <- shapelist01[[ii]]$name
shape_name <- as.character(unique(sf::st_geometry_type(shape_wgs84)))
geotype if (geotype %in% "MULTISURFACE"){
<- st_cast(shape_wgs84, "GEOMETRYCOLLECTION") %>%
shape_wgs84 st_collection_extract("POLYGON")
}
<- shape_wgs84 %>% st_drop_geometry()
label_data
<- purrr::map(1:nrow(label_data), get_values, dat = label_data)
labs
<- lflet %>%
lflet addPolygons(data = shape_wgs84, group = shape_name, label = lapply(labs, HTML))
<- lflet %>%
lflet addPolygons(data = shape_wgs84, group = shape_name)
<- c(basegroups, shape_name)
basegroups
}%>% addLayersControl(baseGroups = basegroups) lflet