Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overture Maps Examples #40

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion assets/scss/layouts/_pages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ h4:hover a {
}

.view-on-map {
margin-top: -2rem;
margin-top: -1.5rem;
text-align: center;
font-size: 0.8em;
}

.view-on-map-cloud {
margin-top: -1.5rem;
// font-size: 0.8em;
}

p.playground-link {
text-align: center;
margin-top: -1.5rem;
Expand Down
5 changes: 3 additions & 2 deletions content/docs/about/kepler-gl-map-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ Visualize population density anywhere in the world and at any level of detail


## Overture Maps
Examples creating kepler.gl maps from Overture Data in BigQuery public dataset

* [Overture Maps: All Nevada roads](https://cloud.dekart.xyz/reports/15540f2b-2411-44a4-92b5-206a9bee5753)
Examples of Kepler.gl maps created using Overture Data in BigQuery, focusing on geospatial visualizations from the segment, division_area, land_use, and place tables.

👉 [Overture Map Example](/docs/about/overture-maps-examples/)

## OpenStreetMap

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
338 changes: 338 additions & 0 deletions content/docs/about/overture-maps-examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
---
title: "Overture Maps Examples"
description: "Collection of kepler.gl maps created from Overture Data in BigQuery public dataset using SQL and Dekart."
lead: ""
date: 2024-08-28T07:26:19+02:00
lastmod: 2024-08-28T07:26:19+02:00
draft: false
images: []
menu:
docs:
parent: "about"
weight: 999
toc: true
canonical: ""
---


Collection of kepler.gl maps created from Overture Data in BigQuery public dataset using BigQuery SQL and Dekart. Each example includes a SQL query and a visualized map.

## Segment

The Overture Maps `segment` table represents paths, roads, and transportation segments, storing their geospatial data as LineStrings along with attributes like class, surface, speed limits, and access restrictions​.


### Nevada Roads by Speed and Class
{{< img src="77dc6f7f-c91c-4099-8dc3-8f043d46cdfb.png" cloud="77dc6f7f-c91c-4099-8dc3-8f043d46cdfb" >}}

```sql
-- Step 1: Get the geometry of Nevada
WITH nevada_geometry AS (
SELECT
geometry
FROM
`bigquery-public-data.overture_maps.division_area`
WHERE
country = 'US'
AND region = 'US-NV'
AND subtype = 'region'
)

-- Step 2: Select roads within Nevada
SELECT
s.geometry,
s.class,
s.road,
SAFE_CAST(JSON_EXTRACT_SCALAR(s.road, '$.restrictions.speed_limits[0].max_speed.value') AS INT64) AS speed_limit
FROM
`bigquery-public-data.overture_maps.segment` AS s,
nevada_geometry AS ng
WHERE
s.subtype = 'road'
and class not in ('track', 'driveway', 'path', 'footway', 'sidewalk', 'pedestrian', 'cycleway', 'steps', 'crosswalk', 'bridleway', 'alley')
AND ST_WITHIN(s.geometry, ng.geometry)

```
{{< try-query-cloud report="77dc6f7f-c91c-4099-8dc3-8f043d46cdfb" >}}

### Berlin Roads
{{< img src="410b857a-aad1-4f05-8ddd-551d0f0fe650.png" cloud="410b857a-aad1-4f05-8ddd-551d0f0fe650" >}}

```sql
WITH berlin_boundary AS (
SELECT geometry
FROM `bigquery-public-data.overture_maps.division_area`
WHERE LOWER(names.primary) = "berlin"
AND country = "DE"
)
SELECT s.id, s.geometry, s.class, s.subtype
FROM `bigquery-public-data.overture_maps.segment` s
JOIN berlin_boundary b
ON ST_CONTAINS(b.geometry, s.geometry) -- Spatial filter for roads inside Berlin boundary
WHERE s.subtype = 'road'
AND s.class IN ('primary', 'secondary', 'tertiary');

```
{{< try-query-cloud report="410b857a-aad1-4f05-8ddd-551d0f0fe650" >}}

### Nevada highways and main roads
{{< img src="db0e26c2-00b0-4f6b-8f21-a26ab312f9e1.png" cloud="db0e26c2-00b0-4f6b-8f21-a26ab312f9e1" >}}

```sql
-- Step 1: Get the simplified geometry of Nevada
WITH nevada_geometry AS (
SELECT
ST_SIMPLIFY(geometry, 0.01) AS geometry
FROM
OVERTURE_MAPS__DIVISIONS.CARTO.DIVISION_AREA
WHERE
country = 'US'
AND region = 'US-NV'
AND subtype = 'region'
)

-- Step 2: Select main roads and highways within simplified Nevada geometry and convert geometry to WKT
SELECT
ST_ASWKT(s.geometry) AS geo,
s.class
FROM
OVERTURE_MAPS__TRANSPORTATION.CARTO.SEGMENT AS s
JOIN nevada_geometry AS ng ON ST_WITHIN(s.geometry, ng.geometry)
WHERE
s.subtype = 'road'
AND s.class IN ('primary', 'secondary', 'tertiary', 'trunk', 'motorway')

```
{{< try-query-cloud report="db0e26c2-00b0-4f6b-8f21-a26ab312f9e1" >}}

### Germany & France Road Networks
{{< img src="a4e308a3-b2e8-4183-bfd6-b68866209f50.png" cloud="a4e308a3-b2e8-4183-bfd6-b68866209f50" >}}

```sql
WITH country_boundaries AS (
-- Define the boundaries for Germany and France
SELECT geometry, country
FROM `bigquery-public-data.overture_maps.division_area`
WHERE country IN ("DE", "FR")
AND subtype = "country" -- Ensure we're selecting the entire country boundaries
),
filtered_roads AS (
-- Filter the roads inside the Germany and France boundaries that are accessible to cars, including main roads but excluding highways
SELECT s.id, s.geometry, s.class, s.subtype, b.country,
ST_LENGTH(s.geometry) / 1000 AS road_length_km -- Convert road length to kilometers
FROM `bigquery-public-data.overture_maps.segment` s
JOIN country_boundaries b
ON ST_CONTAINS(b.geometry, s.geometry) -- Spatial filter for roads inside Germany and France boundaries
WHERE s.subtype = 'road'
AND s.class IN ('primary', 'secondary', 'tertiary') -- Main roads for traffic, excluding highways
),
hexagonized_roads AS (
-- Assign each road segment to an H3 hexagon at level 7
SELECT
id,
country,
`bqcarto.h3.ST_ASH3`(ST_CENTROID(s.geometry), 7) AS h3_hexagon, -- H3 hexagon for each road segment at level 5
road_length_km -- Use the length in kilometers
FROM filtered_roads s
)
-- Aggregate the total length of roads for each hexagon and country
SELECT country, h3_hexagon, SUM(road_length_km) AS total_road_length_km
FROM hexagonized_roads
GROUP BY country, h3_hexagon
ORDER BY total_road_length_km DESC;

```
{{< try-query-cloud report="a4e308a3-b2e8-4183-bfd6-b68866209f50" >}}

### Road density US
{{< img src="eb5b25bf-4c62-44bc-9e69-f0257134e3f8.png" cloud="eb5b25bf-4c62-44bc-9e69-f0257134e3f8" >}}

```sql
WITH country_boundaries AS (
-- Define the boundaries for the US
SELECT geometry, country
FROM `bigquery-public-data.overture_maps.division_area`
WHERE country = "US"
AND subtype = "country" -- Ensure we're selecting the entire country boundaries
),
filtered_roads AS (
-- Filter the roads inside the US boundaries that are accessible to cars, including main roads but excluding highways
SELECT s.id, s.geometry, s.class, s.subtype, b.country,
ST_LENGTH(s.geometry) / 1000 AS road_length_km -- Convert road length to kilometers
FROM `bigquery-public-data.overture_maps.segment` s
JOIN country_boundaries b
ON ST_CONTAINS(b.geometry, s.geometry) -- Spatial filter for roads inside US boundaries
WHERE s.subtype = 'road'
AND s.class IN ('primary', 'secondary', 'tertiary') -- Main roads for traffic, excluding highways
),
hexagonized_roads AS (
-- Assign each road segment to an H3 hexagon at level 6
SELECT
id,
country,
`bqcarto.h3.ST_ASH3`(ST_CENTROID(s.geometry), 6) AS h3_hexagon, -- H3 hexagon for each road segment at level 5
road_length_km -- Use the length in kilometers
FROM filtered_roads s
)
-- Aggregate the total length of roads for each hexagon and country
SELECT country, h3_hexagon, SUM(road_length_km) AS total_road_length_km
FROM hexagonized_roads
GROUP BY country, h3_hexagon
ORDER BY total_road_length_km DESC;
```

{{< try-query-cloud report="eb5b25bf-4c62-44bc-9e69-f0257134e3f8" >}}

## Division Area

The Overture Maps division_area table contains boundary polygons for administrative areas, such as cities, countries, and neighborhoods, along with related attributes like subtype, population, and country codes​.

### Berlin Boundary

{{< img src="5f7144cd-24f0-4698-ba7e-a63e872a4659.png" cloud="5f7144cd-24f0-4698-ba7e-a63e872a4659" >}}

```sql
SELECT id, geometry, names, subtype, country, region
FROM `bigquery-public-data.overture_maps.division_area`
WHERE names.primary = 'Berlin'
AND country = 'DE'
```
{{< try-query-cloud report="5f7144cd-24f0-4698-ba7e-a63e872a4659" >}}

<!-- ffbe0a05-7794-465c-ab5b-de54d69cdb38 -->
### Regions and Cities in France

{{< img src="ffbe0a05-7794-465c-ab5b-de54d69cdb38.png" cloud="ffbe0a05-7794-465c-ab5b-de54d69cdb38" >}}

```sql
SELECT
division_id,
names.primary AS division_name,
subtype,
geometry
FROM
`bigquery-public-data.overture_maps.division_area`
WHERE
country = 'FR' -- ISO code for France
AND subtype IN ('region', 'city') -- Filtering for regions and cities
ORDER BY
subtype;
```
{{< try-query-cloud report="ffbe0a05-7794-465c-ab5b-de54d69cdb38" >}}

## Land Use

The Overture Maps `land_use` table represents different types of land use, such as residential, agricultural, industrial, and others, by storing their spatial data as polygons or multipolygons, along with attributes like subtype, class, surface, and names.

<!-- 34d0ba2c-0fd5-4323-a677-d5b05b65d86d -->

### Berlin Playgrounds

{{< img src="34d0ba2c-0fd5-4323-a677-d5b05b65d86d.png" cloud="34d0ba2c-0fd5-4323-a677-d5b05b65d86d" >}}

```sql
SELECT id, subtype, class, geometry, surface, level
FROM `bigquery-public-data.overture_maps.land_use`
WHERE ST_WITHIN(geometry, ST_GEOGFROMTEXT('POLYGON((13.08835 52.33826, 13.76116 52.33826, 13.76116 52.67551, 13.08835 52.67551, 13.08835 52.33826))'))
AND LOWER(class) = 'playground'
```
{{< try-query-cloud report="34d0ba2c-0fd5-4323-a677-d5b05b65d86d" >}}

### All parks in London

{{< img src="8cb1566f-0237-4d99-9cc4-bdd70859763a.png" cloud="8cb1566f-0237-4d99-9cc4-bdd70859763a" >}}

```sql
SELECT
id,
geometry,
names.primary AS primary_name,
subtype,
country,
region
FROM
`bigquery-public-data.overture_maps.division_area`
WHERE
names.primary = "London"
AND country = 'GB' -- ISO code for the United Kingdom
AND subtype = 'locality'; -- Ensure we are selecting a city or locality
```
{{< try-query-cloud report="8cb1566f-0237-4d99-9cc4-bdd70859763a" >}}

### Ukraine Schools

{{< img src="f0941a67-350f-4a80-a9d0-27594f2f853d.png" cloud="f0941a67-350f-4a80-a9d0-27594f2f853d" >}}

```sql
WITH ukraine_boundary AS (
SELECT geometry
FROM `bigquery-public-data.overture_maps.division_area`
WHERE LOWER(names.primary) = 'ukraine'
AND subtype = 'country'
)

SELECT l.id, l.names.primary, l.geometry, l.subtype, l.class
FROM `bigquery-public-data.overture_maps.land_use` l, ukraine_boundary u
WHERE ST_WITHIN(l.geometry, u.geometry)
AND LOWER(l.subtype) = 'education'
AND LOWER(l.class) = 'school';
```
{{< try-query-cloud report="f0941a67-350f-4a80-a9d0-27594f2f853d" >}}

## Places

The `place` table in the Overture Maps dataset contains points of interest (POIs) such as businesses, amenities, and public facilities.


### London EV Charging Density

{{< img src="af836766-9ec4-40fc-afbe-fc6b32d6593b.png" cloud="af836766-9ec4-40fc-afbe-fc6b32d6593b" >}}

```sql
WITH london_boundary AS (
SELECT geometry
FROM `bigquery-public-data.overture_maps.division_area`
WHERE LOWER(names.primary) = 'london'
AND country = 'GB'
),
ev_charging_stations AS (
SELECT
p.geometry
FROM
`bigquery-public-data.overture_maps.place` AS p,
london_boundary AS lb
WHERE
ST_WITHIN(p.geometry, lb.geometry)
AND LOWER(p.categories.primary) LIKE '%charging%'
)
SELECT
bqcarto.h3.ST_ASH3(ev.geometry, 6) AS h3_cell,
COUNT(*) AS station_count
FROM
ev_charging_stations ev
GROUP BY
h3_cell;

```
{{< try-query-cloud report="af836766-9ec4-40fc-afbe-fc6b32d6593b" >}}

### Las Vegas EV Charging


{{< img src="72781fb6-8bc5-4c41-839f-66f5bcf7c122.png" cloud="72781fb6-8bc5-4c41-839f-66f5bcf7c122" >}}

```sql
WITH las_vegas_boundary AS (
SELECT geometry
FROM `bigquery-public-data.overture_maps.division_area`
WHERE names.primary = "Las Vegas"
AND region = "US-NV"
AND subtype = "locality"
)

SELECT p.id, p.geometry, p.names.primary AS station_name, p.addresses, p.websites, p.phones
FROM `bigquery-public-data.overture_maps.place` AS p, las_vegas_boundary AS lv
WHERE (p.categories.primary LIKE "%charging%" OR p.categories.primary LIKE "%ev%")
AND ST_WITHIN(p.geometry, lv.geometry)
```
{{< try-query-cloud report="72781fb6-8bc5-4c41-839f-66f5bcf7c122" >}}
8 changes: 8 additions & 0 deletions layouts/shortcodes/img.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@
{{ with .Get "report" }}
<p class="view-on-map"><a href="https://play.dekart.xyz/reports/{{ . }}" target="_blank">view on a map</a></p>
{{ end }}
{{ with .Get "cloud" }}
<!-- <p class="view-on-map"><a href="https://cloud.dekart.xyz/reports/{{ . }}" target="_blank">View on Dekart</a></p> -->
<p class="view-on-map">
<a href="https://cloud.dekart.xyz/reports/{{ . }}" target="_blank" class="btn btn-outline-primary btn-sm">
View interactive map
</a>
</p>
{{ end }}
8 changes: 8 additions & 0 deletions layouts/shortcodes/try-query-cloud.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p class="playground-link">
<!-- <a class="btn btn-secondary btn-sm" href='https://cloud.dekart.xyz/reports/{{ .Get "report" }}/source'
target='_blank'>Run on Dekart</a> -->
<a href="https://cloud.dekart.xyz/reports/{{ . }}" target="_blank" class="btn btn-outline-primary btn-sm">
Open query in editor
</a>

</p>
Loading