[postgis-users] Corridor

Brent Wood pcreso at pcreso.com
Thu Jan 4 11:17:33 PST 2007


--- Eric FRANCOIS <ericfrancois at hotmail.com> wrote:

> Hello,
> 
> I'm looking for a method to create a corridor (tunnel) between two points. I
> need to make a polygon witch contains the two points with the possiblity to
> enlarge it via a constant.
> 
> envelope() and box3d() is not good for me as they create a rectangle.


Use makeline to generate a line between the points, then use buffer to generate
the desired polygon. Buffer also accepts an optional third parameter, the
number of points it will generate to make a 1/4 circle, defaulting to 8.

Try:

 select 
   buffer(makeline(point,point),<buffer dist in proj units>, <num_points>)

If you are using lat/long coords (eg, SRID=4326) you can transform the line to
a suitable projection for your locality before buffering, then back again
afterwards, ie, (indented for readability):

 select(
   transform(
     buffer(
       transform(
         makeline(point,point),
       SRID2),
     distance, [npoints]),
   SRID1)



HTH,

  Brent Wood



More information about the postgis-users mailing list