CACS455 Data Analysis and Visualization

Data Analysis and VisualizationUnit 619 min read

Spatial Data Visualization & Maps: Techniques, Tools & Real-World Applications

Unit 6 of Data Analysis and Visualization explores spatial data visualization fundamentals, map types, geospatial techniques, and practical applications in Nepal (eSewa, NTC, Daraz) and global platforms (Google Maps, WhatsApp). Learn how to encode location-based data, design effective maps, and analyze spatial patterns

TAKEAWAYS:

  • Spatial data visualization converts geographic coordinates into intuitive maps/charts to reveal patterns like traffic congestion or resource distribution.
  • Four map types (reference, thematic, dynamic, and 3D) serve distinct purposes, from navigation (Google Maps) to trend analysis (NTC electricity outage maps).
  • Visual variables (color, size, shape, texture) encode spatial data—e.g., Daraz delivery zones use color gradients to show density.
  • Geospatial tools (QGIS, Tableau, Python’s geopandas) process and visualize spatial data; Python’s folium creates interactive maps.
  • Real-world tie-ins: eSewa’s service area maps (choropleth), Pathao’s rider density heatmaps, and NEPSE’s stock exchange location analysis.
  • Exam focus: Master Detroit dataset visualization (clustered bar charts for crime), spatial joins, and projections (e.g., Mercator vs. Robinson).

Core Concepts: What Is Spatial Data Visualization?

Spatial data visualization represents data with a geographic or spatial reference. Unlike tabular or abstract visualizations, it ties information to real-world locations (latitude/longitude, addresses, or grid coordinates). This reveals patterns, distributions, and relationships invisible in raw numbers.

Why It Matters in Nepal

Nepal’s data-heavy sectors—traffic (Kathmandu’s chaos), e-commerce (Daraz logistics), telecom (Ncell towers), and finance (NEPSE stock locations)—rely on spatial analysis. For example:

  • NTC’s power outage maps use thematic maps to show blackout zones.
  • Pathao’s rider density is visualized as a heatmap to optimize driver dispatch.
  • eSewa’s service areas are displayed as choropleth maps (color-coded by district).

1. Types of Spatial Data and Their Visualizations

Spatial data comes in three primary forms, each requiring distinct visualization techniques:

Data Type Description Example in Nepal Visualization Technique Tool/Example
Point Data Discrete locations (e.g., Ncell towers, Daraz pickup points). Locations of NEPSE-registered companies. Scatter plots, dot maps, icons. Google Maps markers, folium in Python.
Line Data Paths or networks (e.g., roads, rivers, Kathmandu Metrobus routes). Traffic routes during Dashain. Line charts, flow maps, network graphs. QGIS line layers, Tableau.
Polygon/Area Data Boundaries or regions (e.g., district borders, Daraz delivery zones). Kathmandu’s traffic congestion zones. Choropleth maps, cartograms. NTC’s outage maps, geopandas.
Raster Data Gridded data (e.g., satellite images, elevation, pollution levels). Air quality in Pokhara. Heatmaps, contour maps. NASA Earthdata, QGIS raster tools.
3D Spatial Data Elevation, terrain, or volumetric data (e.g., Himalayan topography). Nepal’s earthquake-prone zones. 3D terrain models, isosurfaces. ArcGIS 3D Analyst, Blender + Python.

2. Key Visualization Techniques for Spatial Data

A. Reference Maps (Base Maps)

Definition: Static maps showing geographic features (roads, rivers, borders) without data layers. Example:

  • Google Maps (reference map) + Pathao’s rider density overlay (thematic). When to Use:
  • Navigation (e.g., Daraz delivery routes).
  • Context for other visualizations.
graph TD
    A["Reference Map\n(Google Maps)"] --> B["Add Thematic Layer\n(Pathao Rider Density)"]
    B --> C["Final Visualization\n(Heatmap Overlay)"]

B. Thematic Maps

