Last updated: 2026-03-04 01:47:03
Web services
Introduction
In this chapter we introduce and demonstrate routing web services, where routing calculations are provided by a server, over the network, to be consumed in different kinds of applications. The Google Maps platform—accessible through the web browser (Figure 14.1) or a mobile application—is a well-known example of an interface providing a routing service for end users. Behind the scenes, the routing calculations (Routing) are being processed on Google servers. This means that the application (e.g., the Google Maps website) and the server (e.g., Google) need to communicate. For example, when the user chooses the origin and destination points on a map (Figure 14.1), the coordinates (and other settings, such as travel mode, etc.) are sent to the Google Server for processing. When done, the calculated route is then sent to back from the server to the web application. The software components which make it possible for the application(s) to communicate with a server are known as application programming interfaces (APIs). For example, the API to access the routing calculations on Google servers is the Routes API. Developers and researchers can access the API directly, to calculate specific routes in an automated way, or to build their own application using the service. Developers can also build their own API, to be consumed by an application they build or exposed to the public.
In this chapter, we explore both points of view of routing web services:
- In the first part, we demonstrate consumption of an existing routing service, namely a commercial service called the Mapbox Directions API. We are going to see how a routing calculation request can be sent to the Mapbox server, and how the response can be received and processed (Using routing APIs).
- In the second part, we learn how to build our own routing API, based on the Beer-Sheva roads network which we built in OpenStreetMap and osmnx.
- First, we go over the basics of building an API with the
fastapiPython package (fastapi) - Second, we demonstrate building a minimal routing API, which accepts origin and destination coordinates, and returns the geometry and travel time of the fastest route (Building a routing API)
- First, we go over the basics of building an API with the
Packages
import ssl
import urllib.request
import json
import shapely
import geopandas as gpdUsing routing APIs
What is the Mapbox Directions API?
Mapbox Directions API is a commercial service of routing calculations, provided by Mapbox. It is analogous to the Routes API provided by Google which was mentioned above (see Introduction). However, at the time of writing, Google API require registering with a credit card (although there is a free montly quota). The Mapbox Directions API, at the time of writing, provides 100,000 monthly requests for free without requiring a credit card, which is why we chose it for demonstration. It is important to note that Google and Mapbox are just two (well-known) examples of companies providing commercial routing services, and there are many others. Also, these companies typically provide many APIs other than for routing.
After registring on the Mapbox website, you can go to the “Account overview” page and generate a “token”. The token acts as a password in API requests: the token is sent along with each API request (see Sending an API request), so that the Mapbox server can associate the request with your account and monitor your usage. Therefore, importantly, API tokens are supposed to be private whenever possible. Otherwise, other people can take advantage of your account.

