Git Product home page Git Product logo

geoapp's Introduction

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}

geoapp's People

Contributors

mihaialdoiu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.