Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 11 down vote accepted
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);
share|improve this answer
    
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
add comment

Nathan,

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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