A line segment represents a bounded linear object defined by two points and a length. In geospatial data, roads and trails appear as connected sequences of segments, commonly stored as LineString geometries. section 10.1
PostGIS lets you inspect these objects, measure their lengths, and test whether they share points with another geometry. Roads, rivers, highways, and similar linear features can be queried from an OSM-derived line table. section 10.5.3
Finding roads within or crossing Miami
A query selects primary and secondary LineString roads that intersect Miami’s boundary, then reports each geometry’s point count and length in meters and feet. Results can be ordered to show the longest roads. section 10.5.3
Listing 10.22 Finding the top 10 roads within or crossing Miami
WITH miami AS ( SELECT way AS boundaries FROM florida.planet_osm_polygon WHERE name = 'Miami' AND place = 'city' ) SELECT l.name, l.highway, ST_NPoints(l.way) AS points_number, round(ST_Length(l.way)) AS len_meters, round(ST_Length(l.way) * 3.28084) AS len_feet FROM florida.planet_osm_line l JOIN miami m ON ST_Intersects(l.way, m.boundaries) WHERE l.highway IN ('primary', 'secondary') ORDER BY len_meters DESC LIMIT 10;
Run the supplied SQL listing to connect line-segment geometry with city-boundary filtering, road classification, point counts, and length conversion. section 10.5.3



