[postgis-users] Discovering where roads cross rivers

Brent Wood pcreso at pcreso.com
Fri Oct 19 14:32:08 PDT 2007


> > On 15-Sep-07, at 8:03 AM, Dave Potts wrote:
> >
> >> I am trying to discover all the data points when a river system 
> >> crosses a road system, my data is expressed as two different 
> >> shapefiles,  I had assumed that it was just a case of calling  the 
> >> Intersection method
> >>
> >> eg. select m.name from transport m , rivers r where 
> >> Intersection(r.the_geom,m.the_geom) = 't';
> >>
> >> But I get a 'parse error- invaid geometry when I try this, is this 
> >> the correct way of doing this?


This seems obvious, but when you say your data is expressed as two shapefiles,
I assume you have loaded the data in these shapefiles into postgis tables
before trying to query them?

If you have, can you select the data in your tables OK? eg,
 select *, astext(the_geom) from transport;


Are there any invalid geometries in the tables? Try:
select count(*) from transport where not isvalid(the_geom);

if there are, then fix these, or amend your query to exclude any invalid
geometries:

select m.name from transport m, rivers r where
isvalid(m.the_geom) and isvalid(r.the_geom) and 
intersection(r.the_geom,m.the_geom) = 't';


Cheers,

  Brent Wood



More information about the postgis-users mailing list