Giter VIP home page Giter VIP logo

openelevationservice's Introduction

Build status

Documentation Status

Quickstart

Description

openelevationservice is a Flask application which extracts elevation from various elevation datasets for Point or LineString 2D geometries and returns 3D geometries in various formats.

Supported formats are:

  • GeoJSON
  • Polyline, i.e. list of vertices
  • Google's encoded polyline
  • Point, i.e. one vertex

For general support and questions, please contact our forum. After successful installation, you can also find a API documentation locally at https://localhost:5000/apidocs, provided via flasgger.

For issues and improvement suggestions, use the repo's issue tracker.

This service is part of the GIScience software stack, crafted at HeiGIT institute at the University of Heidelberg.

You can also use our free API via (also check Endpoints for usage):

Installation

You can either run this service on a host machine (like your PC) in a virtual environment or via docker (recommended).

Docker installation

Prerequisites

Run Docker container

  1. Customize ops_settings_docker.sample.yml to your needs and name it ops_settings_docker.yml
  2. Build container sudo docker-compose up -d
  3. Create the database
sudo docker exec -it <container ID> bash -c "source /oes_venv/bin/activate; export OES_LOGLEVEL=DEBUG; flask create"
  1. Download SRTM data
sudo docker exec -it <container ID> bash -c "source /oes_venv/bin/activate; export OES_LOGLEVEL=DEBUG; flask download --xyrange=0,0,73,25"

The optional xyrange parameter specfies the minx,miny,maxx,maxy indices of the available tiles, default is 0,0,73,25. You can see a representation of indices in the map on the CGIAR website.

Note, that you need to have credentials to access the FTP site , which you can request here.

  1. Import SRTM data
sudo docker exec  -it <container ID> bash -c "source /oes_venv/bin/activate; flask importdata"

The import command will import whatever .tif files it finds in ./tiles. Now, it's time to grab a coffee, this might take a while. Expect a few hours for a remote database connection with HDD's and the global dataset.

After it's all finished, the service will listen on port 5020 of your host machine, unless specified differently in docker-compose.yml.

Conventional installation

This tutorial assumes a Ubuntu system.

Max OSX should be similar, if not the same. Windows is of course possible, but many of the commands will have to be altered.

Prerequisites

  • Python 3.6 or higher
  • PostGIS installation on the host machine (solely needed for raster2pgsql)
  • (Optional) Remote PostGIS installation (if you want to use a different data server)

Create virtual environment

First, customize ./openelevationservice/server/ops_settings.sample.yml and name it ops_settings.yml.

Then you can set up the environment:

cd openelevationservice
# Either via virtualenv, venv package or conda
python3.6 -m venv .venv
# or
virtualenv python=python3.6 .venv
# or
conda create -n oes python=3.6

# Activate virtual env (or equivalent conda command)
source .venv/bin/activate
# Add FLASK_APP environment variable
# For conda, see here: https://conda.io/docs/user-guide/tasks/manage-environments.html#macos-and-linux
echo "export FLASK_APP=manage" >> .venv/bin/activate
# Install required packages
pip install -r requirements.txt

When your environment is set up, you can run the import process and start the server:

# inside the repo root directory
flask create
# rather as a background/nohup job, will download 27 GB
flask download --xyrange=0,0,73,25
flask importdata

# Start the server
flask run

The service will now listen on `http://localhost:5000.

Endpoints

The default base url is http://localhost:5000/.

The openelevationservice exposes 2 endpoints:

  • /elevation/line: used for LineString geometries
  • /elevation/point: used for single Point geometries
Endpoint Method(s) allowed Parameter Default Values
/elevation/line
POST

format_in

------------+

geometry

------------+

format_out

------------+

dataset

--

---------+

--

---------+

geojson

---------+

srtm

geojson, polyline, encodedpolyline5, encodedpolyline6

---------------------------------------------------------+

depends on format_in

---------------------------------------------------------+

geojson, polyline, encodedpolyline5, encodedpolyline6

---------------------------------------------------------+

srtm (so far)

/elevation/point
GET, POST

format_in

------------+

geometry

------------+

format_out

------------+

dataset

--

---------+

--

---------+

geojson

---------+

srtm

geojson, point

---------------------------------------------------------+

depends on format_in

---------------------------------------------------------+

geojson, point

---------------------------------------------------------+

srtm (so far)

For more detailed information, please visit the API documentation.

When hosted locally, visit https://localhost:5000/apidocs.

Environment variables

openelevationservice recognizes the following environment variables:

variable function Default Values
OES_LOGLEVEL Sets the level of logging output INFO DEBUG, INFO, WARNING, ERROR
APP_SETTINGS Controls the behavior of config.py openelevationservice.server.config.ProductionConfig

ProductionConfig,

DevelopmentConfig

FLASK_APP Sets the app manage
FLASK_ENV Development/Production server development production, development
TESTING Sets flask testing environment None true

In the case of the Docker setup, you don't need to worry about environment variables for the most part.

CLI

The flask command line interface has a few additional commands:

  • flask create: creates a table for CGIAR data
  • `flask download --xyrange=0,73,0,25: downloads CGIAR data and limits the X, Y indices optionally with xyrange
  • flask importdata: imports CGIAR tiles it finds in ./tiles/
  • flask drop: drops CGIAR table

