OSMNx: How to fetch street network using saved osm xml instead of overpass api call request - openstreetmap

I can fetch OSM street network using
G=ox.graph_from_point((lat, lng),custom_filter=road_filter,dist=20,simplify=False,retain_all=True)
The process is very slow if i have to make 1000 of such requests.I was hoping if i can load the saved osm file then query locally for the osm road networks.

In Osmnx, the only way to create a graph from a local .osm formatted XML file is:
graph = osmnx.graph_from_xml(filepath, simplify=False, retain_all=True)
There are not filters as other graph_from_*() functions, but once you got the graph you can query the Geodataframes containing nodes and edges that you get with:
nodes, edges = osmnx.graph_to_gdfs(graph, nodes=True, edges=True)

Related

Filtering the Clustered Points by JSON attributes using Mapbox-gl-js

I am working on the project in which I want to filter the GeoJson using their attributes and visualize the marker in cluster form on the map.
I try using the following "Filtering Clustered Points by JSON attributes using Mapbox-gl-js"
solution but unable to understand how to filter GeoJson using their attributes and set filter GeoJson data to map.
I already made an application using Google Maps API, but now I want to develop through Mapbox-gl-js API.
Existing Application Link: http://maps.dicrc.in/BM/
Mapbox The GeoJSON clustering happens at the source level. If you want to filter data in the clusters, you will have to filter the GeoJSON itself based on the attributes BEFORE clustering it.
You can use tools like turf/filter to filter the GeoJSON data. For clustering and updating your filtered data, follow the example in this jsfiddle map.getSource('sourceName').setData(filteredData)
disclaimer: I work at Mapbox

OSM - Find all optional routes in specific bounding-box

My goal is to get a list of all optional routes in certain area.
I want to use OSM for achieving this data
Route means pair or intersections that it's possible to drive from the first intersection to the second.
In the case at the image:
The optional routes are:
1-2 , 1-4
2-1 , 2-3 , 2-5
3-2 , 3-6
4-1 , 4-5
5-4 , 5-2 , 5-6
6-5 , 6-3
So far I have tried this code in overpass-turbo site:
[bbox:{{bbox}}];
way[highway~"^(residential)$"]->.minor;
node(w.minor)(w.minor);
out;
The output is the intersections, but:
List doesn't contain all the intersections
I need the routes = connection of pairs of intersections
If you're comfortable using Java, consider taking a look at Atlas. Atlas is an in memory representation of OSM data that will allow you to create a graph representing the street network. There is an Atlas API layer for connectivity, routing and spatial searches. For your specific need - there is the concept of a Route - which maintains the OSM Ways and Nodes specifying a path between two Nodes or Ways. There are ways to get the most optimal Route or obtain all possible Routes.
To get started, I recommend the following:
Set up and familiarize yourself with the Atlas project
Extract an OSM or PBF file with the area of interest
Create an Atlas file from the PBF, run applicable routing algorithm
Sample code to load an OSM file:
public class TestAtlasTestRule extends CoreTestRule
{
#TestAtlas(loadFromJosmOsmResource = "yourOsmFile.osm")
private Atlas yourAtlasFile;
public Atlas getAtlasFile()
{
return this.yourAtlasFile;
}
}
Sample code to obtain routes:
// To get the shortest route
final Route shortestRoute = AStarRouter.dijkstra(yourAtlasFile, distanceThreshold).route(startNode, endNode);
// To get all the routes
final Set<Route> allRoutes = AllPathsRouter.allRoutes(startEdge, endEdge, comparatorThatEnforcesRouteOrdering);

Feed JSON to Nominatim with import.io

Greetings fellow SO users,
I am extracting data with import.io from a site which contains city names. What I want to accomplish is to get the coordinates to each city from Nominatim and finally create/get a JSON response which contains the city name and the corresponding coordinates for each.
So I basically need to use the result from one API as the input for another (Nominatim).
Or in other words: feed a JSON list of city names to OSM's Nominatim and get back the coordinates to each city.
I wonder if this is even possible or what other options I have. Finally this would be used with leaflet to put some markers at a map.
There are tutorials for Nominatim, how to query etc. but only one query at a time. Is it even possible to query a whole list of places?
What you want to achieve in here is what we call Chained APIs. So you will need two APIs, where the input of the second one is the output of the first one.
In this case you will need some custom processing between the two APIs. From the first API you are getting the city name and from here you need to generate a list of URLs in the format http://nominatim.openstreetmap.org/search?q=CITY&format=xml one per each CITY.
After that you can use the Bulk Extract feature in import.io and pass the whole list of URLs to be queried against the API.

Shape File To Convert Realtion tag in OSM Data

I am Routing Working routing application which is working in osm data but i have data in shape file so by using JOSM i convert in to OSM data but i have another file for turn restriction where i have get to , form and Junction data so how to implement in to osm file

Where does Nominatim get its address info?

Till now, I was using the Nominatim API to fetch landmark information from but recently, I've downloaded the OpenStreetMaps database, and tried to make my own dataset, so I would not rely so heavily on Nominatim services. I managed to extract from the OSM database the needed information (nodes tagged with amenity for example), but I realized, that while I was querying for amenities through Nominatim, it returned a bunch of address info, which is nowhere to be found in the OSM database.
Example:
Reverse geocoding of a hotel from Spain using Nominatim:
http://nominatim.openstreetmap.org/reverse?format=xml&osm_type=N&osm_id=1207098527
The data that is attached to the same node used to reverse geocode in OSM:
http://open.mapquestapi.com/xapi/api/0.6/node/1207098527
While Nominatim gives me Suburb, Pedestrian, City, County, State, etc. information, this node in OSM contains only a name tag, and a tourism tag.
Does anyone know, where is Nominatim getting the additional data it uses to display its information from?
Nominatim does not just look at individual objects but gathers information from multiple objects instead. Look at the information Nominatim knows about "HOTEL LA MORADA MAS HERMOSA": There are:
the node, lacking all address information (feel free to improve this!, at least house number and street should be added)
a nearby street
the suburb the hotel is located in
the city
... and so on.
Remember, OSM is a spatial database. Instead of attaching all information to each individual object one can do spatial queries in order to gather various kinds of additional information.