Centroids as a Service

Overview

Centroids!

This application reads a valid geojson FeatureCollection and returns a valid geojson FeatureColleciton of centroids.

In the output:

  • All properties are retained.
  • Polygon features become points that represent the Polygon's centroid.
  • LineString features become points that represent the middle of the LineString.
  • Point features do not change.
  • I have no idea how this handles MultiPolygons.

This is a Flask application that uses the Shapely Python library by @sgillies. Issues and pull requests welcome!

The service can be accessed in two ways: an upload/download page and a web service.

Upload/download

The upload/download page can be found here. It is pretty self explanatory.

Web service

The web service lives at http://centroids.herokuapp.com/centroids. You can post to it with geojson.

Here is an example of how you might do that from the command line with curl (example from @invisiblefunnel):

$ curl -X POST -H "Content-Type: application/json" -d \
 '{
   "type": "FeatureCollection",
   "features": [
     {
       "type": "Feature",
       "properties": {},
       "geometry": {
         "type": "Polygon",
         "coordinates": [
           [
             [
               -80.93490600585938,
               35.263561862152095
             ],
             [
               -80.69320678710938,
               35.32745068492882
             ],
             [
               -80.60531616210938,
               35.14124815600257
             ],
             [
               -80.83328247070312,
               35.06597313798418
             ],
             [
               -80.93490600585938,
               35.263561862152095
             ]
           ]
         ]
       }
     }
   ]
 }' http://centroids.herokuapp.com/centroids

Should return:

{
  "features": [
    {
      "geometry": {
        "coordinates": [
          -80.76829071683488, 
          35.199632857787904
        ], 
        "type": "Point"
      }, 
      "properties": {}, 
      "type": "Feature"
    }
  ], 
  "type": "FeatureCollection"
}

Running locally

Optionally create a virtual environment

virtualenv venv
source venv/bin/activate

Install requirements

pip install -r requirements.txt

Start the server

python hello.py

You should now be able to visit the application at http://127.0.0.1:5000/.

Notes

To run on Heroku requires a third party BUILDPACK for Heroku

You might also like...
A familiar HTTP Service Framework for Python.
A familiar HTTP Service Framework for Python.

Responder: a familiar HTTP Service Framework for Python Powered by Starlette. That async declaration is optional. View documentation. This gets you a

Websockify is a WebSocket to TCP proxy/bridge. This allows a browser to connect to any application/server/service. Implementations in Python, C, Node.js and Ruby.

websockify: WebSockets support for any application/server websockify was formerly named wsproxy and was part of the noVNC project. At the most basic l

Deploy a ML inference service on a budget in less than 10 lines of code.
Deploy a ML inference service on a budget in less than 10 lines of code.

BudgetML is perfect for practitioners who would like to quickly deploy their models to an endpoint, but not waste a lot of time, money, and effort trying to figure out how to do this end-to-end.

GraphQL is a query language and execution engine tied to any backend service.

GraphQL The GraphQL specification is edited in the markdown files found in /spec the latest release of which is published at https://graphql.github.io

Lightweight, scriptable browser as a service with an HTTP API

Splash - A javascript rendering service Splash is a javascript rendering service with an HTTP API. It's a lightweight browser with an HTTP API, implem

thumbor is an open-source photo thumbnail service by globo.com
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

FastAPI application and service structure for a more maintainable codebase

Abstracting FastAPI Services See this article for more information: https://camillovisini.com/article/abstracting-fastapi-services/ Poetry poetry inst

A FastAPI Middleware of joerick/pyinstrument to check your service performance.

fastapi_profiler A FastAPI Middleware of joerick/pyinstrument to check your service performance. 📣 Info A FastAPI Middleware of pyinstrument to check

thumbor is an open-source photo thumbnail service by globo.com
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

changedetection.io - The best and simplest self-hosted website change detection monitoring service
changedetection.io - The best and simplest self-hosted website change detection monitoring service

changedetection.io - The best and simplest self-hosted website change detection monitoring service. An alternative to Visualping, Watchtower etc. Designed for simplicity - the main goal is to simply monitor which websites had a text change. Open source web page change detection.

Public HTTPS access to Home Assistant with Dataplicity service
Public HTTPS access to Home Assistant with Dataplicity service

Custom component for public HTTPS access to Home Assistant with Dataplicity service. Should work on any Linux PC or ARM, not only Raspberry as Dataplicity service said. Don't work on Windows.

Analytics service that is part of iter8. Robust analytics and control to unleash cloud-native continuous experimentation.

iter8-analytics iter8 enables statistically robust continuous experimentation of microservices in your CI/CD pipelines. For in-depth information about

python template private service
python template private service

Template for private python service This is a cookiecutter template for an internal REST API service, written in Python, inspired by layout-golang. Th