Sending an API request
An API request is typically sent through using the HTTP communication protocol, over the internet network. HTTP is also being used, for example, when you type a URL into the address bar of a web browser and press enter. The URL represents a request, which is sent to a web server. The server then responds with data, typically HTML and other types of content, which the browser processes into the web page you see on screen. The same concepts of the URL, request, and response are applicable to APIs too:
- The URL is typically composed of “fixed” parts with embedded parameter values, such as the coordinates of route origin and destination and the API token. The API documentation explains how the URL has to be composed and typically provides complete examples
- The request can be sent by pasting the URL in the browser address bar (Figure 14.3), but more often it is sent programmatically, from an application (such as a web map) or from a script written in a programming language such as Python (see below)
- The response contains the calculation result(s), such as the properties of the calculated optimal routes. The response can also be an error message, if no route could be found between the given locations, if the token is incorrect or missing, etc. The response format is typically JSON, a common data format in web applications, analogous to Python dictionaries (see below)
API documentation often also provides interactive pages referred to as a “playground” (Figure 14.2) where you can learn how to compose the API request URLs. There, you can interactively enter specific API parameters—e.g., choose origin and destination locations on a map. Then, you can inspect the corresponding request URL as well as the API response.
For example, here is the URL for calculting the optimal route from Ramot Sportiv to IKEA (Figure 11.4) using the Mapbox Directions API. Note that the access token in the last part of the URL was omitted and replaced with ***:
When pasting the URL (with the token included) into the address bar of a web browser, a JSON string with the properties of the calculated optimal route is returned (Figure 14.3):
The following code section demonstrates how the API request can be executed from the Python environment, instead of the browser. The first part of the code reads the token from the local disk. This is much better practice than embedding the token into the script, for security reasons. The second part of the code then composes the URL, sends the API resuest, and reads the response into a variable named res:
# Read API token
f = open('/home/michael/sync/bgu/key_mapbox')
key = f.readline()
f.close()
# Send request
url = 'https://api.mapbox.com/directions/v5/mapbox/driving/34.799315%2C31.280176%3B34.823224%2C31.224069?alternatives=false&geometries=geojson&overview=full&steps=false&access_token=' + key
response = urllib.request.urlopen(url)
res = response.read().decode('utf-8')
response.close()To run the above code on your own you need to register on Mapbox and get your own token. If you’d rather not do that, you can use the mapbox_response.json file provided with the book materials, where a response corresponding to the above request was saved into a JSON file, as follows:
f = open('data/mapbox_response.json', 'w')
f.write(res)
f.close()Here is how we can read the file contents into the Python environment:
f = open('data/mapbox_response.json', encoding='utf-8')
res = f.readline()
f.close()Either way, you should now have an object with the API response in the JSON format, represented in Python as a string (str):
res'{"routes":[{"weight_name":"auto","weight":1019.888,"duration":887.643,"distance":9037.782,"legs":[{"via_waypoints":[],"admins":[{"iso_3166_1_alpha3":"ISR","iso_3166_1":"IL"}],"weight":1019.888,"duration":887.643,"steps":[],"distance":9037.782,"summary":"שדרות בנ\\"צ כרמל, 40"}],"geometry":{"coordinates":[[34.799258,31.280253],[34.799245,31.280246],[34.799224,31.280231],[34.799206,31.280213],[34.799191,31.280193],[34.79918,31.28017],[34.799173,31.280146],[34.799171,31.280121],[34.799173,31.280096],[34.79918,31.280072],[34.799191,31.28005],[34.799206,31.28003],[34.799224,31.280012],[34.799245,31.279996],[34.799269,31.279983],[34.799295,31.279974],[34.799323,31.279968],[34.799352,31.279966],[34.799382,31.279968],[34.79941,31.279974],[34.799436,31.279983],[34.79946,31.279996],[34.799481,31.280012],[34.799499,31.28003],[34.79953,31.280061],[34.799549,31.280077],[34.799568,31.28009],[34.799589,31.280102],[34.79961,31.280112],[34.799631,31.28012],[34.799654,31.280127],[34.799676,31.280134],[34.799699,31.28014],[34.799722,31.280145],[34.800199,31.280184],[34.800763,31.280229],[34.801225,31.280272],[34.801291,31.280269],[34.801359,31.280267],[34.801427,31.280265],[34.801495,31.280262],[34.801561,31.280258],[34.801626,31.280251],[34.801687,31.280242],[34.801745,31.280228],[34.801798,31.280208],[34.801852,31.280173],[34.80187,31.280156],[34.80189,31.280141],[34.801904,31.280127],[34.801917,31.280114],[34.801929,31.280099],[34.801941,31.280083],[34.801952,31.280065],[34.801965,31.280041],[34.801978,31.280014],[34.801991,31.279977],[34.802003,31.279934],[34.802078,31.279547],[34.8024,31.27797],[34.802428,31.277818],[34.802433,31.277776],[34.802432,31.277746],[34.802428,31.277722],[34.802421,31.27769],[34.802405,31.27764],[34.802377,31.277621],[34.802355,31.277597],[34.802341,31.277571],[34.802334,31.277544],[34.802333,31.277516],[34.802339,31.277489],[34.802351,31.277463],[34.80237,31.27744],[34.802389,31.277424],[34.802411,31.27741],[34.802447,31.277398],[34.802485,31.277393],[34.802524,31.277396],[34.802561,31.277407],[34.802593,31.277426],[34.802608,31.277439],[34.802676,31.277456],[34.802716,31.277462],[34.80276,31.277465],[34.802801,31.277462],[34.802997,31.277445],[34.80319,31.277427],[34.803495,31.277393],[34.803785,31.277352],[34.804068,31.277305],[34.80437,31.277228],[34.804749,31.27711],[34.805108,31.276993],[34.805401,31.276875],[34.805594,31.276777],[34.805839,31.276653],[34.806589,31.276169],[34.807171,31.275694],[34.807365,31.2755],[34.810365,31.271793],[34.81076,31.271271],[34.810855,31.271158],[34.811062,31.270898],[34.813249,31.26823],[34.813239,31.268199],[34.813237,31.268167],[34.813248,31.268129],[34.813272,31.268095],[34.813306,31.268068],[34.813349,31.268052],[34.813385,31.268047],[34.813455,31.267969],[34.814467,31.266614],[34.814762,31.266218],[34.814966,31.265953],[34.816082,31.264562],[34.81633,31.264269],[34.816337,31.264206],[34.81636,31.264157],[34.816398,31.264115],[34.816447,31.264082],[34.816504,31.264062],[34.816568,31.264055],[34.816632,31.264063],[34.816875,31.263869],[34.816991,31.263785],[34.819612,31.261902],[34.820293,31.261422],[34.82036,31.261357],[34.820397,31.26132],[34.820426,31.261268],[34.820445,31.261221],[34.820482,31.261182],[34.820532,31.261156],[34.82059,31.261147],[34.820667,31.261133],[34.82072,31.261111],[34.820783,31.261077],[34.822808,31.25965],[34.823039,31.259483],[34.82331,31.259287],[34.823379,31.259211],[34.823433,31.25914],[34.823435,31.259102],[34.823469,31.259035],[34.823506,31.258998],[34.823529,31.258974],[34.823606,31.25893],[34.823622,31.258925],[34.823688,31.258908],[34.823763,31.258912],[34.823842,31.258902],[34.823917,31.25887],[34.824237,31.258643],[34.824385,31.258538],[34.825641,31.257653],[34.826045,31.257333],[34.826221,31.25721],[34.826588,31.256952],[34.827255,31.256482],[34.827851,31.256046],[34.82813,31.255817],[34.828253,31.255698],[34.828301,31.255641],[34.828505,31.255386],[34.828688,31.255092],[34.828806,31.254794],[34.828886,31.254519],[34.828929,31.254207],[34.828937,31.254016],[34.828933,31.253683],[34.828802,31.251161],[34.828677,31.250057],[34.828629,31.249227],[34.828623,31.248213],[34.82868,31.247451],[34.828777,31.246822],[34.828793,31.246727],[34.828806,31.246649],[34.828961,31.245966],[34.829154,31.245251],[34.829305,31.24481],[34.829487,31.244379],[34.829809,31.243723],[34.83014,31.243152],[34.830813,31.242],[34.831148,31.241433],[34.831815,31.240178],[34.831965,31.239848],[34.832175,31.239284],[34.832303,31.238724],[34.832416,31.237917],[34.83244,31.237164],[34.832384,31.236541],[34.832223,31.235862],[34.832153,31.235619],[34.832028,31.235276],[34.831456,31.234087],[34.830587,31.232399],[34.830088,31.231156],[34.829923,31.23065],[34.829868,31.23043],[34.829195,31.228381],[34.828978,31.22788],[34.828755,31.227445],[34.828669,31.227312],[34.828492,31.227064],[34.828111,31.226582],[34.827961,31.226339],[34.827843,31.226101],[34.8278,31.225981],[34.827704,31.225821],[34.827655,31.225747],[34.827591,31.225679],[34.827521,31.225637],[34.827446,31.225624],[34.827171,31.225621],[34.823062,31.226503],[34.822152,31.226699],[34.821788,31.226775],[34.821672,31.226802],[34.821638,31.226687],[34.821758,31.226661],[34.822116,31.226583],[34.822677,31.226461],[34.822737,31.226428],[34.822763,31.226411],[34.822787,31.226392],[34.82281,31.22637],[34.82283,31.226345],[34.822846,31.226318],[34.822857,31.226286],[34.822863,31.226252],[34.822862,31.226213],[34.822853,31.22617],[34.822761,31.225888],[34.822708,31.225715],[34.822705,31.225707],[34.822701,31.2257],[34.822698,31.225693],[34.822694,31.225686],[34.822689,31.22568],[34.822685,31.225674],[34.822679,31.225668],[34.822673,31.225662],[34.822656,31.22565],[34.82264,31.225644],[34.822624,31.225635],[34.822611,31.225625],[34.822599,31.225614],[34.822589,31.225601],[34.822582,31.225586],[34.822578,31.225571],[34.822576,31.225554],[34.822578,31.225538],[34.822582,31.225523],[34.822589,31.225508],[34.822599,31.225495],[34.822611,31.225479],[34.822615,31.225473],[34.822618,31.225466],[34.82262,31.225459],[34.822622,31.225451],[34.822624,31.225444],[34.822625,31.225437],[34.822625,31.225429],[34.822625,31.225421],[34.822624,31.225413],[34.822566,31.225137],[34.822507,31.224945],[34.822419,31.224656],[34.822391,31.224565],[34.822155,31.223792],[34.822449,31.22372],[34.822422,31.223632],[34.823149,31.22346],[34.823226,31.22343],[34.8233,31.22339],[34.823356,31.223353],[34.823528,31.223212],[34.824352,31.223943],[34.824127,31.22415],[34.823952,31.224075],[34.8239,31.224035],[34.823869,31.223929]],"type":"LineString"}}],"waypoints":[{"distance":10.147,"name":"","location":[34.799258,31.280253]},{"distance":63.304,"name":"","location":[34.823869,31.223929]}],"code":"Ok","uuid":"-E1gTf9SFJWKz42FkTzxbJgjRsb2tvdvKAoOU2xcqKRgiUCP5KFjZg=="}'
Processing the API response
It would be difficult to work with the response in the “raw” string format. For easier access to its components, the first thing we do is transforming the JSON string into a Python dict. The transformation is done using the json.loads function:
res = json.loads(res)The API documentation and/or playground (Figure 14.2) can be used to figure out the structure and meaning of the response components. Here we will demonstrate how the most important components which we focused on in this book (Routing) can be extracted, namely the route geometry, its length, and its total travel time.
First of all, we access the response property named routes, which contains the returned routes:
res.keys()dict_keys(['routes', 'waypoints', 'code', 'uuid'])
res['routes'] is a list of routes:
type(res['routes'])list
In our case, there is just one calculated route. We use the index 0 to access it. “Inside” the route, we can see the three route properties we are interested in: 'duration', 'distance', and 'geometry':
res['routes'][0].keys()dict_keys(['weight_name', 'weight', 'duration', 'distance', 'legs', 'geometry'])
Here are the final three expressions to access the contents of these properties for the given route. 'duration' and 'distance' are plain numeric values, in \(sec\) and \(m\) units, respectively:
res['routes'][0]['duration'] ## Time in seconds887.643
res['routes'][0]['distance'] ## Distance in meters9037.782
The 'geometry' property is returned as a string in the GeoJSON format, representing an individual geometry. To make further calculations with the geometry in the Python environment, we can transform a GeoJSON string to a shapely geometry using shapely.geometry.shape:
geom = res['routes'][0]['geometry']
geom = shapely.geometry.shape(geom)
geomfastapi
Overview
In the previous section we learned how to use, or “consume”, an exising routing API which was set up by a commercial complany. In this section and the next one, we learn how to set up our own API, which can then be used by applications we, or other people, build.
In terms of software, we are going to use the Python fastapi package to build the API. In this section we go over the basics of fastapi, building and testing a minimal API. In the next section (Building a routing API), we will use fastapi to build an actual routing API.
A minimal API
The following script defines a minimal API using fastapi. This API returnes the fixed response {"message":"Hello World"}. Pay attention to two important points about the code:
- the
.getpart specifies a response to theGETHTTP method - the
"/"part specifies the URL path, in this case the base URL or the “root”
Overall, the script specifies that when the GET method is used to request the base URL, the f function is executed:
import fastapi
app = fastapi.FastAPI()
@app.get("/")
async def f():
return {"message": "Hello World"}The above script needs to be saved into a file. Let’s assume the script is saved into a file named api_01.py. Then, the API can be started, in “development” mode, using the following expression on the command line:
fastapi dev api_01.pyor in “production” mode, using the following expression:
fastapi run api_01.pyYou can also choose the port where the application will be running, using the --port command line argument. For example, here we specify that the API will be running in port 8000:
fastapi dev --port 8000 api_01.pyIn any case, you will see a printout with information about your API in the command line. There, you will also see the URL you can use to access the API, such as http://127.0.0.1:8000.
You should keep the command line window open for as long as the application is running. When done, you can shut down the application by pressing Ctrl+C.
API parameters
Typically, the API request isn’t fixed. Instead, it depends on the values of one or more parameters. For example, in a routing API, the parameters may be the origin and destination coordinates and the travel mode (see Sending an API request).
The following script defines another minimal API, this time also using parameters. In this example, there are two parameters, x and y which are supposed to be of type float, both with the default value of 0. The function then calculates the result of x+y, and returns both the inputs and the result:
import fastapi
app = fastapi.FastAPI()
@app.get("/")
async def f(x: float = 0, y: float = 0):
result = x + y
return {'x': x, 'y': y, 'sum': result}Assuming the script is in a file named api_02.py, here is how it can be started from the command line:
fastapi dev --port 8000 api_02.pyNow, you can access the API using the URL:
Since no parameter values were specified as part of the URL, the API uses the default values of 0, and the result you should see is {"x":0.0,"y":0.0,"sum":0.0}:
To specify parameter values as part of the URL, use the following format, known as the query string. The query string comes in the end of the URL. It begins with ?, followed by one or more assignments of the parameter values such as x=4.2 and y=1.2, separated by &:
http://127.0.0.1:8000/?x=4.2&y=1.2
The response should now be {"x":4.2,"y":1.2,"sum":5.4}.
Note that it is essential to specify the data types of the function inputs, such as float for x and y in the last example. Otherwise, by default, the inputs are interpreted as str.
Building a routing API
Expanding the minimal structure in API parameters, we can build a routing API with fastapi. The code loads the Beer-Sheva road network from the file beer-sheva.xml which we prepared earlier (Writing the Beer-Sheva network). Then, the script defines a function named route, which accepts two point coordinates orig and dest, and calculates the fastest route between them(Routing (OSM)). In the end, the function returns the geometry and the total travel time for that route:
import fastapi
import shapely
import pyproj
import geopandas as gpd
import networkx as nx
import net2
# App
app = fastapi.FastAPI()
# Network data
G = nx.read_graphml('output/beer-sheva.xml')
G = net2.prepare(G)
crs = 32636
transformer = pyproj.Transformer.from_crs(4326, crs, always_xy=True)
# App
@app.get("/")
def route(orig: str, dest: str):
orig = orig.split(',')
dest = dest.split(',')
orig = [float(i) for i in orig]
dest = [float(i) for i in dest]
orig = shapely.Point(orig[0], orig[1])
dest = shapely.Point(dest[0], dest[1])
orig = shapely.transform(orig, transformer.transform, interleaved=False)
dest = shapely.transform(dest, transformer.transform, interleaved=False)
route = net2.route2(G, orig, dest, 'time')
route_gdf = net2.route_to_gdf(route['network'], route['route'], crs)
route_gdf = route_gdf.to_crs(4326)
route_gdf = route_gdf.geometry.to_json()
return {'geometry': route_gdf, 'time': route['weight']}Assuming the script is stored in a file named api_03.py, you can start the API with:
fastapi dev --port 8000 api_03.pyThen, the API can be called with specific origin and destination points. For example, here we calculate the fastest route between Ramot and IKEA in Beer-Sheva:
http://127.0.0.1:8000/?orig=34.799315,31.280176&dest=34.823224,31.224069
If all wored well, pasting the above URL into the browser address bar will return a response such as the one shown in Figure 14.4:
fastapi
The above API is also continuously being run on a server for demonstration purposes. You can try it as follows:
https://geobgu.xyz/routing_api?orig=34.799315,31.280176&dest=34.823224,31.224069
Either way, you can also access the API in a Python environment, as follows:
url = 'https://geobgu.xyz/routing_api?orig=34.799315,31.280176&dest=34.823224,31.224069'
response = urllib.request.urlopen(url, context=ssl._create_unverified_context())
dat = json.loads(response.read().decode('utf-8'))
response.close()The variable named dat now contains a dict with two properties, 'geometry' and 'time':
dat{'geometry': '{"type": "FeatureCollection", "features": [{"id": "0", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.79925911307734, 31.280253865747795], [34.79925911307725, 31.280253865747742], [34.7992452, 31.28024649999999]]}, "bbox": [34.7992452, 31.28024649999999, 34.79925911307734, 31.280253865747795]}, {"id": "1", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.7992452, 31.28024649999999], [34.7992241, 31.280230999999993], [34.7992059, 31.2802129]]}, "bbox": [34.7992059, 31.2802129, 34.7992452, 31.28024649999999]}, {"id": "2", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.7992059, 31.2802129], [34.7991912, 31.280192600000003], [34.7991802, 31.280170299999998], [34.7991733, 31.280146400000003], [34.7991709, 31.2801213], [34.7991733, 31.28009610000001], [34.7991802, 31.280072200000003], [34.7991912, 31.280049999999996], [34.7992059, 31.280029700000004]]}, "bbox": [34.7991709, 31.280029700000004, 34.7992059, 31.2802129]}, {"id": "3", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.7992059, 31.280029700000004], [34.7992241, 31.280011599999995], [34.7992452, 31.279996099999995], [34.799269, 31.279983399999995]]}, "bbox": [34.7992059, 31.279983399999995, 34.799269, 31.280029700000004]}, {"id": "4", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.799269, 31.279983399999995], [34.7992951, 31.279974], [34.799323, 31.279968199999995], [34.7993524, 31.279966099999992], [34.7993819, 31.279968199999992], [34.7994098, 31.279974], [34.7994359, 31.279983399999995], [34.7994596, 31.2799961]]}, "bbox": [34.799269, 31.279966099999992, 34.7994596, 31.2799961]}, {"id": "5", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.7994596, 31.2799961], [34.7994808, 31.280011600000005], [34.7994989, 31.280029699999993]]}, "bbox": [34.7994596, 31.2799961, 34.7994989, 31.280029699999993]}, {"id": "6", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.7994989, 31.280029699999993], [34.7995302, 31.280061300000007], [34.7995487, 31.280077], [34.7995682, 31.280090500000007], [34.7995886, 31.280102000000003], [34.7996097, 31.280111800000004], [34.79963140000001, 31.280120199999995], [34.7996536, 31.28012749999999], [34.79967620000001, 31.280133799999994], [34.799699100000005, 31.2801396], [34.7997221, 31.2801451]]}, "bbox": [34.7994989, 31.280029699999993, 34.7997221, 31.2801451]}, {"id": "7", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.7997221, 31.2801451], [34.8001991, 31.2801838], [34.8007628, 31.280229499999994]]}, "bbox": [34.7997221, 31.2801451, 34.8007628, 31.280229499999994]}, {"id": "8", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8007628, 31.280229499999994], [34.8012248, 31.280271899999995]]}, "bbox": [34.8007628, 31.280229499999994, 34.8012248, 31.280271899999995]}, {"id": "9", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8012248, 31.280271899999995], [34.8012911, 31.280268800000005], [34.8013588, 31.280266700000006], [34.8014269, 31.280264799999998], [34.8014947, 31.280262200000003], [34.8015612, 31.280258100000008], [34.8016257, 31.28025149999999], [34.8016873, 31.280241700000005], [34.8017451, 31.280227599999996], [34.8017984, 31.280208499999993], [34.8018522, 31.280173399999995]]}, "bbox": [34.8012248, 31.280173399999995, 34.8018522, 31.280271899999995]}, {"id": "10", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8018522, 31.280173399999995], [34.8018696, 31.280155999999995], [34.80189, 31.2801411]]}, "bbox": [34.8018522, 31.2801411, 34.80189, 31.280173399999995]}, {"id": "11", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.80189, 31.2801411], [34.8019042, 31.28012709999999], [34.8019168, 31.2801141], [34.8019292, 31.280099299999993], [34.801941, 31.2800829], [34.801951900000006, 31.280064999999997], [34.8019652, 31.280040900000007], [34.8019785, 31.2800136], [34.8019914, 31.2799772], [34.8020028, 31.279933699999994], [34.8020784, 31.279547200000007], [34.8024002, 31.277970300000003]]}, "bbox": [34.80189, 31.277970300000003, 34.8024002, 31.2801411]}, {"id": "12", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8024002, 31.277970300000003], [34.80242810000001, 31.277817999999993], [34.8024331, 31.277776299999992], [34.8024319, 31.277745600000003], [34.8024283, 31.2777217], [34.8024213, 31.2776899], [34.8024051, 31.27764]]}, "bbox": [34.8024002, 31.27764, 34.8024331, 31.277970300000003]}, {"id": "13", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8024051, 31.27764], [34.8023773, 31.2776208], [34.8023553, 31.27759670000001]]}, "bbox": [34.8023553, 31.27759670000001, 34.8024051, 31.27764]}, {"id": "14", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8023553, 31.27759670000001], [34.8023412, 31.277571500000004], [34.8023336, 31.277544199999994], [34.8023327, 31.277516200000004], [34.8023387, 31.27748870000001], [34.8023512, 31.2774628], [34.8023697, 31.2774397]]}, "bbox": [34.8023327, 31.2774397, 34.8023697, 31.27759670000001]}, {"id": "15", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8023697, 31.2774397], [34.8023887, 31.277423600000002], [34.8024107, 31.2774105]]}, "bbox": [34.8023697, 31.2774105, 34.8024107, 31.2774397]}, {"id": "16", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8024107, 31.2774105], [34.80244660000001, 31.2773976], [34.8024852, 31.2773926], [34.802524, 31.2773959], [34.8025606, 31.277407199999992], [34.8025929, 31.277425900000004]]}, "bbox": [34.8024107, 31.2773926, 34.8025929, 31.277425900000004]}, {"id": "17", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8025929, 31.277425900000004], [34.8026081, 31.2774391]]}, "bbox": [34.8025929, 31.277425900000004, 34.8026081, 31.2774391]}, {"id": "18", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8026081, 31.2774391], [34.8026762, 31.2774556], [34.8027159, 31.2774625], [34.8027604, 31.277464600000005], [34.8028014, 31.2774624], [34.802997, 31.277444599999995]]}, "bbox": [34.8026081, 31.2774391, 34.802997, 31.277464600000005]}, {"id": "19", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.802997, 31.277444599999995], [34.8031903, 31.277427100000004], [34.8034955, 31.2773935], [34.8037855, 31.277352499999996], [34.8040683, 31.277305099999992], [34.8043704, 31.277227900000003], [34.8047495, 31.2771099], [34.8051076, 31.2769928], [34.8054014, 31.27687530000001], [34.8055945, 31.2767773], [34.805839, 31.276653300000003], [34.806589, 31.276168600000002], [34.8071709, 31.275694400000003], [34.80736530000001, 31.275499599999996], [34.8103651, 31.271793]]}, "bbox": [34.802997, 31.271793, 34.8103651, 31.277444599999995]}, {"id": "20", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8103651, 31.271793], [34.8107596, 31.271271500000005]]}, "bbox": [34.8103651, 31.271271500000005, 34.8107596, 31.271793]}, {"id": "21", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8107596, 31.271271500000005], [34.8108548, 31.271158199999995]]}, "bbox": [34.8107596, 31.271158199999995, 34.8108548, 31.271271500000005]}, {"id": "22", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8108548, 31.271158199999995], [34.8110619, 31.2708981]]}, "bbox": [34.8108548, 31.2708981, 34.8110619, 31.271158199999995]}, {"id": "23", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8110619, 31.2708981], [34.8132495, 31.2682303]]}, "bbox": [34.8110619, 31.2682303, 34.8132495, 31.2708981]}, {"id": "24", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8132495, 31.2682303], [34.8132389, 31.268199500000005], [34.813237400000006, 31.26816739999999]]}, "bbox": [34.813237400000006, 31.26816739999999, 34.8132495, 31.2682303]}, {"id": "25", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.813237400000006, 31.26816739999999], [34.8132482, 31.26812890000001], [34.8132719, 31.2680948], [34.8133065, 31.2680684], [34.8133487, 31.268052]]}, "bbox": [34.813237400000006, 31.268052, 34.8133487, 31.26816739999999]}, {"id": "26", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8133487, 31.268052], [34.8133848, 31.26804720000001]]}, "bbox": [34.8133487, 31.26804720000001, 34.8133848, 31.268052]}, {"id": "27", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8133848, 31.26804720000001], [34.813455000000005, 31.267968999999997], [34.8144667, 31.266613899999992], [34.8147619, 31.266218499999997]]}, "bbox": [34.8133848, 31.266218499999997, 34.8147619, 31.26804720000001]}, {"id": "28", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8147619, 31.266218499999997], [34.8149656, 31.265953299999996]]}, "bbox": [34.8147619, 31.265953299999996, 34.8149656, 31.266218499999997]}, {"id": "29", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8149656, 31.265953299999996], [34.8160823, 31.264561799999992]]}, "bbox": [34.8149656, 31.264561799999992, 34.8160823, 31.265953299999996]}, {"id": "30", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8160823, 31.264561799999992], [34.8163296, 31.264268799999996]]}, "bbox": [34.8160823, 31.264268799999996, 34.8163296, 31.264561799999992]}, {"id": "31", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8163296, 31.264268799999996], [34.8163369, 31.264205799999996]]}, "bbox": [34.8163296, 31.264205799999996, 34.8163369, 31.264268799999996]}, {"id": "32", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8163369, 31.264205799999996], [34.8163603, 31.264156799999988], [34.8163979, 31.264114599999996], [34.816447, 31.264082199999994], [34.8165043, 31.264061899999998]]}, "bbox": [34.8163369, 31.264061899999998, 34.8165043, 31.264205799999996]}, {"id": "33", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8165043, 31.264061899999998], [34.8165684, 31.264055], [34.8166322, 31.264063299999993]]}, "bbox": [34.8165043, 31.264055, 34.8166322, 31.264063299999993]}, {"id": "34", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8166322, 31.264063299999993], [34.8168749, 31.2638692], [34.8169915, 31.2637854]]}, "bbox": [34.8166322, 31.2637854, 34.8169915, 31.264063299999993]}, {"id": "35", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8169915, 31.2637854], [34.8196116, 31.261901999999996], [34.8202928, 31.261422000000003], [34.82036, 31.261356599999996], [34.8203966, 31.261319899999993], [34.82042640000001, 31.261268500000003]]}, "bbox": [34.8169915, 31.261268500000003, 34.82042640000001, 31.2637854]}, {"id": "36", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.82042640000001, 31.261268500000003], [34.8204455, 31.26122120000001], [34.8204823, 31.261182299999994], [34.8205323, 31.26115640000001], [34.8205897, 31.261146699999994]]}, "bbox": [34.82042640000001, 31.261146699999994, 34.8205897, 31.261268500000003]}, {"id": "37", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8205897, 31.261146699999994], [34.820666900000006, 31.261132800000002], [34.8207205, 31.261110899999988], [34.8207829, 31.261076700000004], [34.8228078, 31.25964979999999], [34.8230393, 31.2594827]]}, "bbox": [34.8205897, 31.2594827, 34.8230393, 31.261146699999994]}, {"id": "38", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8230393, 31.2594827], [34.8233099, 31.259287400000005], [34.8233795, 31.2592113], [34.8234329, 31.259140099999996]]}, "bbox": [34.8230393, 31.259140099999996, 34.8234329, 31.2594827]}, {"id": "39", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8234329, 31.259140099999996], [34.8234348, 31.259102299999995], [34.823469, 31.259034899999993], [34.82350580000001, 31.2589979]]}, "bbox": [34.8234329, 31.2589979, 34.82350580000001, 31.259140099999996]}, {"id": "40", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.82350580000001, 31.2589979], [34.823529300000004, 31.258974199999987], [34.8236063, 31.2589296], [34.8236218, 31.2589254]]}, "bbox": [34.82350580000001, 31.2589254, 34.8236218, 31.2589979]}, {"id": "41", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8236218, 31.2589254], [34.8236884, 31.258907699999998], [34.823763, 31.25891189999999]]}, "bbox": [34.8236218, 31.258907699999998, 34.823763, 31.2589254]}, {"id": "42", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.823763, 31.25891189999999], [34.8238425, 31.258901800000004], [34.8239174, 31.258869899999997], [34.8242373, 31.258643100000004]]}, "bbox": [34.823763, 31.258643100000004, 34.8242373, 31.25891189999999]}, {"id": "43", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8242373, 31.258643100000004], [34.8243851, 31.25853830000001], [34.8256411, 31.257653199999993]]}, "bbox": [34.8242373, 31.257653199999993, 34.8256411, 31.258643100000004]}, {"id": "44", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8256411, 31.257653199999993], [34.8260453, 31.257333199999998]]}, "bbox": [34.8256411, 31.257333199999998, 34.8260453, 31.257653199999993]}, {"id": "45", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8260453, 31.257333199999998], [34.8262209, 31.25721]]}, "bbox": [34.8260453, 31.25721, 34.8262209, 31.257333199999998]}, {"id": "46", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8262209, 31.25721], [34.8265878, 31.256951600000008]]}, "bbox": [34.8262209, 31.256951600000008, 34.8265878, 31.25721]}, {"id": "47", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8265878, 31.256951600000008], [34.8272555, 31.2564819], [34.8278509, 31.2560462], [34.8281299, 31.255816899999996], [34.8282533, 31.255697700000002], [34.8283012, 31.2556412]]}, "bbox": [34.8265878, 31.2556412, 34.8283012, 31.256951600000008]}, {"id": "48", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8283012, 31.2556412], [34.8285054, 31.255385899999997], [34.8286878, 31.255092400000002], [34.8288058, 31.2547943], [34.8288863, 31.254519099999992], [34.8289292, 31.254207300000004], [34.8289367, 31.2540165], [34.8289335, 31.25368310000001], [34.8288023, 31.251161199999995]]}, "bbox": [34.8283012, 31.251161199999995, 34.8289367, 31.2556412]}, {"id": "49", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8288023, 31.251161199999995], [34.8286771, 31.250057000000005], [34.8286288, 31.2492269], [34.8286234, 31.248213300000003], [34.8286805, 31.247451099999992], [34.828777, 31.2468218], [34.8287929, 31.246726600000002], [34.8288058, 31.24664939999999], [34.8289614, 31.24596610000001], [34.8291545, 31.2452506], [34.8293047, 31.2448103], [34.8294871, 31.244379199999994], [34.8298089, 31.243723400000004], [34.83014, 31.243151800000003], [34.8308127, 31.241999999999997], [34.8311476, 31.2414331], [34.8318152, 31.24017799999999], [34.8319654, 31.2398478], [34.8321747, 31.2392836], [34.8323034, 31.238724], [34.8324161, 31.237916800000004], [34.8324405, 31.2371639], [34.8323839, 31.2365408], [34.8322229, 31.235861899999993], [34.8321532, 31.2356188], [34.8320285, 31.235275999999995], [34.8314558, 31.234086799999993], [34.8305868, 31.232398799999995], [34.8300879, 31.2311558], [34.8299227, 31.230650299999997], [34.8298685, 31.2304303]]}, "bbox": [34.8286234, 31.2304303, 34.8324405, 31.251161199999995]}, {"id": "50", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8298685, 31.2304303], [34.8291949, 31.228380600000005], [34.8289784, 31.227880399999997], [34.828755, 31.227444799999994], [34.8286691, 31.227311800000003], [34.8284921, 31.227064100000003], [34.8281112, 31.226582400000005], [34.827961, 31.226339299999992], [34.827843, 31.2261007], [34.8278001, 31.2259815]]}, "bbox": [34.8278001, 31.2259815, 34.8298685, 31.2304303]}, {"id": "51", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8278001, 31.2259815], [34.8277036, 31.225820900000002], [34.8276553, 31.225747499999997], [34.8275909, 31.2256787], [34.8275212, 31.2256374], [34.8274461, 31.225623700000003], [34.8271711, 31.225621099999994]]}, "bbox": [34.8271711, 31.225621099999994, 34.8278001, 31.2259815]}, {"id": "52", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8271711, 31.225621099999994], [34.8230619, 31.2265032], [34.8221518, 31.226698599999995]]}, "bbox": [34.8221518, 31.225621099999994, 34.8271711, 31.226698599999995]}, {"id": "53", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8221518, 31.226698599999995], [34.8217877, 31.226774699999986]]}, "bbox": [34.8217877, 31.226698599999995, 34.8221518, 31.226774699999986]}, {"id": "54", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8217877, 31.226774699999986], [34.8216717, 31.2268017]]}, "bbox": [34.8216717, 31.226774699999986, 34.8217877, 31.2268017]}, {"id": "55", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8216717, 31.2268017], [34.8216381, 31.2266868]]}, "bbox": [34.8216381, 31.2266868, 34.8216717, 31.2268017]}, {"id": "56", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8216381, 31.2266868], [34.8215216, 31.226302799999996]]}, "bbox": [34.8215216, 31.226302799999996, 34.8216381, 31.2266868]}, {"id": "57", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8215216, 31.226302799999996], [34.8214442, 31.2260473], [34.8213589, 31.2257661], [34.8213363, 31.225692], [34.8212789, 31.2255047], [34.8209569, 31.22445289999999], [34.82094800000001, 31.2244248], [34.8209369, 31.224393600000003], [34.8209238, 31.22436039999999], [34.8209087, 31.224326100000003], [34.8208917, 31.224291599999994], [34.820873, 31.224257799999993], [34.8208526, 31.22422569999999], [34.8208307, 31.2241962], [34.8208074, 31.224170299999994], [34.8207704, 31.224144400000007]]}, "bbox": [34.8207704, 31.224144400000007, 34.8215216, 31.226302799999996]}, {"id": "58", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8207704, 31.224144400000007], [34.8207353, 31.22413209999999], [34.8207024, 31.224115899999997], [34.8206724, 31.224096000000007], [34.8206458, 31.224072800000002]]}, "bbox": [34.8206458, 31.224072800000002, 34.8207704, 31.224144400000007]}, {"id": "59", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8206458, 31.224072800000002], [34.8206211, 31.224044100000008], [34.8206017, 31.224012599999984], [34.8205879, 31.223979], [34.82058, 31.223944100000004], [34.8205783, 31.223908500000007], [34.8205828, 31.223873100000006], [34.8205933, 31.223838699999988], [34.8206096, 31.2238059]]}, "bbox": [34.8205783, 31.2238059, 34.8206458, 31.224072800000002]}, {"id": "60", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8206096, 31.2238059], [34.8206324, 31.2237745], [34.8206605, 31.2237464], [34.8206933, 31.223722400000007]]}, "bbox": [34.8206096, 31.223722400000007, 34.8206933, 31.2238059]}, {"id": "61", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8206933, 31.223722400000007], [34.82073100000001, 31.2237025], [34.820772, 31.223687899999998], [34.8208151, 31.22367900000001], [34.8208592, 31.223675999999998], [34.8209034, 31.22367900000001], [34.8209465, 31.2236879], [34.8209875, 31.22370250000001], [34.8210252, 31.2237224]]}, "bbox": [34.8206933, 31.223675999999998, 34.8210252, 31.223722400000007]}, {"id": "62", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8210252, 31.2237224], [34.8210388, 31.223731499999996]]}, "bbox": [34.8210252, 31.2237224, 34.8210388, 31.223731499999996]}, {"id": "63", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8210388, 31.223731499999996], [34.8210834, 31.223746800000004], [34.8211075, 31.223754399999994], [34.8211325, 31.22376089999999], [34.8211585, 31.223766199999993], [34.8211858, 31.223770000000002], [34.8212145, 31.2237719], [34.8212449, 31.2237718], [34.8212771, 31.223769399999995], [34.8213115, 31.223764399999993], [34.8214791, 31.22372440000001], [34.8216666, 31.223667999999996], [34.8217001, 31.223656200000004]]}, "bbox": [34.8210388, 31.223656200000004, 34.8217001, 31.2237719]}, {"id": "64", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8217001, 31.223656200000004], [34.8218703, 31.223596], [34.8220066, 31.223540799999995]]}, "bbox": [34.8217001, 31.223540799999995, 34.8220066, 31.223656200000004]}, {"id": "65", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8220066, 31.223540799999995], [34.822086, 31.223508699999993], [34.8223099, 31.2234068], [34.822538, 31.2232908], [34.8227664, 31.223161100000002], [34.8229911, 31.223018299999996], [34.8232082, 31.222863000000007], [34.8234137, 31.222695599999998], [34.8235815, 31.222572099999994], [34.8235949, 31.222557800000004]]}, "bbox": [34.8220066, 31.222557800000004, 34.8235949, 31.223540799999995]}, {"id": "66", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8235949, 31.222557800000004], [34.8236914, 31.22245510000001], [34.8237263, 31.222413799999998], [34.8237447, 31.222385900000003], [34.8237556, 31.222356199999997]]}, "bbox": [34.8235949, 31.222356199999997, 34.8237556, 31.222557800000004]}, {"id": "67", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8237556, 31.222356199999997], [34.8237438, 31.222325700000003]]}, "bbox": [34.8237438, 31.222325700000003, 34.8237556, 31.222356199999997]}, {"id": "68", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8237438, 31.222325700000003], [34.8237398, 31.2222864], [34.8237475, 31.222247500000005], [34.8237665, 31.222211600000005], [34.8237954, 31.222180900000012], [34.8238326, 31.22215750000002]]}, "bbox": [34.8237398, 31.22215750000002, 34.8238326, 31.222325700000003]}, {"id": "69", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8238326, 31.22215750000002], [34.8238788, 31.222142100000006], [34.8239282, 31.222138100000002], [34.8239771, 31.2221456], [34.8240216, 31.222164299999992], [34.8240586, 31.22219259999999], [34.8240852, 31.222228400000002], [34.8240995, 31.2222691], [34.8241002, 31.222311500000004], [34.8240875, 31.222352599999997], [34.8240622, 31.2223891], [34.824026200000006, 31.222418299999998], [34.8239823, 31.222438099999998], [34.8239338, 31.222446999999992]]}, "bbox": [34.8238326, 31.222138100000002, 34.8241002, 31.222446999999992]}, {"id": "70", "type": "Feature", "properties": {}, "geometry": {"type": "LineString", "coordinates": [[34.8239338, 31.222446999999992], [34.8238765, 31.222464199999997], [34.8238175, 31.222505499999993], [34.8237531, 31.2225606], [34.8234869, 31.222786900000003], [34.8232814, 31.222954299999998], [34.823257, 31.222971800000003], [34.8230643, 31.2231096], [34.8228396, 31.2232524], [34.822670100140066, 31.223348652837668], [34.82267010013997, 31.22334865283772]]}, "bbox": [34.82267010013997, 31.222446999999992, 34.8239338, 31.22334865283772]}], "bbox": [34.7991709, 31.222138100000002, 34.8324405, 31.280271899999995]}',
'time': 505.78952091662603}
The 'time' property contains the total travel time, in seconds:
dat['time']505.78952091662603
The 'geometry' property contains a vector layer in GeoJSON format, which can be transformed into a GeoDataFrame as follows:
layer = gpd.read_file(dat['geometry'])
layer| id | geometry | |
|---|---|---|
| 0 | 0 | LINESTRING (34.79926 31.28025, ... |
| 1 | 1 | LINESTRING (34.79925 31.28025, ... |
| 2 | 2 | LINESTRING (34.79921 31.28021, ... |
| ... | ... | ... |
| 68 | 68 | LINESTRING (34.82374 31.22233, ... |
| 69 | 69 | LINESTRING (34.82383 31.22216, ... |
| 70 | 70 | LINESTRING (34.82393 31.22245, ... |
71 rows × 2 columns
Figure 14.5 draws the geometry we got:
layer.plot();
fastapi
Web applications
APIs are often used behind the scenes in web or mobile applications. For example, when using the routing feature in Google Maps (Figure 14.1), the Google Routes API is employed behind the scenes. A minimal application using the API we just built is accessible in https://geobgu.xyz/routing/map/ (Figure 14.6). Clicking on two points triggers an API request with the corresponding origin and destination coordinates. The returned travel time and route geometry are then displayed on the map.
fastapi from fastapi
Exercises
Exercise 1
- What is the total length, in \(m\), of the optimal route displayed in Figure 14.5? Write an expression that calculates the length as a
floatvalue (Solution 13-01)
Exercise 2
- Create an API that accepts two numeric values
lonandlat, and returns the EPSG code of the corresponding UTM zone, based on thelonlat_to_utmfunction (Function definition) - Run the API and test it using http://127.0.0.1:8888/?lon=34.78667&lat=31.25222 (the response shpuld be
32636)
Exercise 3
- Calculate and plot a map of accessibility to a specific location in Beer-Sheva, similarly to Exercise 10-01, but this time using a web API to calculate the travel times (Figure 19.32)