I am new to working with Maps and search algorithms. Currently I am using geopy package to get distances from Nominatim
from geopy.geocoders import Nominatim
from geopy.distance import vincenty
nom = Nominatim()
chicago = nom.geocode("chicago")
dallas = nom.geocode("dallas")
chicago_gps = (chicago.latitude, chicago.longitude)
dallas_gps = (dallas.latitude, dallas.longitude)
distance = vincenty(chicago_gps, dallas_gps).km
print('Distance in kms: {}'.format(distance))
print(chicago.raw)
output
Distance in kms: 1294.7623005649557
{'lat': '41.8755546', 'osm_id': '122604', 'boundingbox': ['41.643919', '42.0230219', '-87.940101', '-87.5239841'], 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright', 'lon': '-87.6244212', 'place_id': '178038280', 'class': 'place', 'icon': 'https://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png', 'osm_type': 'relation', 'importance': 0.29566190262222, 'display_name': 'Chicago, Cook County, Illinois, United States of America', 'type': 'city'}
So for each place I can calculate the distance. Now there are few questions
Is it an airline distance ? Also does OSM provide duration of the journey like Google does ?
How can I get directions if I want to go from "Chicago" to "Dallas" like google ? Is there way we get the routing directly from OSM apart from using APIs MapQuest etc ?
How can we implement traffic layers in our model ? I need some good resources in that and if there are any python implementations of that it would be great.
Is it an airline distance?
Yes, see the geopy documentation on distance calculation. geopy doesn't support real routing at the moment.
Also does OSM provide duration of the journey like Google does?
Yes it does if you use a real router. Take a look at OSM-based online routers. Several of them, such as GraphHopper and OSRM, provide turn-by-turn instructions.
How can I get directions if I want to go from "Chicago" to "Dallas" like google ? Is there way we get the routing directly from OSM apart from using APIs MapQuest etc?
See my previous answer. Use the API of one of the many online routers. Alternatively run your own routing instance. Many of these routers are open source and can be installed locally.
How can we implement traffic layers in our model ? I need some good resources in that and if there are any python implementations of that it would be great.
Can't help you with that. I would start by taking a look at http://opentraffic.io/ and https://github.com/graphhopper/open-traffic-collection.
Related
I recently found this ontology suite:
https://bioportal.bioontology.org/ontologies/AFO/?p=summary
I want to explore its contents. Normally I use http://www.visualdataweb.de/webvowl/ for such purposes. Example (Basic Formal Ontology):
http://www.visualdataweb.de/webvowl/#iri=http://purl.obolibrary.org/obo/bfo.owl
However, I was not able to find the IRI for the AFO ontology or at least some URL which produces a visualization at the webvowl service.
Question: How to visualize the contet of AFO?
You can try to have a look at it on the Ontology Lookup Service (OLS)
Full disclosure : I am responsible for OLS, but not AFO.
I use Python for plotting geospatial data on maps.
For certain map-styles, such as ["basic", "streets", "outdoors", "light", "dark", "satellite", "satellite-streets"], I need a mapbox-access token and for some geospatial plotting packages like folium I even need to create my own link for retrieving the map-tiles.
So far, it worked great with the style "satellite":
mapbox_style = "satellite"
mapbox_access_token = "....blabla"
request_link = f"https://api.mapbox.com/v4/mapbox.{mapbox_style}/{{z}}/{{x}}/{{y}}#2x.jpg90?access_token={mapbox_access_token}"
However, when choosing "satellite-streets" as mapbox-tile-ID, the output doesn't show a background map anymore. It fails with inserting "satellite-streets", "satellitestreets" and "satellite_streets" into the aforementioned link-string.
Why is that and how can I come to know what's the correct tile-ID-name for "satellite-streets"?
I found an answer when reaching out to the customer support.
Apparently, one has to access the static APIs which have specific names listed on their website:
"In general, the styles that you mentioned including
"satellite_streets" that you are referencing are our classic styles
that are going to be deprecated starting June 1st. I would recommend
using our modern static API the equivalent modern styles. This
will allow you to see the most updated street data as well.
Like the example request below:
https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v11/tiles/1/1/0?access_token={your_token}
Here is more info on the deprecation of the classic styles and
the migration guide for them."
My personal adaptation after having tried everything out myself, is:
Via combining the above-mentioned with the details on how to construct a Mapbox-request link on this documention from mapbox' website,
I finally managed to make it work.
An example request looks like so (in python using f-strings):
mapbox_tile_URL = f"https://api.mapbox.com/styles/v1/mapbox/{tileset_ID_str}/tiles/{tilesize_pixels}/{{z}}/{{x}}/{{y}}#2x?access_token={mapbox_access_token}"
The tileset_ID_str could be e.g. "satellite-streets-v11" which can be seen at the following link containing valid static maps.
I try to use Overpass API over europe osm data.
I want to get all European country (+ their islands).
Example, for France : Metropole + Corsica + Guadeloupe + Martinique...
To do it, I downloaded europe OSM datafile from geofabrik : https://download.geofabrik.de/europe-latest.osm.bz2 because I saw that in Europe folder I can get all what I wanted. Example : Europe/France/Corsica+Guadeloupe+Martinique... and same things for others countries.
I followed Overpass API installation : https://wiki.openstreetmap.org/wiki/Overpass_API/Installation with success.
I tried to request on different countries with success but can't get data for many islands.
Example : I can get Corsica data but CAN'T get for others French islands (Guadeloupe, Martinique...).
Request example :
[out:json]; node(around:50,16.24263,-61.535662); <; out geom;
--> this returned values using https://overpass-turbo.eu test tool, but nothing with my custom overpass API (tried on different request and different GPS loc).
Also, I checked import log files generated during import of .osm.bz2 into db/ folder, I saw many (more than hundred) lines like :
compute_geometry: Way 83225893 used in relation 10106318 not found.
--> is it related to my problem ?
Can the europe-latest.osm.bz2 be corrupted (missing data) ?
Can I import islands on my current /db to not re-download all data ?
Thank a lot !
I was wondering if there is a way to get the highway direction of the route.
To be more specific, I am interested in routes on interstate highways in the United States only.
I'll give an example:
Interstate I45 is a north-south highway. When the route is returned, is there a way to know which "direction lane" the route is on?
The problem I'm trying to solve is accessing the rest ares like the one shown on the image here. As you can see, these are two rest areas, each accessible from one direction of the highway.
I would like to display only those accessible from the direction the user is on. I have all the data needed, including if the rest area is on the North/South/East/West direction and I only need the highway direction the route is on.
For obvious reasons, I would like to avoid manually checking if the route just appears to be going northwards.
I checked if this is possible via graphhopper, but it only gives the highway name, without direction. Is it possible to achieve this via Skobbler?
If you are using the TTS instructions (text-to-speech) then in the advice instructions & audio advices you will also receive the "orientation" (coded as a $orientation in the audio config files) - indicating the direction you are driving on a particular highway (south/north, etc.).
The trickier part is that you would have to parse the text instruction to get this information as it's not returned in a separate field (let me know in a comment if this was helpful).
I do not fully understand the original problem but as GraphHopper also returns the geometry for every instruction you should be able to calculate the orientation roughly but easily.
Another more complex approach would be to have a predefined name set associated with the geometry and use the map matching component to find out which highway parts are used in a route.
For obvious reasons,
which obvious reasons? That it is not really going norht south?
Or if something is not possible you always can modify in the code as it is open source or provide a pull request to merge it into the public release (if useful for others) and make it available for the Directions API too.
According to the OSM wiki page Highway Directions In The United States, directions of ways are supposed to be modeled as relation membership roles.
For example, I 75 way 173483918 is a member of the relation 332618 named "I 75 (TN northbound)" with role=north, so it's direction is "north".
The opposite way 173483897 is a member of the relation 332624 named "I 75 (TN southbound)" as role "south".
See more details on the wiki page. Don't know how well established that tagging scheme is, also don't know about router support (Telenav (Scout) seem to be involved in this who now own Skobbler).
I would like to get the distance between 2 markers but not as a direct line, more as a real path like it goes in this plugin -
https://github.com/perliedman/leaflet-routing-machine
I didn't find anything about using this plugin in the directive: angular-leaflet-directive,
if someone can guide how to make it done, it would be very appreciated.
thanks!
I am not sure if you specifically want to use leaflet routing machine to get distances... but if you do, maybe this info can get you started:
Set up a route on your map based on this example by the leaflet routing machine author:
https://www.liedman.net/leaflet-routing-machine/tutorials/interaction/
If you look at that example, there is an array called routes. Each route has some basic statistics associated with it, generated by OSRM. You can pull them by calling for example:
routes[0].summary.totalDistance
or
routes[0].summary.totalTime
Then you can do whatever you want with them. If you dig through the code on GitHub you can see more about how the data are moved around within the plugin and why the array is arranged that way:
https://unpkg.com/leaflet-routing-machine#3.2.12/dist/leaflet-routing-machine.js