Use GitHub Actions to create a serverless service.

ActionServerless - Use GitHub Actions to create a serverless service ActionServerless is an action to do some computing and then generate a string/JSO

Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance frameworks.
Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance frameworks.

aws-allowlister Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance fr

Iris is a highly configurable and flexible service for paging and messaging.
Iris is a highly configurable and flexible service for paging and messaging.

Iris Iris core, API, UI and sender service. For third-party integration support, see iris-relay, a stateless proxy designed to sit at the edge of a pr

Dynamic DNS service

About nsupdate.info https://nsupdate.info is a free dynamic DNS service. nsupdate.info is also the name of the software used to implement it. If you l

Your own movie streaming service. Easy to install, easy to use. Download, manage and watch your favorite movies conveniently from your browser or phone. Install it on your server, access it anywhere and enjoy.
Your own movie streaming service. Easy to install, easy to use. Download, manage and watch your favorite movies conveniently from your browser or phone. Install it on your server, access it anywhere and enjoy.

Vigilio Your own movie streaming service. Easy to install, easy to use. Download, manage and watch your favorite movies conveniently from your browser

A simple service that allows you to run commands on the server using text

Server Text A simple flask service that allows you to run commands on the server/computer over sms. Think of it as a shell where you run commands over

Comments
  • heroku-able

    heroku-able

    To run on Heroku, you'll want two files for python apps:

    1. Procfile (required for all Heroku apps regardless of language/framework)
    2. requirements.txt

    Procfile is your process file and tells Heroku what you want it to do. In this case it is telling Heroku that for the web instances you want it to simply run python hello.py which is what you do to get the app going locally

    requirements.txt tells Heroku (and any other user) what dependencies you want loaded to make the app run properly. It is really easy to generate from within your virtual environment. You simply run pip freeze > requirements.txt in the project directory.

    Protip: To install the requirements from a requirements.txt file you'll just use pip install -r requirements.txt and it will run through the file and install the dependencies.

    opened by jeremiak 5
  • Made hello runnable without gunicorn in debug mode

    Made hello runnable without gunicorn in debug mode

    You can run it like this:

    $ python hello.py
    

    Flask’s debug mode outputs better error details than gunicorn, during dev + debug time. Also, auto-reloads the server when source files change!

    opened by migurski 2
A service to auto provision devices in Aruba Central based on the Geo-IP location

Location Based Provisioning Service for Aruba Central A service to auto provision devices in Aruba Central based on the Geo-IP location Geo-IP auto pr

Will Smith 3 Mar 22, 2022
Imports VZD (Latvian State Land Service) open data into postgis enabled database

Python script main.py downloads and imports Latvian addresses into PostgreSQL database. Data contains parishes, counties, cities, towns, and streets.

Kaspars Foigts 7 Oct 26, 2022
IP Denial of Service Vulnerability ")A proof of concept for CVE-2021-24086 ("Windows TCP/IP Denial of Service Vulnerability ")

CVE-2021-24086 This is a proof of concept for CVE-2021-24086 ("Windows TCP/IP Denial of Service Vulnerability "), a NULL dereference in tcpip.sys patc

Carry 1 Nov 25, 2021
pyinfra automates infrastructure super fast at massive scale. It can be used for ad-hoc command execution, service deployment, configuration management and more.

pyinfra automates/provisions/manages/deploys infrastructure super fast at massive scale. It can be used for ad-hoc command execution, service deployme

Nick Barrett 2.1k Dec 29, 2022
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

Thumbor (by @globocom) 9.3k Dec 31, 2022
Automatically generate a RESTful API service for your legacy database. No code required!

sandman2 sandman2 documentation [ ~ Dependencies scanned by PyUp.io ~ ] sandman2 automagically generates a RESTful API service from your existing data

Jeff Knupp 1.9k Jan 7, 2023
Python bindings for Alexa Web Information Service (AWIS) API

Attention! This package is no longer maintained. See this ticket for more info. Wraps Alexa Web Information Service. Usage Making UrlInfo requests: ap

Atamert Ölçgen 51 Feb 12, 2022
A simple Python wrapper for the archive.is capturing service

archiveis A simple Python wrapper for the archive.is capturing service. Installation pipenv install archiveis Python Usage Import it. >>> import archi

PastPages 157 Dec 28, 2022
:globe_with_meridians: A Python wrapper for the Geocodio geolocation service API

Py-Geocodio Python wrapper for Geocodio geocoding API. Full documentation on Read the Docs. If you are upgrading from a version prior to 0.2.0 please

Ben Lopatin 84 Aug 2, 2022
Open source vulnerability DB and triage service.

OSV - Open Source Vulnerabilities OSV is a vulnerability database and triage infrastructure for open source projects aimed at helping both open source

Google 893 Jan 4, 2023