SlideShare a Scribd company logo
Geospatial in the streams
Where in the World is Franz
Kafka?
Will LaForest
Public Sector CTO
will@confluent.io
2
https://github.com/locationtech/geomesa
3
Geospatial based conditions
ETL
Steaming geo analytics
4
ksqlDB: Streaming SQL Engine for Apache Kafka
ksql > CREATE STREAM vip_actions AS
SELECT userid, page, action
FROM clickstream c
LEFT JOIN users u ON c.userid = u.user_id
WHERE u.level = ‘Platinum’
EMIT CHANGES;
Develop real-time stream processing apps writing only SQL!
No Java, Python, or other boilerplate to wrap around it
5
geo_distance
(lat1, lon1, lat2,
lon2, units)
Implementation Notes
Spatial4J
(https://github.com/locationtech/spatial4j)
JTS
(https://github.com/locationtech/jts)
Testing
6
Geospatial Functions
7
KSQLGeo functions - https://github.com/wlaforest/KSQLGeo
geo_contained(lat, lon, shape), geo_contained(shape1, shape2),
Determine whether the point provided in contained in the shape.
geo_intersected(shape1, shape2)
Determine if two shapes intersect anywhere. Spherical and non-spherical
geo_area(shape)
Calculate the area of a shape in squared degrees
geo_hash(lat,lon), geo_hash(lat,lon, precision)
Calculate the geohash of a point. Default precisions is 12
geo_covering_geohashes(shape),geo_covering_geohashes(shape,precision)
Table function which returns a row for each geohash that a the shape falls into
Representing Geometry in ksqlDB - Points
CREATE STREAM BUS_RAW
(VehicleID VARCHAR,
Lat DOUBLE, Lon DOUBLE,
TripID VARCHAR,
RouteID VARCHAR,
DirectionNum BIGINT,
TripHeadSign VARCHAR,
TripEndTime VARCHA)
WITH
(KAFKA_TOPIC='bus_raw', VALUE_FORMAT='JSON')
8
Representing Geometry in ksqlDB - Shapes
CREATE STREAM FENCE_RAW
(ROWKEY VARCHAR KEY, type VARCHAR,
"properties" MAP<VARCHAR, VARCHAR>,
geometry MAP<VARCHAR, VARCHAR>,
geoshape VARCHAR)
WITH
(kafka_topic='fence_raw', value_format='JSON', PARTITIONS=1);
9
Shape Encodings
10
GeoJSON Geometries
{
"type": "Polygon",
"coordinates": [
[[49.4340992,7.7697603],
[49.4391228,7.7707383],
[49.4395496,7.7695902],
[49.4351295,7.7679744],
[49.4340992,7.7697603]]
]
}
Spatial4j does not support FeatureCollection
WKT
POLYGON((-77.25595325282619
38.90049514948347,-77.25389331630275
38.90503717840573,-77.289598882709
38.91171610485367,-77.2760376339297
38.889539649049034,-77.25595325282619
38.90049514948347))
11
Functions
Geohash
• Base32 encoded
• A hash represents a bin in a grid that covers the earth
• The number and size of the bin depends on the precision
12
Geohash for Keying & Partitioning
geo_hash(lat,lon)
geo_hash(lat,lon, precision)
13
CREATE STREAM BUS AS
SELECT
DTIME,
as_value(geo_geohash(Lat,Lon,5)) GEOHASH,
*
FROM BUS_RAW b
PARTITION BY geo_geohash(Lat,Lon,5)
EMIT CHANGES;
Geohash for Binned Aggregates
geo_hash(lat,lon)
geo_hash(lat,lon, precision)
14
CREATE TABLE geo_heat_map AS
SELECT
windowstart ws,
windowend we,
GEOHASH
COUNT(*) total
FROM bus
WINDOW HOPPING
(SIZE 30 SECONDS, ADVANCE BY 10 SECONDS)
GROUP BY GEOHASH
EMIT CHANGES;
Intersection and Containment
geo_contained(lat, lon, shape) geo_contained(shape1, shape2)
geo_intersected(shape1, shape2)
15
CREATE STREAM ALERT AS
SELECT
b.VEHICLEID, b.Lat, b.Lon,
f.GEOHASH
FROM BUS b
INNER JOIN FENCE f WITHIN 7 days
ON b.GEOHASH = f.GEOHASH
WHERE
GEO_CONTAINED(b.Lat, b.Lon, f.geoshape)
EMIT CHANGES;
https://docs.ksqldb.io/en/latest/developer-guide/joins/partition-data/
Shape Partitioning
geo_covering_geohashes(shape),
geo_covering_geohashes(shape, precision)
16
CREATE STREAM FENCE_PRE_PARTITION AS
SELECT
GEO_COVERING_GEOHASHES(_raw_data, 5) GEOHASH, *
FROM FENCE_RAW;
CREATE STREAM FENCE AS
SELECT *
FROM FENCE_PRE_PARTITION
PARTITION BY GEOHASH;
Shape Area
geo_area(shape)
17
CREATE TABLE WEATHER_SYSTEM_AREA AS
SELECT
windowstart ws,
windowend we,
AVG(geo_area(_RAW_DATA)) AVG_AREA
FROM WEATHER_SYSTEM
WINDOW HOPPING
(SIZE 1 HOUR, ADVANCE BY 10 MINUTES)
GROUP BY weather_type
EMIT CHANGES;
Configuration
- ksql.extension.dir
- ksql.functions._global_.spatial4j.geo
- ksql.functions._global_.spatial4j.normWrapLongitude
18
Spatial4J Shape Support
19
Demonstration
Currently Planned Enhancements and Work
21
• Shape buffering
• Compute and return a shape with a buffer around it
• Particularly useful with lines and paths
• Shape center
• Find the center point for a shape.
• Testing and Optimization
• Additional shape and point encodings
• PostGIS for backlog
https://github.com/wlaforest/KSQLGeo
https://github.com/wlaforest/KafkaGeoDemo
will@confluent.io

More Related Content

PDF
以 Leaflet 濫用^H^H呈現開放街圖資料
PDF
Building a developer community with containers
KEY
Drupal mapping
PDF
Mapping in Drupal 7 using OpenLayers
PDF
Mapping in Drupal using OpenLayers
PDF
IBM Cloud Community Summit 2018:「Kubernetes in Muiticloudで戦うCloud Native時代」 b...
PDF
Payment Channel Introduction
PPTX
OpenLayer's basics
以 Leaflet 濫用^H^H呈現開放街圖資料
Building a developer community with containers
Drupal mapping
Mapping in Drupal 7 using OpenLayers
Mapping in Drupal using OpenLayers
IBM Cloud Community Summit 2018:「Kubernetes in Muiticloudで戦うCloud Native時代」 b...
Payment Channel Introduction
OpenLayer's basics

What's hot (20)

PPTX
Drupal mapping modules
PPTX
Hexagon binning for petroleum data
ODP
Darktable -- raw converter for linux
PDF
Answer togoogleearthuniverseandevrythingelse abbreviated
PPT
Riding the Elephant - Hadoop 2.0
PDF
Marble - ein Schweizer Taschenmesser für Karten
PDF
Marble Virtual Globe 1.4 Factsheet (English)
PDF
LocationTech Meetup Hamburg 2014 - GeoGig
PPTX
Google map and navigation
PDF
Spark meets Telemetry
PDF
Marble Virtual Globe 1.6 Factsheet (English)
PDF
51811680 open layers
PPTX
Flexibling Git - Be a Happier Developer with Git
PDF
Marble Virtual Globe 1.3 Factsheet (English)
DOCX
content page for power transmission via sps
ODP
Extreme JavaScript Minification and Obfuscation
PPTX
Open layers
PDF
KDE Community and KDE Games
PDF
Toolchain for real-time simulations: GSN-MeteoIO-GEOtop
Drupal mapping modules
Hexagon binning for petroleum data
Darktable -- raw converter for linux
Answer togoogleearthuniverseandevrythingelse abbreviated
Riding the Elephant - Hadoop 2.0
Marble - ein Schweizer Taschenmesser für Karten
Marble Virtual Globe 1.4 Factsheet (English)
LocationTech Meetup Hamburg 2014 - GeoGig
Google map and navigation
Spark meets Telemetry
Marble Virtual Globe 1.6 Factsheet (English)
51811680 open layers
Flexibling Git - Be a Happier Developer with Git
Marble Virtual Globe 1.3 Factsheet (English)
content page for power transmission via sps
Extreme JavaScript Minification and Obfuscation
Open layers
KDE Community and KDE Games
Toolchain for real-time simulations: GSN-MeteoIO-GEOtop
Ad

Similar to Where in the world is Franz Kafka? | Will LaForest, Confluent (20)

PDF
Location Analytics Real-Time Geofencing using Kafka
PDF
Location Analytics - Real-Time Geofencing using Apache Kafka
PDF
Location Analytics - Real-Time Geofencing using Kafka
PDF
Location Analytics - Real Time Geofencing using Apache Kafka
PPTX
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
PPTX
GeoMeetup kickoff meeting - Overview of Geospatial Landscape
PPTX
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
PDF
Real-Time Processing of Spatial Data Using Kafka Streams, Ian Feeney & Roman ...
PDF
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
PDF
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
PPTX
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
PDF
Sparksummitny2016
PDF
Magellan-Spark as a Geospatial Analytics Engine by Ram Sriharsha
PPTX
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
KEY
Handling Real-time Geostreams
KEY
Handling Real-time Geostreams
PDF
Managing GeoData with PostGIS @ KhmelnytskyiPy #1
PPTX
Processing and Retrieval of Geotagged Unmanned Aerial System Telemetry
PPTX
Processing and retrieval of geotagged unmanned aerial system telemetry
PDF
The state of geo in ElasticSearch
Location Analytics Real-Time Geofencing using Kafka
Location Analytics - Real-Time Geofencing using Apache Kafka
Location Analytics - Real-Time Geofencing using Kafka
Location Analytics - Real Time Geofencing using Apache Kafka
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
GeoMeetup kickoff meeting - Overview of Geospatial Landscape
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Real-Time Processing of Spatial Data Using Kafka Streams, Ian Feeney & Roman ...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
Gis and Ruby 101 at Ruby Conf Kenya 2017 by Kamal Ogudah
Sparksummitny2016
Magellan-Spark as a Geospatial Analytics Engine by Ram Sriharsha
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Handling Real-time Geostreams
Handling Real-time Geostreams
Managing GeoData with PostGIS @ KhmelnytskyiPy #1
Processing and Retrieval of Geotagged Unmanned Aerial System Telemetry
Processing and retrieval of geotagged unmanned aerial system telemetry
The state of geo in ElasticSearch
Ad

More from HostedbyConfluent (20)

PDF
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
PDF
Renaming a Kafka Topic | Kafka Summit London
PDF
Evolution of NRT Data Ingestion Pipeline at Trendyol
PDF
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
PDF
Exactly-once Stream Processing with Arroyo and Kafka
PDF
Fish Plays Pokemon | Kafka Summit London
PDF
Tiered Storage 101 | Kafla Summit London
PDF
Building a Self-Service Stream Processing Portal: How And Why
PDF
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
PDF
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
PDF
Navigating Private Network Connectivity Options for Kafka Clusters
PDF
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
PDF
Explaining How Real-Time GenAI Works in a Noisy Pub
PDF
TL;DR Kafka Metrics | Kafka Summit London
PDF
A Window Into Your Kafka Streams Tasks | KSL
PDF
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
PDF
Data Contracts Management: Schema Registry and Beyond
PDF
Code-First Approach: Crafting Efficient Flink Apps
PDF
Debezium vs. the World: An Overview of the CDC Ecosystem
PDF
Beyond Tiered Storage: Serverless Kafka with No Local Disks
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Renaming a Kafka Topic | Kafka Summit London
Evolution of NRT Data Ingestion Pipeline at Trendyol
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Exactly-once Stream Processing with Arroyo and Kafka
Fish Plays Pokemon | Kafka Summit London
Tiered Storage 101 | Kafla Summit London
Building a Self-Service Stream Processing Portal: How And Why
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Navigating Private Network Connectivity Options for Kafka Clusters
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
Explaining How Real-Time GenAI Works in a Noisy Pub
TL;DR Kafka Metrics | Kafka Summit London
A Window Into Your Kafka Streams Tasks | KSL
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
Data Contracts Management: Schema Registry and Beyond
Code-First Approach: Crafting Efficient Flink Apps
Debezium vs. the World: An Overview of the CDC Ecosystem
Beyond Tiered Storage: Serverless Kafka with No Local Disks

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
NewMind AI Monthly Chronicles - July 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
MYSQL Presentation for SQL database connectivity
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...

Where in the world is Franz Kafka? | Will LaForest, Confluent