SlideShare a Scribd company logo
1 of 23
Download to read offline
Mapquadlib
GeoPython 2021
Introduction
• Lead Software Engineer @ HERE
Get in contact
• Twitter @tafkas
• GitHub Tafkas
• Blog blog.tafkas.net
GeoPython 2021 - Mapquadlib
What are MapQuads?
• Quadtree data structure in which each
internal node has exactly four
children.
• Partitions a two-dimensional space by
recursively subdividing it into four
quadrants.
GeoPython 2021 - Mapquadlib
Why using MapQuads?
• Very convenient way to represent some area on the map
• load tiles individually
• Binning spatial data
• Pre-compute tiles
GeoPython 2021 - Mapquadlib
Constructing MapQuads
• Depth-first traversal of a quadtree
• Z-order curve
• Morton Codes
GeoPython 2021 - Mapquadlib
Morton Codes
• Interleaving the binary coordinate
values yields binary z-values
• Connecting the z-values in their
numerical order produces the
recursively Z-shaped curve
• Two-dimensional z-values are also
called quadkey
GeoPython 2021 - Mapquadlib
Morton Codes - Example
Example: A Mapquad of zoom level 10 with column x=754 and row y=531
1. Convert X and Y to binary values
x = 1011110010
y = 1000010011
2. Interleave x and y, with
• x on even and
• y on odd positions
morton_key = 1100 0101 0111 0000 1110
= 11 00 01 01 01 11 10 00 00 11 10
=> 3 0 1 1 1 3 2 0 0 3 2
= 30111320032 = quad_key
GeoPython 2021 - Mapquadlib
Mapquadlib
A Python library for working with MapQuads
• Uses only Python Standard Library => zero dependencies
• Well tested: over 500 tests, 92% test coverage
• Currently, supports MercatorQuads and HereQuads
• To be open-sourced soon
GeoPython 2021 - Mapquadlib
MercatorQuads
• Used at Bing Maps, Mapbox
• Tiling schema with baked in Mercator
projection
•
!
Tile is always a square on the
map surface
•
"
Distortion
•
"
Latitude is limited up to ~85.05
degrees north and ~-85.05 south
GeoPython 2021 - Mapquadlib
HereQuads
• Based on raw, non-projected WGS84
lat/lng coordinate values
• non-square tiles when viewed on
Mercator projected 2D map
•
!
Tile size in degrees does not change
when close to the poles
GeoPython 2021 - Mapquadlib
Mapquadlib - GeoCoordinate
GeoCoordinate
here_office_location = GeoCoordinate(lng=13.3850739, lat=52.5309163)
print(f"GeoJSON: {here_office_location.geojson}")
GeoJSON: {"type": "Point",
"coordinates": [13.3850739, 52.5309163]}
print(f"WKT: {here_office_location.wkt}")
WKT: POINT (13.3850739 52.5309163)
GeoPython 2021 - Mapquadlib
Mapquadlib - BoundingBox
BoundingBox
here_office = BoundingBox(west=13.3839069538,
south=52.5302044945,
east=13.385562377,
north=52.5309703632)
print(f"GeoJSON: {here_office.geojson}")
GeoJSON: {"type": "Polygon",
"coordinates": [
[
[13.3839069538, 52.5302044945],
[13.385562377, 52.5302044945],
[13.385562377, 52.5309703632],
[13.3839069538, 52.5309703632],
[13.3839069538, 52.5302044945]
]
]
}
print(f"WKT: {here_office.wkt}")
WKT: POLYGON (52.5302044945 13.3839069538,
52.5309703632 13.3839069538,
52.5309703632 13.385562377,
52.5302044945 13.385562377,
52.5302044945 13.3839069538)
GeoPython 2021 - Mapquadlib
Mapquadlib - Creating MapQuads
• Generate a MapQuad by
• long key
• quad key
• latitude, longitude and
zoom level
• x, y index and zoom level
my_quad_1 = HereQuad.from_lat_lng_level(lat=52.5309163,
lng=13.3850739,
level=10)
str(my_quad)
str(my_quad_1)
HereQuad [quadKey=1220120312, longKey=1476150, x=550, y=405, level=10]
my_quad_2 = HereQuad(1476150)
my_quad_3 = HereQuad.from_quad_key("1220120312")
my_quad_1 == my_quad_2 == my_quad_3
True
GeoPython 2021 - Mapquadlib
Mapquadlib - Plotting
Draw its bounding box on a map
bbox = my_quad_1.bounding_box
bbox.geojson
{"type": "Polygon",
"coordinates": [
[
[13.359375, 52.3828125],
[13.7109375, 52.3828125],
[13.7109375, 52.734375],
[13.359375, 52.734375],
[13.359375, 52.3828125]
]
]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Ancestors
Get a MapQuad's ancestor:
ancestor = my_quad.ancestor(7)
ancestor.bounding_box.geojson
{"type": "Polygon",
"coordinates": [
[
[11.25, 50.625],
[14.0625, 50.625],
[14.0625, 53.4375],
[11.25, 53.4375],
[11.25, 50.625]
]
]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Descendants
Get a MapQuad's descendants:
descendants = my_quad.descendants(14)
geo_collection = {
"type": "GeometryCollection",
"geometries": [d.bounding_box._geojson()
for d in descendants]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Neighbors
Get a MapQuad's neighbors:
neighbors = my_quad.neighbors()
geo_collection = {
"type": "GeometryCollection",
"geometries": [d.bounding_box._geojson()
for d in neighbors]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Neighbors
Get a MapQuad's neighbors at a different
level:
neighbors = my_quad.neighbors(14)
geo_collection = {
"type": "GeometryCollection",
"geometries": [d.bounding_box._geojson()
for d in neighbors]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Iterators
Get all MapQuads for a given bounding
box
berlin = BoundingBox(west=13.08835,
south=52.33826,
east=13.76116,
north=52.67551)
quads = MapQuadIterator(HereQuad,level=14,
bounding_box=berlin)
geo_collection = {
"type": "GeometryCollection",
"geometries": [q.bounding_box._geojson() for q in quads]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Conversion
Convert from one MapQuad type to
another
iterator = MapQuadIterator(MercatorQuad,
level=14,
bounding_box=berlin)
geojson = {
"type": "GeometryCollection",
"geometries": [q.bounding_box._geojson() for q in iterator]
}
here_quads = set([HereQuad.from_geocoordinate_level(q.bounding_box.center,
level=14) for q in iterator])
geojson = {
"type": "GeometryCollection",
"geometries": [q.bounding_box._geojson() for q in here_quads]
}
GeoPython 2021 - Mapquadlib
Mapquadlib - Conversion
Convert from one MapQuad type to
another
iterator = MapQuadIterator(MercatorQuad,
level=14,
bounding_box=berlin)
geojson = {
"type": "GeometryCollection",
"geometries": [q.bounding_box._geojson() for q in iterator]
}
here_quads = set([HereQuad.from_geocoordinate_level(q.bounding_box.center,
level=14) for q in iterator])
geojson = {
"type": "GeometryCollection",
"geometries": [q.bounding_box._geojson() for q in here_quads]
}
GeoPython 2021 - Mapquadlib
References
1. Tiled web map
2. Z-order curve
3. Bing Maps Tile System
4. Here Developer Portal
GeoPython 2021 - Mapquadlib
Thank you
GeoPython 2021 - Mapquadlib

More Related Content

Similar to GeoPython 2021 - Mapquadlib: A Python Library for Working with Map Quads

Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012Mack Hardy
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBGetting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBMongoDB
 
The state of geo in ElasticSearch
The state of geo in ElasticSearchThe state of geo in ElasticSearch
The state of geo in ElasticSearchFan Robbin
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDBleafnode
 
Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...John Wilker
 
Lucene/Solr spatial in 2015
Lucene/Solr spatial in 2015Lucene/Solr spatial in 2015
Lucene/Solr spatial in 2015David Smiley
 
Lucene/Solr Spatial in 2015: Presented by David Smiley
Lucene/Solr Spatial in 2015: Presented by David SmileyLucene/Solr Spatial in 2015: Presented by David Smiley
Lucene/Solr Spatial in 2015: Presented by David SmileyLucidworks
 
Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...
Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...
Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...Neo4j
 
Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™Databricks
 
Challenging Web-Scale Graph Analytics with Apache Spark
Challenging Web-Scale Graph Analytics with Apache SparkChallenging Web-Scale Graph Analytics with Apache Spark
Challenging Web-Scale Graph Analytics with Apache SparkDatabricks
 
Challenging Web-Scale Graph Analytics with Apache Spark with Xiangrui Meng
Challenging Web-Scale Graph Analytics with Apache Spark with Xiangrui MengChallenging Web-Scale Graph Analytics with Apache Spark with Xiangrui Meng
Challenging Web-Scale Graph Analytics with Apache Spark with Xiangrui MengDatabricks
 
NetVLAD: CNN architecture for weakly supervised place recognition
NetVLAD:  CNN architecture for weakly supervised place recognitionNetVLAD:  CNN architecture for weakly supervised place recognition
NetVLAD: CNN architecture for weakly supervised place recognitionGeunhee Cho
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Texas Natural Resources Information System
 
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2StanfordComputationalImaging
 
Geospatial for Java
Geospatial for JavaGeospatial for Java
Geospatial for JavaJody Garnett
 
Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™Databricks
 

Similar to GeoPython 2021 - Mapquadlib: A Python Library for Working with Map Quads (20)

Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBGetting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDB
 
The state of geo in ElasticSearch
The state of geo in ElasticSearchThe state of geo in ElasticSearch
The state of geo in ElasticSearch
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDB
 
Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...Getting Oriented with MapKit: Everything you need to get started with the new...
Getting Oriented with MapKit: Everything you need to get started with the new...
 
Lucene/Solr spatial in 2015
Lucene/Solr spatial in 2015Lucene/Solr spatial in 2015
Lucene/Solr spatial in 2015
 
Ar1 twf030 lecture1.2
Ar1 twf030 lecture1.2Ar1 twf030 lecture1.2
Ar1 twf030 lecture1.2
 
Day 6 - PostGIS
Day 6 - PostGISDay 6 - PostGIS
Day 6 - PostGIS
 
Lucene/Solr Spatial in 2015: Presented by David Smiley
Lucene/Solr Spatial in 2015: Presented by David SmileyLucene/Solr Spatial in 2015: Presented by David Smiley
Lucene/Solr Spatial in 2015: Presented by David Smiley
 
Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...
Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...
Training Series - Build A Routing Web Application With OpenStreetMap, Neo4j, ...
 
Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™
 
Challenging Web-Scale Graph Analytics with Apache Spark
Challenging Web-Scale Graph Analytics with Apache SparkChallenging Web-Scale Graph Analytics with Apache Spark
Challenging Web-Scale Graph Analytics with Apache Spark
 
Challenging Web-Scale Graph Analytics with Apache Spark with Xiangrui Meng
Challenging Web-Scale Graph Analytics with Apache Spark with Xiangrui MengChallenging Web-Scale Graph Analytics with Apache Spark with Xiangrui Meng
Challenging Web-Scale Graph Analytics with Apache Spark with Xiangrui Meng
 
NetVLAD: CNN architecture for weakly supervised place recognition
NetVLAD:  CNN architecture for weakly supervised place recognitionNetVLAD:  CNN architecture for weakly supervised place recognition
NetVLAD: CNN architecture for weakly supervised place recognition
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...
 
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
 
Advancing Scientific Data Support in ArcGIS
Advancing Scientific Data Support in ArcGISAdvancing Scientific Data Support in ArcGIS
Advancing Scientific Data Support in ArcGIS
 
Geospatial for Java
Geospatial for JavaGeospatial for Java
Geospatial for Java
 
Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™Web-Scale Graph Analytics with Apache® Spark™
Web-Scale Graph Analytics with Apache® Spark™
 
S2
S2S2
S2
 

Recently uploaded

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

GeoPython 2021 - Mapquadlib: A Python Library for Working with Map Quads

  • 2. Introduction • Lead Software Engineer @ HERE Get in contact • Twitter @tafkas • GitHub Tafkas • Blog blog.tafkas.net GeoPython 2021 - Mapquadlib
  • 3. What are MapQuads? • Quadtree data structure in which each internal node has exactly four children. • Partitions a two-dimensional space by recursively subdividing it into four quadrants. GeoPython 2021 - Mapquadlib
  • 4. Why using MapQuads? • Very convenient way to represent some area on the map • load tiles individually • Binning spatial data • Pre-compute tiles GeoPython 2021 - Mapquadlib
  • 5. Constructing MapQuads • Depth-first traversal of a quadtree • Z-order curve • Morton Codes GeoPython 2021 - Mapquadlib
  • 6. Morton Codes • Interleaving the binary coordinate values yields binary z-values • Connecting the z-values in their numerical order produces the recursively Z-shaped curve • Two-dimensional z-values are also called quadkey GeoPython 2021 - Mapquadlib
  • 7. Morton Codes - Example Example: A Mapquad of zoom level 10 with column x=754 and row y=531 1. Convert X and Y to binary values x = 1011110010 y = 1000010011 2. Interleave x and y, with • x on even and • y on odd positions morton_key = 1100 0101 0111 0000 1110 = 11 00 01 01 01 11 10 00 00 11 10 => 3 0 1 1 1 3 2 0 0 3 2 = 30111320032 = quad_key GeoPython 2021 - Mapquadlib
  • 8. Mapquadlib A Python library for working with MapQuads • Uses only Python Standard Library => zero dependencies • Well tested: over 500 tests, 92% test coverage • Currently, supports MercatorQuads and HereQuads • To be open-sourced soon GeoPython 2021 - Mapquadlib
  • 9. MercatorQuads • Used at Bing Maps, Mapbox • Tiling schema with baked in Mercator projection • ! Tile is always a square on the map surface • " Distortion • " Latitude is limited up to ~85.05 degrees north and ~-85.05 south GeoPython 2021 - Mapquadlib
  • 10. HereQuads • Based on raw, non-projected WGS84 lat/lng coordinate values • non-square tiles when viewed on Mercator projected 2D map • ! Tile size in degrees does not change when close to the poles GeoPython 2021 - Mapquadlib
  • 11. Mapquadlib - GeoCoordinate GeoCoordinate here_office_location = GeoCoordinate(lng=13.3850739, lat=52.5309163) print(f"GeoJSON: {here_office_location.geojson}") GeoJSON: {"type": "Point", "coordinates": [13.3850739, 52.5309163]} print(f"WKT: {here_office_location.wkt}") WKT: POINT (13.3850739 52.5309163) GeoPython 2021 - Mapquadlib
  • 12. Mapquadlib - BoundingBox BoundingBox here_office = BoundingBox(west=13.3839069538, south=52.5302044945, east=13.385562377, north=52.5309703632) print(f"GeoJSON: {here_office.geojson}") GeoJSON: {"type": "Polygon", "coordinates": [ [ [13.3839069538, 52.5302044945], [13.385562377, 52.5302044945], [13.385562377, 52.5309703632], [13.3839069538, 52.5309703632], [13.3839069538, 52.5302044945] ] ] } print(f"WKT: {here_office.wkt}") WKT: POLYGON (52.5302044945 13.3839069538, 52.5309703632 13.3839069538, 52.5309703632 13.385562377, 52.5302044945 13.385562377, 52.5302044945 13.3839069538) GeoPython 2021 - Mapquadlib
  • 13. Mapquadlib - Creating MapQuads • Generate a MapQuad by • long key • quad key • latitude, longitude and zoom level • x, y index and zoom level my_quad_1 = HereQuad.from_lat_lng_level(lat=52.5309163, lng=13.3850739, level=10) str(my_quad) str(my_quad_1) HereQuad [quadKey=1220120312, longKey=1476150, x=550, y=405, level=10] my_quad_2 = HereQuad(1476150) my_quad_3 = HereQuad.from_quad_key("1220120312") my_quad_1 == my_quad_2 == my_quad_3 True GeoPython 2021 - Mapquadlib
  • 14. Mapquadlib - Plotting Draw its bounding box on a map bbox = my_quad_1.bounding_box bbox.geojson {"type": "Polygon", "coordinates": [ [ [13.359375, 52.3828125], [13.7109375, 52.3828125], [13.7109375, 52.734375], [13.359375, 52.734375], [13.359375, 52.3828125] ] ] } GeoPython 2021 - Mapquadlib
  • 15. Mapquadlib - Ancestors Get a MapQuad's ancestor: ancestor = my_quad.ancestor(7) ancestor.bounding_box.geojson {"type": "Polygon", "coordinates": [ [ [11.25, 50.625], [14.0625, 50.625], [14.0625, 53.4375], [11.25, 53.4375], [11.25, 50.625] ] ] } GeoPython 2021 - Mapquadlib
  • 16. Mapquadlib - Descendants Get a MapQuad's descendants: descendants = my_quad.descendants(14) geo_collection = { "type": "GeometryCollection", "geometries": [d.bounding_box._geojson() for d in descendants] } GeoPython 2021 - Mapquadlib
  • 17. Mapquadlib - Neighbors Get a MapQuad's neighbors: neighbors = my_quad.neighbors() geo_collection = { "type": "GeometryCollection", "geometries": [d.bounding_box._geojson() for d in neighbors] } GeoPython 2021 - Mapquadlib
  • 18. Mapquadlib - Neighbors Get a MapQuad's neighbors at a different level: neighbors = my_quad.neighbors(14) geo_collection = { "type": "GeometryCollection", "geometries": [d.bounding_box._geojson() for d in neighbors] } GeoPython 2021 - Mapquadlib
  • 19. Mapquadlib - Iterators Get all MapQuads for a given bounding box berlin = BoundingBox(west=13.08835, south=52.33826, east=13.76116, north=52.67551) quads = MapQuadIterator(HereQuad,level=14, bounding_box=berlin) geo_collection = { "type": "GeometryCollection", "geometries": [q.bounding_box._geojson() for q in quads] } GeoPython 2021 - Mapquadlib
  • 20. Mapquadlib - Conversion Convert from one MapQuad type to another iterator = MapQuadIterator(MercatorQuad, level=14, bounding_box=berlin) geojson = { "type": "GeometryCollection", "geometries": [q.bounding_box._geojson() for q in iterator] } here_quads = set([HereQuad.from_geocoordinate_level(q.bounding_box.center, level=14) for q in iterator]) geojson = { "type": "GeometryCollection", "geometries": [q.bounding_box._geojson() for q in here_quads] } GeoPython 2021 - Mapquadlib
  • 21. Mapquadlib - Conversion Convert from one MapQuad type to another iterator = MapQuadIterator(MercatorQuad, level=14, bounding_box=berlin) geojson = { "type": "GeometryCollection", "geometries": [q.bounding_box._geojson() for q in iterator] } here_quads = set([HereQuad.from_geocoordinate_level(q.bounding_box.center, level=14) for q in iterator]) geojson = { "type": "GeometryCollection", "geometries": [q.bounding_box._geojson() for q in here_quads] } GeoPython 2021 - Mapquadlib
  • 22. References 1. Tiled web map 2. Z-order curve 3. Bing Maps Tile System 4. Here Developer Portal GeoPython 2021 - Mapquadlib
  • 23. Thank you GeoPython 2021 - Mapquadlib