Skip to content

mihaialdoiu/geoapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

geoapp

Exemplify geospatial query capabilities in Amazon DocumentDB or MongoDB. The app takes a geospatial coordinate and a distance radius as input. It identifies the US state the coordinate is part of, finds the number of airports located in the state and then lists the ones found in the specified radius, sorted by closest.

Prerequisites

  1. Install python requirements
pip install -r requirements.txt
  1. Import data set into your Amazon DocumentDB cluster
unzip dataset/airports_geodata.zip;
mongoimport --ssl --host <DocumentDB-cluster-endpoint> --sslCAFile rds-combined-ca-bundle.pem -u <username> -p <password> -d geodata -c airports dataset/airports-us.json;
  
mongoimport --ssl --host <DocumentDB-cluster-endpoint> --sslCAFile rds-combined-ca-bundle.pem -u <username> -p <password> -d geodata -c states dataset/states-us.json;
  1. Connect with mongo shell and create 2dsphere index:
> use geodata
switched to db geodata
> db.airports.createIndex({"loc": "2dsphere"})
  1. Add the Amazon DocumentDB credentials in AWS Secrets Manager. Update the global variables, in the script, and specify the AWS region and secret name.

Usage example:

python3 geoapp.py
Enter your longitude coordinate: -73.9341
Enter your latitude coordinate: 40.8230
Enter distance radius (in km): 40
The geolocation coordinate entered is in the state of: New York
-----------------------------
I have found a number of 29 airports in New York.
-----------------------------
The following airports were found in a 40 km radius:
{'name': 'La Guardia', 'code': 'LGA', 'DistanceKilometers': 7.84283869954285}
{'name': 'Newark Intl', 'code': 'EWR', 'DistanceKilometers': 19.840025284365467}
{'name': 'John F Kennedy Intl', 'code': 'JFK', 'DistanceKilometers': 22.389465314261685}

About

Exemplify geospatial query capabilities in Amazon DocumentDB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages