6

I am working with spatial data in land management using Oracle. The daily task is to perform spatial analysis: defining the mutual disposition of land plots borders, territorial areas etc. The accuracy of coordinates of every border depends on its type and location (city, forest). For that reason determination of spatial relationships of objects is carried out with varying tolerance in different tasks.

This is what I am doing using Oracle:

  1. perform initial filtering of data by an SDO_FILTER-operator,
  2. determine the spatial relationship with the specified tolerance using SDO_GEOM.RELATE procedure, where tolerance is one of the prameters of SDO_GEOM.RELATE.

When I started to work with PostGIS I found out that there is no such parameter as tolerance in methods used for spatial analysis.

Could you tell me please how to realize scenario described above using PostGIS? Is there any possibility to set tolerance of methods?

3
  • 2
    Check if ST_SnapToGrid is what you need postgis.net/docs/ST_SnapToGrid.html Commented Jan 11, 2016 at 8:56
  • Perhaps you could state what sort of tolerance and what projection you are using. Double precision numbers in a projected coordinate system are likely to provide enough, and as states, you can used St_SnapToGrid to force a particular tolerance. Commented Jan 12, 2016 at 14:27
  • @FranciscoPuga, could you write your comment as an answer so it could be accepted?
    – user30184
    Commented Jun 28, 2019 at 12:43

1 Answer 1

1

It's difficult to provide an accurate response without knowing the exact use cases. I will try to provide a couple of tips and useful PostGIS functions for these kind of tasks.

  • You can use any of the PostGIS Operators for the first filtering. Most of the spatial relationship functions already use by default the && operator and geometry indexes to compare bounding boxes. I don't work with Oracle but this can be similar to the SDO_FILTER
  • For the first filter you can also use ST_DWithin as is explained in this answer.
  • Instead of set the tolerance you can try to snap each geometry to a grid with the function ST_SnapToGrid. I think that ST_SnapToGrid is commonly easier to use than ST_Snap and more versatile.
WITH 
    t1 AS (
        SELECT id, ST_SnapToGrid(geom, 0.001) as geom FROM table1
    ),
    t2 AS (
         SELECT id, ST_SnapToGrid(geom, 0.003) as geom FROM table2
    )
SELECT
    t1.id
    , t2.id
    , ST_Relate(t1.geom, t2.geom) 
FROM t1 JOIN t2 ON t1.geom && t2.geom
  • You can even create another geometry column in your table and keep the snapped geometry updated with triggers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.