pszufe / OpenStreetMapX.jl

OpenStreetMap (*.osm) support for Julia 1.0 and up
MIT License
118 stars 24 forks source link

Is there a way to extract the lat/long coordinates for each point along a "way?" #64

Closed 00krishna closed 2 years ago

00krishna commented 2 years ago

So I get that a way represents a set of edges between nodes in an OSM graph. I was wondering, is there a method to query all of the points that fall along a way? That is, I would like to identify all of the latitude and longitude points along a way.

I did google this question, and it seems like other people push the OSM graph into a database like PostGIS to do this. I was just wondering if there was a way to do this without pulling down to a database? Thanks.

The reason is that I have a different geospatial layer, and I need to basically match the points on each path to the points on the raster layer. And then I can basically integrate that path, and assign that integral value to the nodes on either side of the path. And then I can hopefully use that information to make routing decisions. That is the intent anyway.

Thanks.

ghost commented 2 years ago

Hi,

As OSMX pakage gives the routes in the format of node IDs and as m.nodes[node_id] command returns an ENU coordinates so you can perhaps use the following:

LLA(m.nodes[node_id]) # which gives latitude and longtitude

pszufe commented 2 years ago

Basically, the ENU coordinates are ready for plotting. Having an ENU node you can do getX(::ENU) and getY(::ENU) and use it to plot a map. OpenStreetMapXPlot.jl is actually using this mechanism. To convert from ENU to LLA you need to provide the reference point where the ENU system is attached. typically this will be something like:

LLA(enu, some_map_data.bounds)

where enu is an ENU node and some_map_data is a result of loading of an OSM file

00krishna commented 2 years ago

@pszufe Oh thanks for showing me how to do this. This is very helpful. So ENU coordinates are the way to go. I will try and implement this.