Choropleth Map with OpenStreetMap Data

My goal is to get the so-called "choropleth map" (I think) of the zip code areas in Germany. I found the python "folium" package, but it seems that the .json file is required as the input file:

https://github.com/python-visualization/folium

In OpenStreetMap, I only see shp.zip and .osm.pbf files. Inside the shp.zip archive, I find all kinds of file endings that I have never heard of, but not a .json file. How to use data from OpenStreetMap to submit folia? Am I running in the wrong direction?

EDIT / SOLUTION : I went to https://overpass-turbo.eu/ (which extracts data from openstreetmap through a specific QL Language Query Language) and runs the following code:

[timeout:900];
area[name="Deutschland"][admin_level=2][boundary=administrative]->.myarea;
rel(area.myarea)["boundary"="postal_code"];
out geom;

You can "export to geojson", but in my case it did not work, because there is too much data that cannot be processed inside the browser. But the export of raw data works. So I did this and then used "osmtogeojson" to get the format you want. After that, I was able to transfer my openstreetmap data to folium, as described in the folium tutorial.

+4
source share
2 answers

, OSM (.osm .pbf) (geo) json. osmtogeojson. GeoJSON OSM.

0

choropleth map, :

  • , . .json , , . OSM (.shp) , .geojson. , ogr2ogr :

    ogr2ogr -f GeoJSON -t_srs EPSG: 4326 -simplify 1000 [name].geojson [name].shp

    : -:

  • (, .csv). , ZIP- .

  • , , Follium choropleth.

:

:

import folium
import pandas as pd

osm = folium.Map([43, -100], zoom_start=4)

osm.choropleth(
    geo_str = open('US_states.json').read(),
    data = pd.read_csv("US_unemployment.csv"),
    columns = ['State', 'Unemployment'],
    key_on = 'feature.id',
    fill_color = 'YlGn',
)

:

enter image description here

0

Source: https://habr.com/ru/post/1683941/


All Articles