Lua – How to use external data in an OSRM configuration file

In this Mapbox blog post, Lauren Budorick shared how they used OSRM to run the routing engine, which uses elevation data to provide riders with better routes… amazing!

I also want to explore the potential of OSRM routing when inserting external (user-generated) data, but I still have a hard time grasping how the OSRM profile works. I think I got a major The idea is that every way (or node?) is transmitted through the pipeline to some functions, and these functions have always been a good analysis of how good this road is.

But that’s it, I There are a lot of missing parts in the mind, like every function Lauren uses in her profile. If someone can point out some more detailed information on how it works, you will make my next week easier 🙂< /p>

In addition, in Lauren’s post, inside source_function, she loads a ./srtm_bayarea.asc file. What is the .asc file like? How to generate a file, for example, data stored in a pgsql database? Can we use other formats, such as GeoJSON?

Then, when things like source.lon and target.lat are used in segment_function, do those refer to the raw data stored in the asc file? Or is the file processed into some standard to map everything to conform to it?

As you can see, I am a complete routing novice, maybe a general GIS, but I want to learn more about these standards and tools around the OSRM ecosystem. Can you share with me Some tips?

I think I get the main idea, that every way (or node ?) is piped into a few functions that, all toghether, scores how good that path is.

Yes, the score for each method and each node is as they are read from an OSM dump to determine the passability of the node and the speed of the way (used as a scoring heuristic).

A basic description of the data format can be found here. When reading, it is immediately available in the ArcInfo ASCII grid The data includes SRTM data. Currently, the plaintext ASCII grid is the only supported format. There are some great Python tools available to GIS developers that can help convert other data types to ASCII grids-such as check out rasterio. This is a very simple python script example to convert NED IMG to ASCII grid:

import sys
import rasterio as rio
import numpy as np

args = sys.argv[1:]

with rio.drivers():
with rio.open(args[0]) as src:
elev = src.read()[0]
profile = src.profile

def shortify(x):
if x == profile[' nodata']:
return -9999
elif x == np.finfo(x).tiny:
return 0
else:
return int(round(x ) )

out_elev = [map(shortify, row) for row in elev]

with open(args[0] +'.asc','a') as dst :
np.savetxt(dst, np.array(out_elev),fmt="%s",delimiter=" ")

source.lon and target.lat For example: source and target are The nodes provided by the extraction process as parameters. Their coordinates are used to find data at each location during extraction.

Please be sure to read the relevant Wiki page (linked) carefully.

Feel free alternately to open a Github issue in 07006 with OSRM questions.

this Mapbox blog post, Lauren Budorick Share how they use OSRM to run the routing engine, which uses elevation data to provide riders with better routes… amazing!

I also want to explore the potential of OSRM routing when inserting external (user-generated) data, but I still have a hard time grasping how the OSRM profile works. I think I got a major The idea is that every way (or node?) is transmitted through the pipeline to some functions, and these functions have always been a good analysis of how good this road is.

But that’s it, I There are a lot of missing parts in the mind, like every function Lauren uses in her profile. If someone can point out some more detailed information on how it works, you will make my next week easier 🙂< /p>

In addition, in Lauren’s post, inside source_function, she loads a ./srtm_bayarea.asc file. What is the .asc file like? How to generate a file, for example, data stored in a pgsql database? Can we use other formats, such as GeoJSON?

Then, when things like source.lon and target.lat are used in segment_function, do those refer to the raw data stored in the asc file? Or is the file processed into some standard to map everything to conform to it?

As you can see, I am a complete routing novice, maybe a general GIS, but I want to learn more about these standards and tools around the OSRM ecosystem. Can you share with me Some tips?

I think I get the main idea, that every way (or node?) is piped into a few functions that, all toghether , scores how good that path is.

Yes, the scores of each method and each node are as they are read from an OSM dump to determine the passability and method of the node Speed ​​(used as a scoring heuristic).

A basic description of the data format can be found here. When reading, the data immediately available in the ArcInfo ASCII grid includes SRTM data. Currently, the plaintext ASCII grid Is the only supported format. There are some great Python tools available to GIS developers that can help convert other data types to ASCII grids-such as check out rasterio. This is a very simple python script example for Convert NED IMG to ASCII grid:

import sys
import rasterio as rio
import numpy as np

args = sys.argv[1:]

with rio.drivers():
with rio.open(args[0]) as src:
elev = src.read( )[0]
profile = src.profile

def shortify(x):
if x == profile['nodata']:
return -9999< br /> elif x == np.finfo(x).tiny:
return 0
else:
return int(round(x))

out_elev = [map(shortify, row) for row in elev]

with open(args[0] +'.asc','a') as dst:
np.savetxt(dst, np.array(out_elev),fmt= "%s",delimiter=" ")

source.lon and target.lat For example: source and target are nodes provided by the extraction process as parameters. Their coordinates are used in each location during extraction Find data.

Please read the relevant Wiki page (linked) carefully.

Feel free alternately to open a Github issue in 07006 with OSRM questions.

Leave a Comment

Your email address will not be published.