Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to perform a diff operation on Postgis features/tables or Geotools objects? Are there any automatic methods I can use? If not, what would be the optimal way to implement your own diff? For example I have two versions of a Shapefile and I import them into two separate PostiGIS tables, what algorithm should I consider now - how to compare a geometry column and get a diff result? I would be grateful for any advices or links to additional sources/articles concerning this matter.

share|improve this question
up vote 1 down vote accepted

Not absolutely clear what you are trying to do, but you may want to take a look at ST_Equals, ST_Difference functions. (if you expect things to be more or less exact)

Then you do a join something of form

SELECT t1.gid
  FROM t1 LEFT JOIN t2 ON ST_OrderingEquals(t1.geom, t2.geom)

Would give you all the gids that are not exactly represented in second table.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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