[postgis-users] make the buffer in 3d

Kevin Neufeld kneufeld at refractions.net
Wed Sep 17 14:51:39 PDT 2008


Do you mean you want to select all point features in a specific cylinder?

Well, you could do it in a 3D bounding box (using cube), but I don't 
know of an easy way to filter which points lie in your 3d box, but 
outside the cylinder.  I suspect you'll have to write a custom plpgsql 
function and do some math in there ... returning true or false 
appropriately.


On a side note, this example shows how to build a 3D index on a geometry.


-- Create 10,000 3D points randomly for a sample dataset
CREATE TEMP TABLE tmp AS
SELECT
   ST_MakePoint(random()*1000, random()*1000, random()*1000) AS the_geom
FROM generate_series(1, 10000);


-- Create a 3D index on the geometry
CREATE INDEX tmp_geom_cube_idx ON tmp USING GIST (
   cube(
     cube(
       cube(ST_XMin(the_geom), ST_XMax(the_geom)),
       ST_YMin(the_geom),
       ST_YMax(the_geom)
     ),
     ST_ZMin(the_geom),
     ST_ZMax(the_geom)
   )
);

ANALYZE tmp;


-- SELECT the points that lie within the z-value range [500,501]
SELECT ST_AsEWKT(the_geom)
FROM tmp
WHERE '(0,0,500),(1000,1000,501)'::cube @>
   cube(
     cube(
       cube(ST_XMin(the_geom), ST_XMax(the_geom)),
       ST_YMin(the_geom),
       ST_YMax(the_geom)
     ),
     ST_ZMin(the_geom),
     ST_ZMax(the_geom)
   );

                          st_asewkt
-----------------------------------------------------------
  POINT(226.273822132498 958.905964624137 500.327607151121)
  POINT(578.404269646853 912.93861810118 500.205896329135)
  POINT(829.249489121139 923.576071392745 500.778052955866)
  POINT(677.46328888461 946.14454684779 500.152825843543)
  POINT(807.106878608465 67.1494407579303 500.44699665159)
  POINT(494.829344097525 620.502772275358 500.783439725637)
(6 rows)


Cheers,
Kevin

eehab hamzeh wrote:
> Hello,
>  
> I have a point feature, i need to buffer this point by specific 
> distance. then extrude the resulted circle by the same buffer distance.
>  
> Is there is a possibility to select all the feature that are in the 3d 
> space of this feature.
>  
> Thanks
>  



More information about the postgis-users mailing list