Skip to content

Data scraping from OpenStreetMap (OSM) and data visualization with Folium - Python / Jupyter Notebook.

Notifications You must be signed in to change notification settings

salmiah-ls/OpenStreetMap-data-scraping-and-Folium-visualization

Repository files navigation

OpenStreetMap (OSM) Data Scraping and Folium Visualization

OpenStreetMap

OpenStreetMap (OSM) is a free, open geographic database updated and maintained by a community of volunteers via open collaboration. Contributors collect data from surveys, trace from aerial imagery and also import from other freely licensed geodata sources.

Link to OpenStreetMap:
  • Map: https://www.openstreetmap.org/
  • Wiki: https://wiki.openstreetmap.org/
  • Folium

    folium builds on the data wrangling strengths of the Python ecosystem and the mapping strength of the leaflet.js library. Manipulate data with Python, then visualize it on a Leaflet map via folium. Link to folium:

  • https://python-visualization.github.io/folium/
  • https://pypi.org/project/folium/
  • Concept

    In this repository, I collect data of medical facilities (hospital, clinic, doctor, dentist, and pharmacy) in Bali province, Indonesia. The data contains 4 atrributes: name of the medical facility, type, and coordinates in latitude and longitude. The scraped data is saved in a csv file and then displayed in simple html page.

    Area of Interest: Bali Province, Indonesia

    Visualize the area of interest with library folium:


    Scraping data from OpenStreetMap (OSM)

    If we search keyword "hospital in Bali" in OpenStreetMap, the result will be like this:

    Here, I will collect data of medical facilities consisting clinics, dentists, doctors, hospitals, and pharmacies.

    Libraries, API and Query

    I use 3 libraries for scraping data:

    • pandas for manipulating and analyzing data,
    • requests to make and process HTTP requests,
    • json to parse JSON into dictionary or list.

    API link for OpenStreetMap: http://overpass-api.de/api/interpreter

    Query for searching medical-facilities in Bali, Indonesia:

    [out:json];
    (area['name:id'='Provinsi Bali'];
    node[amenity~'(clinic|dentist|doctors|hospital|pharmacy)'](area);
    );
    out;
    

    Output

    There are 2 output files from this project:

    1. A CSV file contains data of medical facilities in Bali.
    2. An HTML page contains map for visualizing the data.

    Since github can't render html page correctly, I put the final output of this code in my blog here.

    About

    Data scraping from OpenStreetMap (OSM) and data visualization with Folium - Python / Jupyter Notebook.

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published