Last active
May 5, 2019 08:43
-
-
Save patperu/8f54d7d38d7baa5e78534430c1bcd48d to your computer and use it in GitHub Desktop.
Read WFS data from the geodata portal (FIS-Broker) of Berlin (Population density) via 'sf'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: | |
# - https://fbinter.stadt-berlin.de/fb/index.jsp?loginkey=zoomStart&mapId=wmsk_06_06ewdichte2017@senstadt | |
# - https://fbinter.stadt-berlin.de/fb/berlin/service.jsp?id=s06_06ewdichte2017@senstadt&type=WFS | |
library(glue) | |
library(sf) | |
sf_fisbroker <- function(x) { | |
u1 <- glue("http://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/{x}") | |
u2 <- glue("?service=wfs&version=2.0.0&request=GetFeature&TYPENAMES={x}") | |
url <- paste0(u1, u2) | |
print(url) | |
s <- sf::read_sf(url) | |
sf::st_crs(s) <- 25833 | |
s <- sf::st_transform(s, 4326) | |
s | |
} | |
z <- sf_fisbroker("s06_06ewdichte2017") | |
#> z | |
# Simple feature collection with 14730 features and 5 fields | |
#geometry type: MULTIPOLYGON | |
#dimension: XY | |
#bbox: xmin: 13.09301 ymin: 52.33963 xmax: 13.74157 ymax: 52.66074 | |
#epsg (SRID): 4326 | |
#proj4string: +proj=longlat +datum=WGS84 +no_defs | |
## A tibble: 14,730 x 6 | |
# gml_id EW2017 FLALLE EW_HA2017 TYPKLAR geometry | |
# <chr> <int> <dbl> <dbl> <chr> <MULTIPOLYGON [°]> | |
# 1 s06_06ewdichte201~ 500 10256. 488. Entkernte Blockrandbebauung, Lücke~ (((13.34376 52.48248, 13.34383 52.48199, 13.3439~ | |
# 2 s06_06ewdichte201~ 489 10305. 475. Geschlossene Blockbebauung, Hinter~ (((13.34525 52.481, 13.34621 52.48101, 13.34621 ~ | |
# 3 s06_06ewdichte201~ 727 11640. 625. Geschlossene Blockbebauung, Hinter~ (((13.3465 52.48059, 13.34804 52.48177, 13.34668~ | |
# 4 s06_06ewdichte201~ 296 14027. 211. Entkernte Blockrandbebauung, Lücke~ (((13.34122 52.47999, 13.34243 52.479, 13.34295 ~ | |
# 5 s06_06ewdichte201~ 282 7264. 388. Geschlossene Blockbebauung, Hinter~ (((13.34313 52.48067, 13.34341 52.48005, 13.3437~ | |
# 6 s06_06ewdichte201~ 432 6630. 652. Blockrandbebauung mit Großhöfen (1~ (((13.34382 52.4792, 13.34392 52.47898, 13.34426~ | |
# 7 s06_06ewdichte201~ 268 5894 455. Geschlossene Blockbebauung, Hinter~ (((13.34519 52.47962, 13.3462 52.48038, 13.34621~ | |
# 8 s06_06ewdichte201~ 936 21202. 441. Geschlossene Blockbebauung, Hinter~ (((13.34459 52.47861, 13.34502 52.47847, 13.3456~ | |
# 9 s06_06ewdichte201~ 500 9842. 508. Dichte Blockbebauung, geschlossene~ (((13.3473 52.48076, 13.34739 52.48043, 13.34955~ | |
#10 s06_06ewdichte201~ 499 9300. 537. Dichte Blockbebauung, geschlossene~ (((13.34744 52.48025, 13.3476 52.4797, 13.34962 ~ | |
## ... with 14,720 more rows | |
## Save the sf object in different formats | |
sf::st_write(z, "s06_06ewdichte2017.geojson") | |
sf::st_write(z, "s06_06ewdichte2017.sqlite") | |
sf::st_write(z, "s06_06ewdichte2017.shp") | |
sf::st_write(z, "s06_06ewdichte2017.kml") | |
sf::st_write(z, "s06_06ewdichte2017.gml") | |
sf::st_write(z, "s06_06ewdichte2017.xlsx") # no geometry | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment