Loading...

Geospatial Plots

General

Let’s begin by importing the dataset module of VerticaPy. It provides a range of datasets for both training and exploring VerticaPy’s capabilities.

import verticapy.datasets as vpd

Let’s utilize the World dataset to demonstrate geospatial capabilities.

import verticapy.datasets as vpd

world = vpd.load_world()

# We filter to select only the African continent
africa = world[world["continent"] == "Africa"]

Let’s use Africa Education dataset from the VerticaPy datasets. Data is also available here.

import verticapy as vp

# This dataset provides multiple scores of students in Africa.
africa_education = vpd.load_africa_education()

VerticaPy provides the option to create various types of geospatial plots, including scatter plots and heat maps. To leverage these capabilities, it’s important to have geospatial data stored within Vertica, specifically in either GEOMETRY or GEOGRAPHY data types. This data forms the foundation for generating insightful geospatial visualizations using VerticaPy.

Note

Currently, VerticaPy provides geospatial capabilities using Matplotlib and GeoPandas. We plan to expand these functionalities in the future by incorporating Plotly.

We can switch to using the matplotlib module.

vp.set_option("plotting_lib", "matplotlib")

VerticaPy offers a range of geospatial plots, including scatter plots for visualizing individual data points on a map, heat maps for displaying data density, and choropleth maps that shade regions based on variable values. These plots enable data analysts to gain actionable insights from geospatial data, whether it’s for understanding point distributions, identifying hotspots, or visualizing regional trends, making VerticaPy a valuable tool for location-based analysis and data-driven decision-making.

africa["geometry"].geo_plot(edgecolor = "black", color = "white")
Out[2]: <Axes: >
_images/plotting_matplotlib_geo_regular.png
africa["geometry"].geo_plot(edgecolor = "black", column = "pop_est")
Out[3]: <Axes: >
_images/plotting_matplotlib_geo_cmap.png
ax = africa["geometry"].geo_plot(color = "white", edgecolor = "black")

africa_education.scatter(
  columns = ["lon", "lat"],
  by = "country_long",
  ax = ax,
)

Out[5]: <Axes: xlabel='lon', ylabel='lat'>
_images/plotting_matplotlib_geo_scatter.png
ax = africa["geometry"].geo_plot(color = "white", edgecolor = "black")

africa_education.scatter(
  columns = ["lon", "lat"],
  size = "zmalocp",
  by = "country_long",
  ax = ax,
)

Out[7]: <Axes: xlabel='lon', ylabel='lat'>
_images/plotting_matplotlib_geo_bubble.png

Chart Customization

VerticaPy empowers users with a high degree of flexibility when it comes to tailoring the visual aspects of their plots. This customization extends to essential elements such as color schemes, text labels, and plot sizes, as well as a wide range of other attributes that can be fine-tuned to align with specific design preferences and analytical requirements. Whether you want to make your visualizations more visually appealing or need to convey specific insights with precision, VerticaPy’s customization options enable you to craft graphics that suit your exact needs.

Note

As geospatial plots encompass various chart types such as heatmaps and scatter plots, customization options vary between graphics. To tailor your visualization, please refer to the corresponding Chart Gallery for specific guidance on customization.