1

I have some experience with PostgreSQL, but not with PostGIS, and for the life of me I can't make my bounding box take the Z axis into account.

I have a points table with XYZ columns. I add another one:

ALTER TABLE foo ADD COLUMN the_geom Geometry(PointZ,4326); 

Then I populate the_geom column with my XYZ coordinates:

UPDATE foo SET the_geom = ST_SetSRID(ST_MakePoint (x,y,z), 4326) 

I confirmed my 3 dimensions with:

SELECT f_geometry_column As col_name, type, srid, coord_dimension As ndims FROM geometry_columns 

And finally, I can query my data against the bounding box with:

SELECT * FROM foo WHERE the_geom && ST_3DMakeBox( ST_MakePoint(0,0,0), ST_MakePoint(6600, 15500, 0) ) 

Which should return no rows since in the bounding box the Z axis is 0 and all my Z data is greater than zero, but the query only filters the X and Y axes, not caring about the Z axis.

What am I'm doing wrong, please?

2
  • As stupid as it looks, just found out about the &&& operator. I've installed the latest postgis (2.1.7) but still no luck... Commented Jun 9, 2015 at 14:26
  • 1
    It seems like something like this: SELECT * from foo where the_geom &&& 'LINESTRING(0 0 0 ,6600 15500 3107.5)'; really works. Commented Jun 9, 2015 at 16:04

1 Answer 1

1

Try creating an n-d index on your geometry column:

CREATE INDEX foo_gix_nd ON foo USING GIST (the_geom gist_geometry_ops_nd);

Some more information is available here:

http://suite.opengeo.org/opengeo-docs/dataadmin/pgBasics/3d_types.html

2
  • As a matter of fact I did, found the same link you mentioned. Thanks! Just wished there was an easy way to visually confirm the results...QGIS seems to be 2D only and GRASS GIS is super complicated... Commented Jun 17, 2015 at 12:07
  • Why do you need to visualize this? your points ahve a z-coord, it is either within the z-bounds in the bbox, or it is not, should be easy enough to tell. Commented Jun 17, 2015 at 22:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.