SlideShare uma empresa Scribd logo
1 de 31
PRESENTED BY
Getting Started with GeoCoding with
Redis
Linda Achieng’
Podii, Ruby & Elixir Developer
PRESENTED BY
1 Introduction
Self Introduction & Introduction to GeoCoding.
2 Geo API
Breaking down the GEO API and seeing it in action live on
production, with source code to understand how
implementation is carried out
3 RediSearch & Q & A
Very brief introduction to RediSearch then Q & A comes up
next.
Agenda:
PRESENTED BY
Name: Linda Achieng’
Organization: Podii
Location: -0.107626, 34.768505
Role: Software Developer, specializing in Ruby
and Elixir
Introduction
PRESENTED BY
PRESENTED BY
Introduction to Geocoding
PRESENTED BY
WHERE AM I?
PRESENTED BY
Geocoding is all about coordinates, the x and y axis.
Converting an address like Lutheran Church Kisumu, Kenya to -0.107626,
34.768505.
Location has become key in data collection, accurate location being the key
word, and accurate location goes back to the definition of Geocoding.
Users want answers to questions like “Who is near me?”, “what is near me?”,
“how far am I from X?”
How can we answer the users such questions, in ms?
PRESENTED BY
Users want answers
● “Who is near me?”
● “what is near me?”
● “how far am I from X?
PRESENTED BY
What would happen if we relied on the
names of places instead of coordinates?
PRESENTED BY
PRESENTED BY
Introduction to Redis and Geo API
PRESENTED BY
PRESENTED BY
● Redis is an in-memory data structure store that's commonly used as a
database, a cache, and a message broker.
● Data structures in Redis are like Lego building blocks, helping developers
achieve specific functionalities with minimal complexity and at an amazing
speed .
● Redis also minimizes network overhead and latency because operations are
executed extremely efficiently in memory, right next to where the data is
stored.
● We’ll get to see geospatial functions that use two-dimensional indices built
from latitude and longitude data, and how we can use other Redis APIs to get
the most out of Redis to make our work easier, and most importantly, make
our applications fast.
PRESENTED BY
PRESENTED BY
Write to the DB
Save the location by calling the GEOADD API
It takes in the longitude, latitude and member.
Updating the DB uses the same api.
Whether writing or updating the db, if everything goes well, response will
always be
{:ok, val}
PRESENTED BY
Write to the DB
PRESENTED BY
Read from the DB Read from the DB
You can use hashes instead of
coordinates.
GEOHASH returns a string, a
unique, that is user friendly and
browser(url) friendly.
The longer the string, the more
accurate it is.
We can query coordinates of one place,
a member, in your table.
The output is something like this:
PRESENTED BY
PRESENTED BY
Read from DB
You can also use other APIs that
Redis has to query from DB.
Like ZRANGE – gives you list of
members within the range you
specify.
If you query a non-existent table (sad
path)
ZRANGE gives you a list of the
locations, but you can decide to get
Only the number of locations in your
database.
The ZCARD is a handy command when
you need that.
PRESENTED BY
Important Points to Note
Redis supports data structures such as strings, hashes, lists, sets, sorted sets
with range queries, bitmaps, hyperloglogs and geospatial indexes with radius
queries.
Geospatial indexing uses sorted sets which adds an ordered view to members,
sorted by scores.
When we add our coordinates (longitudes and latitudes), they are hashed together
to make a numeric geohash and the label is saved in a sorted set with the
geohash as a score in a sorted set (ZSET).
This how scores are derived:
● If A and B are two elements with a different score, then A > B if A.score is >
B.score.
● If A and B have exactly the same score, then A > B if the A string is
lexicographically greater than the B string. A and B strings can't be equal since
sorted sets only have unique elements.
PRESENTED BY
Queries for Searching the DB
GEORADIUS
Searching within a circle given by its center and its radius and returns the
members that fall inside it.
We specify the distance we want to query with, like “Which hospitals are 500m
away from me?”
We can also ensure that the response comes with the distance, or
coordinates or hash.
PRESENTED BY
GEORADIUSBYMEMBER
Works exactly like GEORADIUS with additional information, it accepts one of
the indexed members as the circle’s center.
The difference between this and GEORADIUS is that here you specify a
member, with the latter you use coordinates of where your searching.
See:
PRESENTED BY
PRESENTED BY
Points to Note
Results are obtained in less than
10ms- for little amount of data.
If you want want great performance
(speed), keep the radius as small as
possible.
The more points that the circle
covers, the slower the query.
PRESENTED BY
GEODISTANCE
Calculates the distance between two members
By default, return value is in meters, but you can always specify the units
you want.
PRESENTED BY
PRESENTED BY
Deleting from Database
You don’t need a location from your db anymore, then ZREM will work for
you.
Response shows you the number of locations deleted.
PRESENTED BY
RediSearch
Search engine that utilizes both its own datatype and the inbuilt Redis data
types.
Best features:
● Auto-Complete and suggestions/ hints
● Simplicity and ease of use – define an index, add data then search.
PRESENTED BY
Resources
Data Structures
- https://redislabs.com/why-redis/
- https://redis.io/topics/data-types-intro
Geo API
- https://redislabs.com/redis-best-practices/indexing-patterns/geospatial/
-
Thank you!
PRESENTED BY

