[postgis-users] Bounding Box Clipping

chodgson@refractions.net chodgson@refractions.net
Mon Nov 10 17:44:46 2003


If you are using this for a dynamic mapping application, using geos may not be 
ideal - I believe it would take longer to calculate the intersection of your 
box and the polygon than to just transfer all of the points and throw away 
those outside of the box (as mapserver would do when rendering the map).

A better solution would be to chop your coastline into smaller pieces, small 
enough that a "normal-sized" bounding box would select a few of the pieces. 
Even though there would now be more geometries to select, each would be much 
smaller and the total number of coordinates would be much less. In addition, 
the spatial index would be able to locate which pieces are inside the bounding 
box very quickly. 

In the case of lines, this can be achieved by "chopping" the line at every 50th 
vertex, or something like that (depending on the resolution of your data and 
the intended viewing resolution). For polygons, you can overlay a grid onto the 
polygon and chop it into little squares - on the edges of the polygon, they 
won't be square, they will have a section of the edge of the original polygon, 
as well as some straight edges where the grid cut it up. Again, the size of the 
grid is relatively flexible, but you want to achieve a balance between not 
having to deal with too many excess points, and not having to select too many 
individual pieces. 

Chris

Quoting Chris Faulkner <chrisf@oramap.com>:

> Hello
> 
> I am selecting a large polygon (coastline of Great Britain) from my
> geometry_field, using a clause like this
> 
> geometry_field &&GeometryFromText('BOX3D(189858.0 746543.0,195858.0
> 750543.0)'::box3d,-1)
> 
> This obviously retrieves the whole geometry where it overlaps with the
> coastline - a lot of coordinates ! Are there any functions or operators I
> can retrieve so that this polygon is clipped to my box and yet retain the
> polygon ?
> 
> Thanks
> 
> Chris
> 
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>