
I ran the query statement below to create an intersection of the road network layer and country layer (scotland in particular). After unsuccessfully converting the resulting table into a shapefile, I found out that the table contains heterogenous geometry types. It consists of several linestrings and multilinestrings as well as a geometry collection. The latter contains one point and one linestring. I was curious as to why the query would return a geometry collection so I went on to plot the point and linestring that made up the geometry collection. The point turned out to be one of the vertices of a linestring. The linestring, on the other hand, is valid but I wonder why it has to be included in a geometrycollection and not as a separate linestring entry. Does anybody have explanation for this?

Corollary to this, is there a way to force the resulting table to return only a specific geometrytype (e.g., linestring only) so I could skip the extra step in exporting it to shapefile? Right now, since I'm aware that the output table does not have a homogenous geometry type, I do a filter on it whenever I export it using pgsql2shp.

I have uploaded a captured image of the country layer with the queried road layer in http://gislnxserver.irri.org/intx.gif . The valid linestrings/multilinestrings are in red while the linestring included in the geometrycollection is in blue. The point included in the geometrycollection is shown in black.

This is the query statement I used to generate the table:

"CREATE TABLE sc_road AS SELECT b.name, a.*, intersection(a.the_geom, b.memgeomunion) FROM road AS a, (SELECT name, memgeomunion(the_geom) FROM polbndry WHERE name='SCOTLAND' GROUP BY name) AS b WHERE a.the_geom && b.memgeomunion AND intersects(a.the_geom, b.memgeomunion);"

I used memgeomunion primarily because a country may be composed of several polygons and it should be grouped into one prior to intersecting it with the road layer.


_____________________________________________________________
Check out Atenista.Net (www.atenista.net)- new design, regular content and additional services!

