Radabstellanlagen Wien

(ns at.birdview.bike-parking
  (:require [clojure.data.json :as json]
            [clojure.java.io :as io]))


(def bike-parking-json-url "https://data.wien.gv.at/daten/geo?service=WFS&request=GetFeature&version=1.1.0&typeName=ogdwien:FAHRRADABSTELLANLAGEOGD&srsName=EPSG:4326&outputFormat=json")

;; store input data for reference in results
(io/copy (io/reader bike-parking-json-url)
         (io/file "/results/input.json"))

(def data (-> bike-parking-json-url
                           io/reader
                           json/read))
at.birdview.bike-parking/data
input.json
(def by-district
  (->> (get data "features")
     (group-by #(get-in % ["properties" "BEZIRK"]))
     (reduce-kv (fn [m k v]
                  (if k
                    (assoc m k
                           (reduce
                            (fn [acc p]
                              (+ acc (get-in p ["properties" "ANZAHL"])))
                            0
                            v))
                    m))
                {})
     (into (sorted-map-by <))))

(with-open [file (-> "/results/by-district.json" io/file io/writer)]
  (json/write by-district file))

by-district
23{1421023952329014181651370619207217181767944121026171174212106813940141062151745161470171001181208198512016573 more…}
by-district.json
(.plot js/Nextjournal
       [{:type "bar"
         :x (map #(str % ". Bezirk")
                 (keys by-district))
         :y (vals by-district)}]
       {:title "Radabstellplätze Wien per Bezirk"
        :margin {:l 50 :t 50}
        :sizex 1
        :sizing "stretch"})
© 2018 Nextjournal GmbH