This project demonstrates how to analyze and visualize geospatial data using Python, with a focus on interactive mapping and data-driven insights. The notebook walks through the process of importing, cleaning, and visualizing real-world datasets using the Folium library, which is designed for creating interactive maps in Jupyter environments.
- DV0101EN-Exercise-Generating-Maps-in-Python.ipynb: Main notebook containing all code, analysis, and visualizations.
- README.md: This documentation file.
The notebook begins by explaining the importance of geospatial data and its applications in real-world scenarios, such as crime analysis and migration studies. It introduces the Folium library, which leverages Leaflet.js for interactive mapping.
- San Francisco Police Department Incidents (2016): The notebook imports a public dataset containing anonymized crime reports from San Francisco. The data is cleaned and limited to the first 100 incidents for computational efficiency.
- Canadian Immigration Data (1980-2013): Another dataset is imported to analyze migration flows to Canada from various countries over three decades.
- World Map Visualization: Demonstrates how to create a basic world map and zoom into specific regions (e.g., Canada, Mexico) using latitude and longitude coordinates.
- Custom Map Styles: Explores different map tile styles (e.g., CartoDB dark_matter, positron) to enhance the visual appeal and clarity of the maps.
- Marker Maps: Plots the locations of crimes on a map of San Francisco using circle markers. Each marker represents an incident, with color and size indicating its properties.
- Pop-up Information: Adds interactive pop-ups to markers, displaying the category of each crime when hovered over.
- Marker Clustering: Groups markers into clusters to reduce visual clutter and highlight areas with high crime density. This helps identify crime hotspots and patterns across the city.
- World Choropleth Map: Uses a GeoJSON file to define country boundaries and overlays migration data as a choropleth map. Countries are shaded according to the total number of immigrants to Canada, with a color scale indicating intensity.
- Legend and Interactivity: The map includes a legend and interactive features, allowing users to explore migration trends by country and year.
- Crime Data Visualization: Mapping crime incidents helps city officials and researchers identify patterns, allocate resources, and develop targeted interventions. Clustering and pop-ups make the data more accessible and actionable.
- Migration Analysis: Choropleth maps provide a clear, comparative view of migration flows, highlighting countries with significant emigration to Canada. This informs policy decisions and sociological research.
- Map Styles and Interactivity: Different tile styles and zoom levels improve readability and user engagement, making the visualizations suitable for presentations and exploratory analysis.
- Open the notebook in Jupyter or VS Code with a Python kernel.
- Run the cells sequentially to install dependencies, import data, and generate visualizations.
- Use the provided "Trust this notebook" cell to enable interactive map rendering.
- Experiment with different datasets, map styles, and analysis techniques to gain deeper insights.
- Python 3.x
- Folium
- Pandas
- Numpy
Install dependencies with:
%pip install folium pandas numpy
- Data sources: San Francisco Open Data Portal, United Nations, IBM Skills Network
- Author: Alex Aklson
© IBM Corporation 2020. All rights reserved.
This README provides a comprehensive overview of the notebook, explaining the purpose and reasoning behind each analysis and visualization. For further details, refer to the code comments and markdown cells within the notebook.