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.

I am manually editing a Postgis layar with QGIS and would like to export these manual changes in the form of an SQL script. This way:

  • I can do it automatically next time i need to
  • it is easier to work on remote machines where i don't have QGIS

Is this possible?

share|improve this question
    
What type of manual edits are you making? Spatial edits? Attribute edits? Some more details may help us provide a better answer. –  Darren Cope Aug 29 '11 at 12:47
    
I meant spatial edits. It is easy to manually drag a line in QGIS but to repeat the exact same thing again is practically undoable. –  mrg Nov 21 '12 at 7:45
add comment

2 Answers

up vote 5 down vote accepted

Don't know how to do it specifically for QGIS, but when I want to know what queries an application is executing, I turn on logging on the database. If you are only interested in seeing update/inserts you can do this:

ALTER DATABASE mygisdb SET log_statement='mod';

Read: http://www.postgresql.org/docs/9.0/static/runtime-config-logging.html for more details

Then check your logs after your QGIS change and copy the statements.

Logs are usually kept in pg_log folder (check your postgresql.conf to be sure).

share|improve this answer
    
This sounds like a very good idea. I will have to try this to see if this works. I will get back here after i have tried your suggestion. –  mrg Aug 29 '11 at 17:11
    
I tried it and it worked! Thank you for your good answer! –  mrg Aug 30 '11 at 10:43
    
It might be handy to know that the output found in the logfile needs a bit of editing before you can use it in an SQL script. Make sure you add E before the bytestring and replace all occurrences of \ with \\ as in: geomfromwkb(E'\\001\\002\\000... –  mrg Aug 30 '11 at 17:29
add comment

I have no idea to do it automatically with QGIS but I know that you can retrieve WKT geometry just with copy and past data from QGIS to text file. You need to write the SQL part (*UPDATE FROM XXXX SET the_geom='' WHERE id='YY'* ou INSERT).

Hope it helps,

Y.

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.