[postgis-users] Bounding Box Clipping

chodgson@refractions.net chodgson@refractions.net
Mon Nov 10 18:24:35 2003


To do this in postgis, you would need to create a grid of square polygons and 
use geos to calculate the intersection of each square with your big polygon.
It might be easiest just to script the grid generation, unless you have a 
standard grid lying around (mapsheet grid? lat-long based grid?). It shouldn't 
be to painful to do this with PHP or (insert favourite scripting language 
here). If you are good with C++ then you could even do it natively with GEOS, 
that would probably be much faster to do the whole overlay - I expect it will 
take a while to overlay a few hundred individual squares with your on big 
polyogn.

I actually used the FME when I did this, it was my first time using it but it 
was incredibly simple to do the grid overlay on the big polygon and also to 
chop the coastline up into smaller segments. If you have this tool available i 
would suggest that it is the best way to go.

Chris

Quoting Chris Faulkner <chrisf@oramap.com>:

> Good idea. Is there any easy way of creating a grid suitable for overlaying
> ? I could script something but is there anything built-in ? Second, how
> would I do overlay and what would the results be ? I can see various
> functions but not all are documented.
> 
> Thanks
> 
> Chris
> 
> > -----Original Message-----
> > From: postgis-users-bounces@postgis.refractions.net
> > [mailto:postgis-users-bounces@postgis.refractions.net]On Behalf Of
> > chodgson@refractions.net
> > Sent: 10 November 2003 17:45
> > To: PostGIS Users Discussion
> > Subject: Re: [postgis-users] Bounding Box Clipping
> >
> >
> > 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
> > >
> >
> >
> >
> >
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users@postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> 
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>