3
votes

I am new to PostGIS. I am looking to have a simple bounded (-200 < x, y, z < 200) data set of 1,000,000 points on a plain XYZ graph. The only query I need is a fast K nearest neighbors and all neighbors such that the distance is less than < N. It seems that PostGIS has a LOT of extra features that I do not need.

  • What do SRID do I need? One that does not concern with feet or meters.
  • Am I right that I need to use the function ST_3DDistance to query for the K nearest neighbors with LIMIT K? or with a maximum distance of N.
  • To add a column, I need to use SELECT AddGeometryColumn ('my_schema','my_spatial_table','geom_c',4326,'POINT',3, false);. Is that correct?
    • What is the difference between a 3D point and a PointZ?
    • Will AddGeometryColumn ensure that my distance query is fast?
  • Is PostGIS the right choice for my use case? The rest of my DB is already integrated with PostgreSQL

Thanks!

1

1 Answers

5
votes

What do SRID do I need? One that does not concern with feet or meters.

You don't "need" a srid. If your data is a in a coordinate system, find the right srid, otherwise, use 0.

Am I right that I need to use the function ST_3DDistance to query for the K nearest neighbors with LIMIT K? or with a maximum distance of N.

Yes, you're right.

To add a column, I need to use SELECT AddGeometryColumn ('my_schema','my_spatial_table','geom_c',4326,'POINT',3, false);. Is that correct?

Yes, but I'd use 0 for srid, instead of 4326 (that is for degrees).

What is the difference between a 3D point and a PointZ?

PointZ is a 3d Point.

Will AddGeometryColumn ensure that my distance query is fast?

AddGeometryColumn will just add some constraints to the table, ensuring that the geometries you insert are coherent with the column definition.

I don't think you need it, but you could try adding an index to your geometry column using CREATE INDEX index_name ON schema.table USING gist (geom_col);

Is PostGIS the right choice for my use case? The rest of my DB is already integrated with PostgreSQL

I think it is the easiest way, not necessarly the "right" one.

You could also implement a distance function without postgis, storing the three coordinates in three numeric fields.