Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Visualizing Geographic Data | Data Analysis and Visualization for Media
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Journalists and Media

bookVisualizing Geographic Data

Geographic data plays a vital role in journalism, offering new ways to present and interpret information for your audience. By mapping crime reports, election results, or the locations of news sources, you can reveal patterns and stories that might otherwise go unnoticed. Visualizing geographic data helps readers quickly grasp the scale, spread, and connections between events, making your reporting more engaging and informative.

123456789101112131415161718192021
import matplotlib.pyplot as plt # Example dataset: news events with latitude and longitude news_events = [ {"title": "City Hall Protest", "lat": 40.7128, "lon": -74.0060}, {"title": "Downtown Fire", "lat": 40.7135, "lon": -74.0090}, {"title": "Riverfront Festival", "lat": 40.7150, "lon": -74.0030}, {"title": "Museum Opening", "lat": 40.7100, "lon": -74.0150} ] # Extract latitude and longitude lats = [event["lat"] for event in news_events] lons = [event["lon"] for event in news_events] plt.figure(figsize=(8, 6)) plt.scatter(lons, lats, c='red', marker='o') plt.title("Map of News Events") plt.xlabel("Longitude") plt.ylabel("Latitude") plt.grid(True) plt.show()
copy

Geographic visualizations like the scatter plot above allow you to display the locations of news events on a map, helping readers see where stories are happening. This context can highlight clusters of incidents, reveal underserved areas, or support investigative reporting by connecting events to their locations. By plotting latitude and longitude data, you give your audience a visual anchor for your stories, making complex information easier to digest.

1234567891011121314151617181920
import matplotlib.pyplot as plt # Reuse the news_events dataset lats = [event["lat"] for event in news_events] lons = [event["lon"] for event in news_events] titles = [event["title"] for event in news_events] plt.figure(figsize=(8, 6)) # Customize marker size and color plt.scatter(lons, lats, s=150, c='blue', marker='^', alpha=0.7) # Add labels to each point for lon, lat, title in zip(lons, lats, titles): plt.text(lon + 0.0005, lat + 0.0005, title, fontsize=9) plt.title("Customized Map of News Events") plt.xlabel("Longitude") plt.ylabel("Latitude") plt.grid(True) plt.show()
copy

1. Why are maps useful in news reporting?

2. What data is needed to plot events on a map?

3. Fill in the blank: To plot latitude and longitude points in matplotlib, use _ _ _.

question mark

Why are maps useful in news reporting?

Select the correct answer

question mark

What data is needed to plot events on a map?

Select the correct answer

question-icon

Fill in the blank: To plot latitude and longitude points in matplotlib, use _ _ _.

plt.plotplt.barplt.hist

Click or drag`n`drop items and fill in the blanks

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 6

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

bookVisualizing Geographic Data

Scorri per mostrare il menu

Geographic data plays a vital role in journalism, offering new ways to present and interpret information for your audience. By mapping crime reports, election results, or the locations of news sources, you can reveal patterns and stories that might otherwise go unnoticed. Visualizing geographic data helps readers quickly grasp the scale, spread, and connections between events, making your reporting more engaging and informative.

123456789101112131415161718192021
import matplotlib.pyplot as plt # Example dataset: news events with latitude and longitude news_events = [ {"title": "City Hall Protest", "lat": 40.7128, "lon": -74.0060}, {"title": "Downtown Fire", "lat": 40.7135, "lon": -74.0090}, {"title": "Riverfront Festival", "lat": 40.7150, "lon": -74.0030}, {"title": "Museum Opening", "lat": 40.7100, "lon": -74.0150} ] # Extract latitude and longitude lats = [event["lat"] for event in news_events] lons = [event["lon"] for event in news_events] plt.figure(figsize=(8, 6)) plt.scatter(lons, lats, c='red', marker='o') plt.title("Map of News Events") plt.xlabel("Longitude") plt.ylabel("Latitude") plt.grid(True) plt.show()
copy

Geographic visualizations like the scatter plot above allow you to display the locations of news events on a map, helping readers see where stories are happening. This context can highlight clusters of incidents, reveal underserved areas, or support investigative reporting by connecting events to their locations. By plotting latitude and longitude data, you give your audience a visual anchor for your stories, making complex information easier to digest.

1234567891011121314151617181920
import matplotlib.pyplot as plt # Reuse the news_events dataset lats = [event["lat"] for event in news_events] lons = [event["lon"] for event in news_events] titles = [event["title"] for event in news_events] plt.figure(figsize=(8, 6)) # Customize marker size and color plt.scatter(lons, lats, s=150, c='blue', marker='^', alpha=0.7) # Add labels to each point for lon, lat, title in zip(lons, lats, titles): plt.text(lon + 0.0005, lat + 0.0005, title, fontsize=9) plt.title("Customized Map of News Events") plt.xlabel("Longitude") plt.ylabel("Latitude") plt.grid(True) plt.show()
copy

1. Why are maps useful in news reporting?

2. What data is needed to plot events on a map?

3. Fill in the blank: To plot latitude and longitude points in matplotlib, use _ _ _.

question mark

Why are maps useful in news reporting?

Select the correct answer

question mark

What data is needed to plot events on a map?

Select the correct answer

question-icon

Fill in the blank: To plot latitude and longitude points in matplotlib, use _ _ _.

plt.plotplt.barplt.hist

Click or drag`n`drop items and fill in the blanks

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 6
some-alt