This notebook serves as a technical introduction for developers and data analysts who have subscribed to the Places Insights Sample Datasets.
Its primary purpose is to demonstrate how to query, aggregate, and visualize Google Maps Platform Places Insights data within a BigQuery environment. By running this notebook, you will learn how to transition from raw dataset subscriptions to actionable geospatial insights using Standard SQL and Python.
- Places Insights: A BigQuery dataset providing aggregated counts and attributes for Points of Interest (POIs).
- BigQuery: Used to execute Standard SQL and Geospatial functions (such as
ST_DWITHINandST_GEOGPOINT) on the dataset. - H3 (Hierarchical Geospatial Indexing): A hexagonal grid system used by the Places Insights SQL functions to normalize spatial data.
- Google Maps 2D Tiles: Provides the high-resolution roadmap imagery used for the visualization layer.
- Python Libraries:
See Google Maps Platform Pricing and BigQuery Pricing for costs associated with running this notebook.
-
Configuration: The notebook initializes the environment based on your selection of a Sample City (e.g., "New York City", "Tokyo", "London"). It automatically maps your selection to the correct Analytics Hub Dataset ID and geographic coordinates.
-
Direct Query Analysis (Radius Search): We demonstrate how to count places that match specific criteria, such as
primary_type,business_status, and boolean attributes likeallows_dogs, within a set radius. We utilize theWITH AGGREGATION_THRESHOLDclause to compare amenity density across multiple neighborhoods programmatically. -
H3 Density Analysis (Grid Search): We utilize the predefined
PLACES_COUNT_PER_H3SQL function to retrieve a normalized grid of place counts. This allows us to visualize macro-level commercial density across the entire city without manually defining boundaries. -
Visualization: We render the query results on interactive maps using Folium and Google Maps 2D Tiles:
- Marker Map: Visualizes the "Direct Query" results, identifying hotspots based on amenity concentration.
- Choropleth Map: Overlays the H3 hexagonal grid to visualize the "Function Query" density results.
-
Prerequisites:
- A Google Cloud Project with the BigQuery API and Map Tiles API enabled.
- A subscription to at least one of the Places Insights Sample Datasets via Analytics Hub.
-
Set Up Secrets: Configure the following keys in the Colab "Secrets" tab (the key icon on the left menu):
GCP_PROJECT_ID: Your Google Cloud Project ID.GMP_API_KEY: Your Google Maps Platform API key.
-
Run the Cells: Run the cells in sequence to authenticate, execute the BigQuery jobs, and render the visualizations.