I was wondering if it is possible to split a polyline on polygon boundaries (regions) in PostGIS, the picture below is of what we have at the moment and showing where I need the polylines split:

alt text

Lets call the regions road_blocks and the lines road_cl

If you can copy the data from the road_block under the newly created polyline to the new polyline that would be a real bonus.

CREATE TABLE new_road_cl AS
  SELECT ST_Intersection(r.geom, b.geom) AS geom,
         b.attr1, b.attr2, b.attr3,
         r.attr1, r.attr2, r.attr3
  FROM road_blocks b, road_cl r
  WHERE ST_Intersects(r.geom, b.geom);
  • Thanks but I seem to get this when I run it: TopologyException: found non-noded intersection between LINESTRING (397766 6.83237e+006, 397769 6.83237e+006) and LINESTRING (397767 6.83238e+006, 397766 6.83237e+006) at 397766 6.83237e+006
    – Nathan W
    Aug 25 '10 at 6:13
  • Just ran it on a single road, seems like there is some malformed data somewhere.
    – Nathan W
    Aug 25 '10 at 6:29
  • 1
    +1 Nice. Isn't the_geom not geom, the default geometry field name?
    – Adam Matan
    Aug 25 '10 at 7:04


1) Make sure your geometry is valid - invalid geometries are a major cause of these kind of errors. SELECT ST_IsValid(geom);

2) Which version of geos are you running? Do a

SELECT postgis_full_version();

GEOS 3.2+ runs into fewer of these topological exception issues.

To Adam - Paul decided one day he was too lazy to type the_geom :) -- so he proclaimed "from now on the default will be -- geom". We all stamped our feet and said -- NO until 2.0

So geog is default for geography and geom will be the default in 2.0 for geometry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.