Mais conteúdo relacionado

Semelhante a Getting started with geocoding x

Geocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 Presentation
Geocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 PresentationGeocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 Presentation
Geocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 Presentation
Blue Raster
 
duy_bien_ism2014_paper
duy_bien_ism2014_paperduy_bien_ism2014_paper
duy_bien_ism2014_paper
Duy Phạm
 
Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...
Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...
Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...
dbpublications
 
MongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data scienceMongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data science
bitragowthamkumar1
 

Semelhante a Getting started with geocoding x (20)

Geocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 Presentation
Geocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 PresentationGeocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 Presentation
Geocoding Our Nation's Schools - Blue Raster NCES Stats-DC 2012 Presentation
 
Explicit Semantics in Graph DBs Driving Digital Transformation With Neo4j
Explicit Semantics in Graph DBs Driving Digital Transformation With Neo4jExplicit Semantics in Graph DBs Driving Digital Transformation With Neo4j
Explicit Semantics in Graph DBs Driving Digital Transformation With Neo4j
 
Building a Spatial Database in PostgreSQL
Building a Spatial Database in PostgreSQLBuilding a Spatial Database in PostgreSQL
Building a Spatial Database in PostgreSQL
 
duy_bien_ism2014_paper
duy_bien_ism2014_paperduy_bien_ism2014_paper
duy_bien_ism2014_paper
 
MongoDB
MongoDBMongoDB
MongoDB
 
Discovery of adaptable services
Discovery of adaptable servicesDiscovery of adaptable services
Discovery of adaptable services
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
 
Beginner's guide to Mongodb and NoSQL
Beginner's guide to Mongodb and NoSQL  Beginner's guide to Mongodb and NoSQL
Beginner's guide to Mongodb and NoSQL
 
Creating Real-Time Data Mashups with Node.js and Adobe CQ by Josh Miller
Creating Real-Time Data Mashups with Node.js and Adobe CQ by Josh MillerCreating Real-Time Data Mashups with Node.js and Adobe CQ by Josh Miller
Creating Real-Time Data Mashups with Node.js and Adobe CQ by Josh Miller
 
MongoDB.pptx
MongoDB.pptxMongoDB.pptx
MongoDB.pptx
 
What is active directory
What is active directoryWhat is active directory
What is active directory
 
Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014Differential Sync and JSON Patch @ SpringOne2GX 2014
Differential Sync and JSON Patch @ SpringOne2GX 2014
 
Introduction to MongoDB How is it Different from RDBMS
Introduction to MongoDB How is it Different from RDBMSIntroduction to MongoDB How is it Different from RDBMS
Introduction to MongoDB How is it Different from RDBMS
 
Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...
Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...
Hybrid Job-Driven Meta Data Scheduling for BigData with MapReduce Clusters an...
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Elasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonElasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparison
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDB - General Purpose Database
MongoDB - General Purpose DatabaseMongoDB - General Purpose Database
MongoDB - General Purpose Database
 
MongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data scienceMongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data science
 

Último

Último (20)

A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
 
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank
^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank
^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank
 