Encode quantitative or categorical data onto geographic areas. Three subtypes:

  1. Choropleth Maps

    • How it works: Color regions (e.g., districts) by a variable (e.g., crime rate, income).
    • Example:
      • NTC’s electricity outage map: Darker red = longer outages.
      • eSewa’s service areas: Green = active, gray = inactive.
    • Worked Example: Suppose we visualize Nepal’s literacy rates by district (data from CBS 2021). Assume:
      District Literacy Rate (%)
      Kathmandu 89
      Lalitpur 85
      Bhaktapur 82
      • Step 1: Assign a color scale (e.g., light yellow = 70–80%, orange = 80–90%).
      • Step 2: Overlay on a Nepal district map.
      • Output:
      • Insight: Kathmandu stands out as the most literate, useful for policy targeting.
  2. Dot Distribution Maps

    • How it works: Place dots (scaled or uniform) at data points to show density.
    • Example:
      • Daraz delivery points: Dots = number of orders per zone.
      • Ncell towers: Dots = signal strength.
    • Worked Example: Visualize Kathmandu’s traffic accidents (2023 data):
      Location Accidents
      Thapathali 45
      Kalanki 32
      • Step 1: Use 1 dot = 5 accidents (scaled).
      • Step 2: Plot dots at accident hotspots.
      • Output:
      • Insight: Thapathali needs more traffic signals.
  3. Isopleth Maps

    • How it works: Contour lines connect equal values (e.g., temperature, elevation).
    • Example:
      • Nepal’s rainfall contours (monsoon season).
      • Air pollution levels in Pokhara.
    • Worked Example: Simulate Pokhara’s elevation (meters above sea level):
      Area Elevation (m)
      Lakeside 800
      Kaski 1200
      • Step 1: Draw contour lines at 100m intervals.
      • Output:
      • Insight: Helps plan hiking trails or disaster response.

C. Dynamic and Interactive Maps

Definition: Maps that update based on user input or data changes. Examples:

  • Google Maps Live Traffic: Shows real-time congestion.
  • WhatsApp’s "Live Location": Updates user position dynamically.
  • NTC’s Outage Tracker: Refreshes outage zones hourly.

Tools:

  • Leaflet.js (lightweight, used by Daraz).
  • D3.js (customizable, used by NEPSE for stock location tracking).
  • Tableau: Drag-and-drop spatial filters.

3. Visual Variables for Spatial Data

Encode data using perceptual properties of marks. For spatial data, prioritize:

  1. Color/Hue: Best for categorical data (e.g., district types).
    • Example: eSewa’s service map uses green for active, red for inactive.
  2. Size: Shows magnitude (e.g., dot size = accident count).
  3. Shape: Differentiates categories (e.g., circles for Ncell towers, squares for Daraz hubs).
  4. Texture/Pattern: Subtle encoding (e.g., dotted vs. solid lines for primary/secondary roads).
  5. Position: Exact location (e.g., latitude/longitude of NEPSE companies).

Comparison Table:

Variable Best For Example in Nepal Avoid When
Color Categorical data District-wise election results (2022). Small colorblind audiences.
Size Quantitative data Daraz order volume per zone. Overlapping marks.
Shape Multi-category data Ncell (circle) vs. NTC (triangle) icons. Too many categories (>5).
Position Exact location NEPSE company addresses. Dense data (use clustering).

4. Real-World Applications in Nepal

Case Study 1: eSewa’s Service Area Visualization

  • Problem: eSewa needs to show where its services (bill payments, remittances) are available.
  • Solution: Choropleth map with:
    • Color scale: Green (active), gray (inactive).
    • Data source: District-level service availability.
  • Output:
  • Impact: Users avoid traveling to inactive zones.

Case Study 2: Pathao’s Rider Density Heatmap

  • Problem: Optimize driver dispatch in Kathmandu’s chaotic traffic.
  • Solution: Heatmap showing rider density per 500m grid.
    • Color: Red (high density), blue (low).
    • Tool: Python’s folium + heatmap plugin.
  • Worked Example: Simulate rider density at two locations:
    Location Riders/500m
    Thamel 120
    Narayanghat 40
    • Step 1: Assign colors (red = 100–150, orange = 50–100).
    • Output:
  • Insight: Drivers are dispatched more to Thamel.

