Explore GeoJSON for use in geographical information systems (GIS)

In the following we will show you how get polygons for 600/1200s traveltime with walk routing in the center of Berlin in JavaScript, Python and on the command line with Curl.

Buffering and simplifying GeoJSON outputs is not available for all plan levels. Check our plans for details.

Route360° JavaScript API

Important: Since the returned coordinates are in CRS 3857 (Web mercator) and the Leaflet polygon layer only supports CRS 4326 (WGS84), we first need to project the coordinates.

To generate GeoJson with the Javascript API we first need to create a travel options object and switch from the default polygon serialization to the GeoJson version with travelOptions.setPolygonSerializer('geojson');

var travelOptions = r360.travelOptions();
// set the service API-key
travelOptions.setServiceKey('<your service key>');
travelOptions.setServiceUrl('https://service.route360.net/germany/');
travelOptions.addSource({ lat : 52.52, lng : 13.405 });            
travelOptions.setTravelTimes([600, 1200]);
travelOptions.setTravelType('walk');
// request geojson
travelOptions.setPolygonSerializer('geojson');
// wgs84
travelOptions.setSrid(4326);
// add 50m buffer to clean up the thin lines
// !!! wgs84 uses degrees as the unit! Longitudinal degrees are closer together at the poles, so we may need to calculate degrees for our latitude...
// ~50m in longitudinal degrees at 52° latitude
var bufferLengthsMeters = r360.Util.metersInDegrees(50, latlon[0]);
travelOptions.setBuffer(bufferLengthsMeters.lng);

Now we can use the polygon service to send the request and even use the default GeoJson layer from Leaflet to display the polygons.

r360.PolygonService.getTravelTimePolygons(travelOptions, function(geojsonPolygons){  
    L.geoJson(geojsonPolygons, {
        "fillColor" : "#006837",
        "fillOpacity" : 0.4,
        "color" : "#006837",
        "stroke" : false,
        "fill" : true
    }).addTo(map);
});
Displaying raw geoJSON in leaflet

Just need the data?

GET YOUR FREE API KEY to use this example
reload
open in new tab
show code

Route360° Python API

If you have python3 installed you can pip install r360_py and get the data via the cli (or module integration in a python app, if you want):

python -m r360_py.cli \
    --travelType walk \
    --travelTime 600 1200 \
    --source "52.52;13.405" \
    --outputDir data/ \
    --outputFilename test.geojson \
    --srid 4326 \
    --serviceKey <your service key> \
    --serviceUrl http://service.route360.net/germany/

You can then drag and drop the generated file to QGIS or any other GIS as long as it supports GeoJSON. In case GeoJson is not supported, you can transform the result very easily with ogr2ogr to, let's say an ESRI Shapefile:

/usr/local/bin/ogr2ogr -f "ESRI Shapefile" 'data/output_filename.shp' 'data/input_filename.geojson'

Command line usage

If you prefer to do things on the command line you can use Curl. But you need generate the request URL, e.g. the polygon configuration, yourself. So let's define a configuration for 600/1200s walking in Berlin center.

{
    'sources': [{
        'lat': 52.52,
        'lng': 13.405,
        'id': 'HG26SJ9SK',
        'tm': {
            'walk': {}
        }
    }],
    'polygon': {
        'serializer': 'geojson',
        'srid': '4326',
        'values': [600,1200]
    }
}

For the POST polygon service we simply need to make the configuration a one-liner:

curl --compressed -H 'Content-Type: application/json' --data "{'sources':[{'lat':52.52,'lng':13.405,'id':'HG26SJ9SK','tm':{'walk':{}}}],'polygon':{'serializer':'geojson','srid':'4326','values':[1200,600]}}" 'https://service.route360.net/brandenburg/v1/polygon_post?key=YOUR_KEY_HERE' > berlin_center_600s_1200s_walk_post.geojson

If using GET the -g option is the important one here, which disables the globbing and makes it possible to just write a javascript object there.

curl --compressed -g "https://service.route360.net/brandenburg/v1/polygon?cfg={'sources':[{'lat':52.52,'lng':13.405,'id':'HG26SJ9SK','tm':{'walk':{}}}],'polygon':{'serializer':'geojson','srid':'4326','values':[600,1200]}}&key=<YOUR KEY HERE>" > berlin_center_600s_1200s_walk_get.geojson