Getting started with geocoding x

  • 1. PRESENTED BY Getting Started with GeoCoding with Redis Linda Achieng’ Podii, Ruby & Elixir Developer
  • 2. PRESENTED BY 1 Introduction Self Introduction & Introduction to GeoCoding. 2 Geo API Breaking down the GEO API and seeing it in action live on production, with source code to understand how implementation is carried out 3 RediSearch & Q & A Very brief introduction to RediSearch then Q & A comes up next. Agenda:
  • 3. PRESENTED BY Name: Linda Achieng’ Organization: Podii Location: -0.107626, 34.768505 Role: Software Developer, specializing in Ruby and Elixir Introduction
  • 7. PRESENTED BY Geocoding is all about coordinates, the x and y axis. Converting an address like Lutheran Church Kisumu, Kenya to -0.107626, 34.768505. Location has become key in data collection, accurate location being the key word, and accurate location goes back to the definition of Geocoding. Users want answers to questions like “Who is near me?”, “what is near me?”, “how far am I from X?” How can we answer the users such questions, in ms?
  • 8. PRESENTED BY Users want answers ● “Who is near me?” ● “what is near me?” ● “how far am I from X?
  • 9. PRESENTED BY What would happen if we relied on the names of places instead of coordinates?
  • 11. PRESENTED BY Introduction to Redis and Geo API
  • 13. PRESENTED BY ● Redis is an in-memory data structure store that's commonly used as a database, a cache, and a message broker. ● Data structures in Redis are like Lego building blocks, helping developers achieve specific functionalities with minimal complexity and at an amazing speed . ● Redis also minimizes network overhead and latency because operations are executed extremely efficiently in memory, right next to where the data is stored. ● We’ll get to see geospatial functions that use two-dimensional indices built from latitude and longitude data, and how we can use other Redis APIs to get the most out of Redis to make our work easier, and most importantly, make our applications fast.
  • 15. PRESENTED BY Write to the DB Save the location by calling the GEOADD API It takes in the longitude, latitude and member. Updating the DB uses the same api. Whether writing or updating the db, if everything goes well, response will always be {:ok, val}
  • 17. PRESENTED BY Read from the DB Read from the DB You can use hashes instead of coordinates. GEOHASH returns a string, a unique, that is user friendly and browser(url) friendly. The longer the string, the more accurate it is. We can query coordinates of one place, a member, in your table. The output is something like this:
  • 19. PRESENTED BY Read from DB You can also use other APIs that Redis has to query from DB. Like ZRANGE – gives you list of members within the range you specify. If you query a non-existent table (sad path) ZRANGE gives you a list of the locations, but you can decide to get Only the number of locations in your database. The ZCARD is a handy command when you need that.
  • 20. PRESENTED BY Important Points to Note Redis supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Geospatial indexing uses sorted sets which adds an ordered view to members, sorted by scores. When we add our coordinates (longitudes and latitudes), they are hashed together to make a numeric geohash and the label is saved in a sorted set with the geohash as a score in a sorted set (ZSET). This how scores are derived: ● If A and B are two elements with a different score, then A > B if A.score is > B.score. ● If A and B have exactly the same score, then A > B if the A string is lexicographically greater than the B string. A and B strings can't be equal since sorted sets only have unique elements.
  • 21. PRESENTED BY Queries for Searching the DB GEORADIUS Searching within a circle given by its center and its radius and returns the members that fall inside it. We specify the distance we want to query with, like “Which hospitals are 500m away from me?” We can also ensure that the response comes with the distance, or coordinates or hash.
  • 22. PRESENTED BY GEORADIUSBYMEMBER Works exactly like GEORADIUS with additional information, it accepts one of the indexed members as the circle’s center. The difference between this and GEORADIUS is that here you specify a member, with the latter you use coordinates of where your searching. See:
  • 24. PRESENTED BY Points to Note Results are obtained in less than 10ms- for little amount of data. If you want want great performance (speed), keep the radius as small as possible. The more points that the circle covers, the slower the query.
  • 25. PRESENTED BY GEODISTANCE Calculates the distance between two members By default, return value is in meters, but you can always specify the units you want.
  • 27. PRESENTED BY Deleting from Database You don’t need a location from your db anymore, then ZREM will work for you. Response shows you the number of locations deleted.
  • 28. PRESENTED BY RediSearch Search engine that utilizes both its own datatype and the inbuilt Redis data types. Best features: ● Auto-Complete and suggestions/ hints ● Simplicity and ease of use – define an index, add data then search.
  • 29. PRESENTED BY Resources Data Structures - https://redislabs.com/why-redis/ - https://redis.io/topics/data-types-intro Geo API - https://redislabs.com/redis-best-practices/indexing-patterns/geospatial/ -