Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

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.

http://postgis.net/docs/manual-2.0/ST_Difference.html

http://postgis.net/docs/manual-2.0/ST_OrderingEquals.html (if you expect things to be more or less exact)

http://postgis.net/docs/manual-2.0/ST_Equals.html

Then you do a join something of form

SELECT t1.gid
  FROM t1 LEFT JOIN t2 ON ST_OrderingEquals(t1.geom, t2.geom)
WHERE t2.gid IS NULL;

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

share|improve this answer
add comment

Your Answer

 
discard

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.