[postgis-users] Spatial query performance & GMT format output

Wood Brent pcreso at pcreso.com
Mon Feb 23 10:25:08 PST 2004


Regarding the performance of spatial queries, one aproach I have used for large
complex polygons (coastlines) is to tile the area, then manually remove tile
borders which still leave rectangles inside the polygons, as well as any tile
borders outside them. Give all the rectangles & internal border polygons the
same name attribute as the original polygon they lie inside.

A Postgres query along the lines of:
"select poly_name from table 
 where <geometry0> <inside/intersects/overlaps> <geometry1>
 limit 1;"
returns any matches very quickly, even with millions of vertices in the
original coast. (If you want all matches, rather than is there a match, use
distinct & remove limit)

For islands (polygons in polygons) a view was created on the original table to
select just polygons with a classification of island, then any hits from the
first were checked with a subquery along the lines of:
 
"select poly_name from table 
 where <geometry0> <inside/intersects/overlaps> <geometry1> and 
 poly_name not in 
         (select poly_name from island_view where <geometry> inside <geometry>)

 limit 1;" 

I arrived at this process as the optimum using a GIS with very good topological
capability initially (Genamap), then dumped the new maps into Postgres/Postgis
tables. it gave very good response times, pretty much independent of polygon
complexity. It did take a bit of time using commercial GIS to set up however. 



Which sort of leads to my questions:


Is a comparable approach able to be set up just using Postgres/PostGIS/GEOS??

Can anyone recommend a good graphical front end (GRASS? QGIS?) to a
Postgres/PostGIS spatial database where features can be displayed/edited/
maintained?


Has anyone a written a function to dump XYZ output into a format for plotting
with GMT? (I'm able to reformat the query output to work, but haven't written
internal PG functions. I'd like to pipe the output directly into GMT to plot
the data). FYI the format required is:

x0 y0 z0
x1 y1 z1
...
xn yn zn
>
x0 y0 z0
...
...

ie: sequences of XYZ on separate lines separated by a ">" on a line for
multiline or polygon features. 


Thanks,

  Brent Wood



More information about the postgis-users mailing list