Tuesday, 3 October 2017

Writing a plugin for QGIS using Python to access PostGIS and write geometries


Sorry about the strange title, I didn't really know how to word it.


I currently use MapInfo to do most of my GIS work however I have recently installed PostGIS 1.5 and I really like it so far.



A project that I am going to start working on in the future sometime will involve creating an application for managing stormwater assets, all my previous mapping projects have just been using a MapInfo window embedded in a C# application. Now that I have some data in a PostGIS server it has opened a lot of possibilities.


I tried writing some small sample applications using NHibernate and NHibernate.Spatial in C# but to say it's frustrating is an understatement (sometimes static typed code gives me the shits).


So I was wondering if anyone had any experience writing a QGIS plugin using python to access PostGIS and if you think it would be a viable route to take, and if so anyone had any good places to read about doing such things.



Answer



There are a lot of python plugins for QGIS that access PostGIS. Just download them and check the source code. Accessing PostGIS from Python is quite straight forward (same is true for SpatiaLite by the way).


PostGIS related plugins by name:



  • PgQuery for QGIS

  • PostGIS Manager

  • PostGIS SQL Query Editor


  • RT Sql Layer

  • ...


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...