Search code examples
openstreetmappostgis

How to get all points along a way from (osm)PostGIS?


I have import OpenstreetMap data into Postgres with gis extension with tool osm2pgsql (-s option)

of course, I have the following tables

planet_osm_point
planet_osm_ways
....

Within planet_osm_ways I have a column called way, type geometry(LineString, 4326), content like following

"0102000020E6100000070000005E70BCF1A49F2540D3D226987B134840896764EB749F25403B5DCC858013484040D1860D609F2540C426327381134840CE50DCF1269F2540EF552B137E1348405AAB2CC02D9E2540F978324976134840D66F26A60B9D2540CE8877256E1348403CA81F2FFF9C2540BC1D86FB6D134840"

What is that ? How could I get all points along this way ?


Solution

  • That's hex-encoded extended well-known binary (EWKB) of a LINESTRING.

    There are several methods to get the points along the way. To get individual coordinates as points, use ST_DumpPoints. Or to simply output the geometry in other human-readable formats (WKT, EWKT, GeoJSON, GML, etc.), see the relevant manual section.