Testing

The testing framework is nosetests, which makes it very easy to run the tests:

TESTING=true nosetests -v

Usage

GET point

curl -XGET https://localhost:5000/elevation/point?geometry=13.349762,38.11295

POST point as GeoJSON

curl -XPOST http://localhost:5000/elevation/point \
  -H 'Content-Type: application/json' \
  -d '{
    "format_in": "geojson",
    "format_out": "geojson",
    "geometry": {
      "coordinates": [13.349762, 38.11295],
      "type": "Point"
    }
  }'

POST LineString as polyline

curl -XPOST http://localhost:5000/elevation/line \
  -H 'Content-Type: application/json' \
  -d '{
    "format_in": "polyline",
    "format_out": "encodedpolyline",
    "geometry": [[13.349762, 38.11295],
                 [12.638397, 37.645772]]
  }'

openelevationservice's People

Contributors

nilsnolde avatar thegreatrefrigerator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openelevationservice's Issues

API fails with complex encoded polylines

Hi!

We are testing the service and found that with encoded polylines with many points (more than 300) the API returns http 400. It does work with simpler encoded polylines.

Is there a known limit in the number of points for the /elevation/line endopoint?

Thanks!

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Hi,

I get the following error after: sudo docker-compose up -d

#0 32.10     copying src/greenlet/platform/switch_x86_unix.h -> build/lib.linux-x86_64-3.6/greenlet/platform
#0 32.10     running build_ext
#0 32.10     building 'greenlet._greenlet' extension
#0 32.10     creating build/temp.linux-x86_64-3.6
#0 32.10     creating build/temp.linux-x86_64-3.6/src
#0 32.10     creating build/temp.linux-x86_64-3.6/src/greenlet
#0 32.10     x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/oes_venv/include -I/usr/include/python3.6m -c src/greenlet/greenlet.cpp -o build/temp.linux-x86_64-3.6/src/greenlet/greenlet.o
#0 32.10     unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
#0 32.10     error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
#0 32.10     
#0 32.10     ----------------------------------------
#0 32.21 Command "/oes_venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9yrh8slh/greenlet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-xmv34gcf-record/install-record.txt --single-version-externally-managed --compile --install-headers /oes_venv/include/site/python3.6/greenlet" failed with error code 1 in /tmp/pip-build-9yrh8slh/greenlet/
------
failed to solve: executor failed running [/bin/sh -c /oes_venv/bin/pip3 install -r /deploy/app/requirements.txt]: exit code: 1
(base) beatgurtner@bg openelevationservice % 

I did not change the content of the *.yml file:

---
attribution: "service by https://openrouteservice.org | data by http://srtm.csi.cgiar.org"
coord_precision: 1e-6
maximum_nodes: 2000
srtm_parameters:
  user: 
  password: 
provider_parameters:
  table_name: oes_cgiar
  db_name: 
  user_name:
  password:
  host: localhost
  port: 5432

Should I change something?

Any idea why I'm getting this error above?

Im using MacOS 13.1 with conda.io, Python 3.11.0 and installed Docker v4.16.2.

State information about elevation units

currently it is implied that the elevation unit is meters above sea level.
This should be stated somewhere, so people using other elevation units aren't confused.

Backwards compatibility of encodedpolyline

Recent updates to the package introduced improvements to encodedpolyline format by adding support for increased precision. While implementing the new encodedpolyline6 format the originally accepted encodedpolyline parameter value was renamed to encodedpolyline5.

This approach, however, breaks backwards compatibility. Apart from it there is also no particular reason to use a different name for the format which follows Google's encoded polyline standard. Please consider renaming encodedpolyline5 to just encodedpolyline.

Cheers,
Andrzej

Building Docker image fails with no acceptable C compiler found

I've tried building the Docker image, which failed with the following message. This happens during the step where the Python requirements are installed.

configure: error: in `/tmp/pip-build-mmeastyv/gevent/deps/libev':
configure: error: no acceptable C compiler found in $PATH

Attached you can find the full log output from the beginning of the step.
I guess this is because the newer Ubuntu Docker images are smaller than before. I'm sure they dropped everything from the image that is not needed.

I'm currently trying to fix this issue and prepare a pull request afterwards.

docker_build.log

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.