I have basically the same conundrum as Calculating line segment lengths within polygon using ArcGIS Desktop? but I'm working in PostGIS, not ArcGIS. Any pointers?
This query seems to like it should work, just to show the sums:
SELECT county, ST_LENGTH(ST_Intersection(counties.the_geom,routes.the_geom))
FROM counties, routes
WHERE ST_Intersects(counties.the_geom, routes.the_geom)
But I'm not confident that I'm getting it right and I can't figure out how to reshape that into an update query.
Best Answer
If I understand the translation correctly, proceed as follows:
1)
2)
Important: the original data lines - type LineString; EPSG 4326.
The total length of the lines will be in meters, with respect.
If you don’t like to dance the old-fashioned way like me step by step, dance in a modern and independent way by running the following script:
Good luck :-)