How to get a polygon (for buildings) with one known inside node? - openstreetmap

I'm now using OSMnx to extract data for buildings. What I need is to get building polygons through addresses. The question I met is about some of the buildings have multiple addresses, thus there are no address data for that building's polygon.
For example, the building 'Furutorpsgatan 49A' (in Helsingborg, Sweden) has three nodes you can search for, which are:
Furutorpsgatan 49A; Furutorpsgatan 49B; Gustav Adolfs Gata 23
But if you export the geometry data (polygon), there's no address data at all! In another word, there's no way to get the building polygon except for three nodes inside.
I was trying to use OSMid for polygons to match the position, but I can't find the building with OSMid 'w483244917'
Then I'm thinking is there any method I can extract the polygon data through one or several nodes inside?
Or could you suggest me some methods to get any building footprint polygons through building addresses?
Or is there a plugin for grasshopper to get building footprints by addresses?
Thank you!

Related

How to compute bounding boxes of specific roads from Overpass api

I have a high volume dataset with keys like this:
lat:6.897585,
long:52.785805,
speed:12,
bearing:144
Basically it is a dataset of records of various trips on cars. The data was stored every few seconds during each trip. The main goal of this project is to be able to visualize only u-turns (turn arounds) on a map. But for now, I am trying to at least show the data on specifc roads. For that, I am using Overpass API
With the help of Overpass Turbo, I can get a dataset with all the roads I need.
However, in the dataset, the road's geometry is represented with LineString type.
My question is, How can I get a bounding box(es) of the roads from Overpass API, so later on, I can display events that happened only on the given roads? Or maybe you have a better solution on how to achieve this?
A bounding box wouldn't be very helpful here, as using it to filter your points would show everything that falls within the box (which could include other nearby roads)
It sounds like getting a buffer around a linestring might get you closer, but could still include points that are within the buffer but not on the road you are inspecting.
The smarter way to do this would be to assign each event to a road segment using some logic based on their attributes/properties, so you don't have to depend on a spatial filter.

OSMnx: lacks for addresses when extracting building footprints from OpenStreetMap

I'm using OSMnx to get building footprints for buildings, expecting to put polygon data in grasshopper to generate building models for energy simulations. I already have building height data and other energy input for that. The question is I need building addresses along with geometry data (polygon) from OpenStreetMap to match the building height data I have.
I used ox.geometries_from_place('Helsingborg, Sweden', tags={'building':True}) to get polygons of building footprints but there are so many blank in address columns like addr:city, addr:street.... But I'm pretty sure there's data for this information because I can see the address info when searching the building on OpenStreetMap web.
For example, I searched the building called 'Furutorpsgatan 49A' in Helsingborg.
In OpenStreetMap, all the information looks fine, but in the data I extracted from OSMnx there's no address info
What should I do? Is there any mistake I made? Or Is there any other method to get building footprint data for a specific building?
Many thanks!

Hide polygons that are within a specific area

I'm trying to create an experience where I have a couple of detailed 3D models of buildings on the map with extruded building footprints of neighboring buildings via a vector tile source. The 3D models would be the main focus point and the extruded footprints would be for reference. One challenge I'm running into is that I have a global building footprint layer and it has a footprint for the 3D buildings which doesn't match up perfectly. Additionally, when extruded, it ends up merging/overlapping the nice 3D models.
I'd like to be able to hide the individual footprints that overlap the 3D models. My original thought was to grab the bounding box of the 3D model and then use the new within style expression, but it looks like this will only filter points and lines, not polygons. The building footprint polygons have no unique information in them that I could use to filter on.
I know I could monitor map movements and query the rendered features and manually detect intersecting polygons, but since there is no unique property on the footprint, I can't filter or use feature state.
Any ideas of how to efficiently avoid rendering individual polygons in a specific area that come in from a vector tile source?
It is a common issue that the buildings layer in Mapbox Streets don't contain any unique attributes to allow filtering or rendering differently.
The best solution is usually to source a different buildings layer, and in this case, remove those redundant buildings in pre-processing.
I can think of one rather crazy workaround that might work here, although the performance may be poor.
Add the building layer with very low opacity, of type fill, essentially invisible. (Maybe invisible would work.) Call your main source buildings`.
Create a secondary building source of type geojson, and a secondary fill-extrusion layer. Call this source buildings-copy.
On map move or moveend, use querySourceFeatures to obtain a copy of all buildings.
Process this copy using Turf to remove the buildings you don't want, and call setData to set the copy as the data for buildings-copy.
You may need to do some clever caching to get reasonable performance.

Mapbox: Making a line given two OSM Node IDs

I have two Open Street Map node IDs. Is there any API provided by Mapbox or Leaflet which could draw a PolyLine or LineString given the two node IDs?
I am not able to find any reference to OSM IDs anywhere in Mapbox documentation, apart from here and it does not detail how to use the OSM IDs for ourselves to draw lines on the map.
What I want to do is given 2 OSM IDs, I want to highlight the road segment connecting those OSM IDs. I can't go for things like Leaflet routing machine since the number of such lines are too many, with small distances. I can't run routing for all the edges.
Since you say "I can't go for things like Leaflet routing machine since the number of such lines are too many, with small distances. I can't run routing for all the edges." I'm excluding all solutions calling an external routing API, instead you can do your own internal routing.
Use the OSM Overpass API to get the long,lat points for those nodes
In Mapbox GL JS fitBounds to those two nodes and do map.querySourceFeatures to get the roads as GeoJSON LineStrings
then compute a network graph from this and use Dijkstra's algorithm to get the shortest path between your two OSM nodes.

How does routing services for OSM determine the distance between two points

I am going to design an Android application and I will be needing the distances of the pathways inside our university(pathways between buildings)
I read about OSM(OpenStreetMap) and tried it. It is a map which is editable which means anyone can contribute to that map(like a wikipedia map version).
It has many routing services that give routes and directions between two point(start and end).
There is a routing service named GraphHopper and it is very easy to use. I can just drag and drop the start and end pt and it gives the distance(km) between the two pts.
What I want to know is how did they come up with the distance?
Is the distance reliable and accurate?
Any help is greatly appreciated because I want to use the distances for my Android app and I need to know if these distances have basis.
The distance is 'accurate' in the sense that it correctly processes the existing information from OpenStreetMap and correctly adds road segments for the final route. You can just try for your local area and compare to your own knowledge.
There could be mapping errors, where a road is incorrectly mapped. And there could be also roads missing and so the router uses a detour making the path unnecessarily longer. Also there are different modes like for cars or bikes or fastest and shortest where you get a different distance between two coordinates.