I am using PostGIS and QGIS 2.2.
I have a shapefile of rivers and a shapefile of state parks and other polygons. I would like to show the user a simplified version of a stream as a straight line, with the edges of the stream line highlighted where it intersects a polygon.
Here is a picture of my map in QGIS: Ignore the tributaries - they are well named and easily culled :)
Here is the simplified version I would like:
In order to create the above image, I would imagine I need to split the stream into several lines. In the above example, I would need six. Blue, Green, Blue, Green, Blue, and Green again. Each of these segments would have a distance and a type (blue, or green). The total distance would be normalized to unit length, and all the segments would be displayed for the user.
Another solution would be to simply track the Green segments, each with two offsets: a point, and an end point. In this case, there would only be three segments, and they would show where they started and stopped. This would work well if I wanted multiple types.
It was fun to find the distance of the stream inside of polygons vs outside using ST_Intersect and ST_Length. However, that was simply a ratio of inside vs outside. My solution needs both length and order. I think I need to split the line into several smaller lines - both inside and outside the polygons.
I think my solution needs to satisfy the following properties:
- Length of each segment must be preserved
- Order of segments must be preserved