Skip to content

Redislabs-Solution-Architects/polygon-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polygon Search Examples

Contents

  1. Summary
  2. Features
  3. Prerequisites
  4. Installation
  5. Usage

Summary

This is a Python demo of Polygon Search capabilities available with 7.2 Redis Stack. This builds 4 random polygons and points via the Shapely module. The 4 polygons are arranged to be layered in containment with 4 points within them. The polygons and points are stored in Redis as JSON objects. Redis Search is then leveraged to show the WITHIN and CONTAINS query types.

Features

  • Creates 4 random polygons + points and plots them on a graphical display
  • Stores the Polygons and Points in Redis as JSON objects
  • Performs Redis geo searches leveraging the WITHIN and CONTAINS queries

Prerequisites

  • Docker Compose
  • Python

Installation

  1. Clone this repo.

  2. Install Python requirements

pip install -r requirements.txt
  1. Start Redis Stack
docker compose up -d

Usage

Execution

python3 poly.py

Plot

plot

Results

*** Polygons within the Red Polygon ***
Green Polygon
Blue Polygon
Cyan Polygon

*** Polygons within the Green Polygon ***
Blue Polygon
Cyan Polygon

*** Polygons within the Blue Polygon ***
Cyan Polygon

*** Polygons within the Cyan Polygon ***
None

*** Points within the Red Polygon ***
Purple Point
Brown Point
Orange Point
Olive Point

*** Points within the Green Polygon ***
Purple Point
Brown Point
Orange Point
Olive Point

*** Points within the Blue Polygon ***
Purple Point
Brown Point

*** Points within the Cyan Polygon ***
Purple Point
Brown Point

*** Polygons containing the Red Polygon ***
None

*** Polygons containing the Green Polygon ***
Red Polygon

*** Polygons containing the Blue Polygon ***
Red Polygon
Green Polygon

*** Polygons containing the Cyan Polygon ***
Red Polygon
Green Polygon
Blue Polygon

*** Polygons containing the Purple Point ***
Red Polygon
Green Polygon
Blue Polygon
Cyan Polygon

*** Polygons containing the Brown Point ***
Red Polygon
Green Polygon
Blue Polygon
Cyan Polygon

*** Polygons containing the Orange Point ***
Red Polygon
Green Polygon

*** Polygons containing the Olive Point ***
Red Polygon
Green Polygon