Which Python library is commonly used for working with geospatial data and creating maps and geographic visualizations?

Pandas
Seaborn
Plotly
Geopandas

The correct answer is D. Geopandas.

Geopandas is a Python package that provides a geospatial extension to the Pandas library. It allows you to work with spatial data in a variety of ways, including reading and writing data, performing spatial analysis, and creating maps and geographic visualizations.

Pandas is a Python library that provides high-performance, easy-to-use data structures and data analysis tools for working with structured (tabular, multidimensional, potentially heterogeneous) and time series data.

Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive statistical graphics.

Plotly is a Python library for interactive, publication-quality graphs. It is built on top of Matplotlib, but provides a more user-friendly interface and a wider range of features.

Here are some examples of how Geopandas can be used:

  • Reading and writing spatial data: Geopandas can read and write data from a variety of spatial data formats, including Shapefiles, GeoJSON, and KML.
  • Performing spatial analysis: Geopandas provides a variety of tools for performing spatial analysis, such as finding the nearest neighbor, calculating the distance between two points, and finding the area of a polygon.
  • Creating maps and geographic visualizations: Geopandas can be used to create maps and geographic visualizations using Matplotlib, Plotly, or other visualization libraries.

Here is an example of how Geopandas can be used to create a map:

“`python
import geopandas as gpd
import matplotlib.pyplot as plt

Read a Shapefile of US counties

df = gpd.read_file(“counties.shp”)

Plot the counties on a map

plt.figure(figsize=(10, 10))
df.plot(c=”blue”, alpha=0.5)
plt.show()
“`

This code will create a map of the United States, with each county represented by a blue polygon.