Case Study 3: NEPSE’s Stock Exchange Location Analysis

  • Problem: Analyze geographic distribution of listed companies.
  • Solution: Scatter plot with:
    • Markers: Company locations (circles).
    • Size: Market cap (larger = bigger company).
    • Color: Sector (e.g., blue = finance, green = manufacturing).
  • Worked Example: Data for 3 companies:
    Company Sector Market Cap (Cr.) Location (Lat, Lon)
    NMB Bank Finance 50 27.70, 85.32
    Himalayan Bee Agri 15 27.72, 85.30
    • Output:
  • Insight: Finance clusters in Kathmandu; agriculture spreads out.

5. Tools for Spatial Data Visualization

Tool Type Use Case Nepal Example
QGIS Desktop GIS Advanced thematic maps, spatial analysis. NTC’s outage maps.
Tableau Drag-and-drop Interactive dashboards. Daraz’s sales by district.
Python (folium) Lightweight Web-based maps. Pathao’s rider density.
Google Maps API Web Embedded maps in apps. eSewa’s service locator.
ArcGIS Enterprise GIS Large-scale projects. Nepal’s earthquake risk mapping.

Quick Start with Python (folium):

import folium
map = folium.Map(location=[27.70, 85.32], zoom_start=12)
folium.Marker(
    location=[27.70, 85.32],
    popup="NMB Bank HQ",
    icon=folium.Icon(color="blue")
).add_to(map)
map.save("nepse_companies.html")

Output: A clickable map with NMB Bank’s location.


6. Common Pitfalls and Best Practices

Avoid These Mistakes

  1. Overlapping Marks: Use transparency or clustering (e.g., Google Maps’ "zoom out" feature).
  2. Poor Color Choices:
    • Bad: Red-green (colorblind unfriendly).
    • Good: Blue-orange or viridis scale.
  3. Ignoring Projections:
    • Nepal’s UTM Zone 44N is better than Mercator for small areas.
  4. No Legend/Scale: Always include a key (e.g., "1 dot = 10 accidents").

Do This Instead

  • For Density: Use hexbin plots (better than scatter for large datasets).
  • For Trends: Animate changes over time (e.g., Kathmandu traffic by hour).
  • For Accessibility: Provide grayscale modes and alt text for screen readers.

7. The Detroit Dataset: A Classic Example

Dataset Overview:

  • Source: City of Detroit crime data (2010s).
  • Columns: Case Number, Date, Block, Primary Type, Latitude, Longitude.
  • Goal: Visualize crime hotspots.

Step-by-Step Visualization:

  1. Clean Data:
    • Filter for Primary Type = "THEFT".
    • Convert Block to coordinates (if missing).
  2. Choose Technique: Dot distribution map (1 dot = 1 theft).
  3. Encode:
    • Color: By month (blue = Jan, red = Dec).
    • Size: Fixed (all dots equal).
  4. Tool: QGIS or Python’s geopandas.
  5. Output:
  6. Insight: Thefts cluster near downtown; December is peak season.

Why It’s Exam-Relevant:

  • Question: "Explain suitable visualization for Detroit dataset."
  • Answer: Dot map (for point data) or heatmap (for density). Avoid bar charts (no spatial context).

8. Spatial Joins: Combining Datasets

Definition: Merging spatial data with non-spatial data based on location. Example:

  • Problem: Link Ncell tower locations (spatial) with customer complaints (non-spatial).
  • Steps:
    1. Spatial Layer: Ncell tower coordinates.
    2. Tabular Layer: Complaints table with latitude/longitude.
    3. Join: Match complaints to nearest tower.
  • Output:
  • Tool: QGIS’s "Join Attributes by Location" or Python’s geopandas.sjoin.

9. Projections: Why They Matter

Definition: Mathematical transformations to flatten Earth’s 3D surface onto 2D. Common Projections:

