[postgis-users] split line at polygon edge

Garret W garretlewis at gmail.com
Wed Mar 16 20:10:58 PDT 2016


Hi Ive been looking for a way to take several hundred lines and split them
where they intersect a polygon while also giving them the ID of the polygon
they fall in. Ive seen many posts on splitting polygons. But its been
difficult for me to adapt those examples.

Ive been able to get an output from this:

select st_intersection(t.geom, d.geom),t.trails_id, d.id
 from public.temp_trails as t, public.polys as d;

Its giving me the line and IDs that I wanted but the geom is unreadable for
some reason by QGIS.

99.9% of the lines fall within a polygon. Id like to still hang on to those
few lines that arent contained in a polygon. They should just be split with
no ID added

Im using; postgis 2.2, postgresql 9.5

Thank you
Garret
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20160316/e3d890b6/attachment.html>


More information about the postgis-users mailing list