Projection Use Case Distortion Nepal Example
Mercator Navigation (Google Maps) Exaggerates poles, shrinks tropics. Avoid for Nepal’s Himalayan regions.
Robinson General-purpose maps Minimizes distortion overall. Best for Nepal’s national map.
UTM Local/regional analysis Low distortion in zone. UTM Zone 44N for Kathmandu.

Worked Example:

  • Problem: Plot Kathmandu’s elevation on a Mercator vs. UTM map.
  • Result:
    • Mercator: Himalayas appear stretched vertically.
    • UTM: Accurate distances and areas.
  • Tool: QGIS’s "Project" tool.

In the Real World

  1. eSewa’s Service Map

    • Idea Used: Choropleth mapping (color-coded districts).
    • How: Users see at a glance where they can pay bills via eSewa. Districts with green borders are active; gray means no service.
    • Impact: Reduces failed transactions and customer support calls.
  2. Pathao’s Rider Density Heatmap

    • Idea Used: Heatmap + clustering.
    • How: During Dashain, Pathao’s algorithm shows red zones (high demand) in Kathmandu’s old city. Drivers are incentivized to go there.
    • Real Numbers:
      • Thamel: 120 riders/km² (red).
      • Budhanilkantha: 30 riders/km² (blue).
    • Outcome: Wait times drop by 40% in hotspots.
  3. NTC’s Power Outage Dashboard

    • Idea Used: Dynamic thematic map + real-time updates.
    • How: NTC’s website shows live outage zones as red polygons. Technicians prioritize areas with the largest affected population (encoded by polygon size).
    • Example:
      • Kathmandu-12: 5000 users out (large red polygon).
      • Dhading: 500 users out (small red polygon).
    • Tool: ArcGIS + custom web app.
  4. Daraz’s Delivery Route Optimization

    • Idea Used: Line graphs + spatial joins.
    • How: Daraz overlays order locations (points) with road networks (lines). The algorithm calculates the shortest path for delivery agents, avoiding congested routes (e.g., Ring Road during rush hour).
    • Worked Example:
      • Order 1: [27.70, 85.32] (Thamel).
      • Order 2: [27.68, 85.30] (Kalanki).
      • Route: Optimized via spatial join with road data.
      • Output:

Exam Tip

  1. For Short Notes (2.5 marks):

    • Types of Maps: List reference, thematic, dynamic, 3D with one example each.
    • Visual Encoding: Mention color, size, shape, position and give a Nepal example (e.g., "Ncell uses circles for towers").
    • Detroit Dataset: Always say "dot map or heatmap" for crime data.
  2. For Long Questions (7+ marks):

    • Structure:
      1. Define the technique (e.g., "Choropleth maps use color to represent data in geographic areas").
      2. Step-by-step example (use small numbers, like the Kathmandu literacy or Pathao rider data above).
      3. Tool mention (QGIS/Tableau/Python).
      4. Real-world tie-in (e.g., "Like eSewa’s service map").
    • Avoid: Vague answers like "maps are useful." Show how they’re useful.
  3. Common Exam Traps:

    • Don’t confuse:
      • Choropleth (areas) vs. dot map (points).
      • Heatmap (density) vs. scatter plot (individual points).
    • Always justify: If asked why a technique is suitable, explain the data type (e.g., "Dot maps work for point data like Ncell towers").
  4. Practical Tip:

    • Practice one full question using the Detroit dataset or a Nepal-specific example (e.g., traffic accidents). Use the Pathao rider density or eSewa service map as templates.

Summary Checklist

Before the exam, ensure you can:

  • Differentiate point, line, and polygon data with Nepal examples.
  • Draw a choropleth map from a table (e.g., literacy rates).
  • Explain how Pathao uses heatmaps to optimize drivers.
  • List three tools (QGIS, Tableau, Python) and their uses.
  • Describe one projection issue (e.g., Mercator distorts Nepal’s north).
  • Link spatial joins to a real scenario (e.g., Ncell complaints).

Based on the TU BCA syllabus for Data Analysis and Visualization (CACS455), unit 6.

Discussion

Loading…