22

I know QGIS comes with its field calculator, which is not bad. It also comes with ftools which permits several operations on geometry and attributes. But we often need more control and I haven't seen any convenient tool in QGIS to perform such operations (where you can select fields you need for example or perform arithmetical operations on them while doing a spatial query).

Basically, I'd like to know if a SQL console (a kind of Mapinfo mapbasic window) is on the roadmap of QGIS and if not, if it would be hard to code it as plugin. If it exists yet, please let me know, i've missed it! ;-)

6
  • 4
    This doesn't really seem like a good question for this site. It would be better put to QGIS devs on one of their mailing lists. A better question might ask how to do a specific thing or get a certain result with QGIS. Questions about planned features will become moot and pointless or even wrong in time.
    – Sean
    Commented Mar 15, 2011 at 19:30
  • 1
    FastSQL is awesome! Especially that you can replace the layer you are looking at immediately. This adds extraordinary power to QGIS connected to PostGRES. However, I have found one problem, and that is the use of the spatial operators. I can perform basic SQL queries in FastSQL, but none of the spatial queries for. For example, this query works just find in the DB Manager plugin: select * from wetlands,watersheds where st_intersects(wetlands.geom,watersheds.geom) but, when I try it in FastSQL, it says its not a valid layer and cannot be added to the map. I'm thinking that there is something pr
    – user16112
    Commented Mar 13, 2013 at 13:06
  • I spent a lot of time to find the way to do that in QGIS 2.0. Most of the answers here and on google are outdated. @Simo : Can you check HeyOverThere's answer as the best answer? It will be easier for next readers to find the fresh correct answer. Commented Dec 13, 2013 at 9:03
  • This is done (with an additional comment)
    – simo
    Commented Dec 13, 2013 at 9:31
  • Can you tell us why the answer doesn't satisfy you completely? Commented Dec 13, 2013 at 10:11

5 Answers 5

10

The new DB Manager plugin is now a standard part of QGIS from 1.8 forward. It has autocomplete, syntax highlighting, and you can add layers created from a spatial query to your map.

In 1.9 (the development version for 2.0) DB Manager adds import / export functions that are pretty handy.

1
  • I'm not satisfied with this answer because I was looking for a built-in tool that works whatever the data format is, but as @Nicolas-Boisteault said, accepting this answer may put other people into the right direction. I hope, so!
    – simo
    Commented Dec 13, 2013 at 13:49
10

RT Sql Layer plugin can do what you want (but it's not a console).

enter image description here

You can use python console too: 'PostGIS ’select’ statement as vector layer in QGIS'

8
  • Thanks underdark. I also know that plugin but it relies on Postgis layer use. Actually I would like to have a tool which is not format input dependent (as orbisgis propose, see agemen post)
    – simo
    Commented Mar 16, 2011 at 8:49
  • 3
    I see. I haven't heard of any such plans. Maybe a plugin that uses spatialite in the background could be an approach. This could be a topic for Google Summer of Code.
    – underdark
    Commented Mar 16, 2011 at 10:38
  • Should I add myself a request on qgis.org/wiki/Google_Summer_of_Code_2011? I'm not sure I cant create an account on gqis wiki page.
    – simo
    Commented Mar 16, 2011 at 12:56
  • You can ask on the user mailing list to get a wiki account. (We had spam problems.) At the same time, you can ask other user/dev opinions on the topic.
    – underdark
    Commented Mar 16, 2011 at 13:00
  • 1
    @Nathan > Nice, you are following that post. I should really submit the idea on qgis dev list (except if you did it already?). Using a standard SQL to query any type of data is just fantastic (see orbisgis).
    – simo
    Commented May 17, 2011 at 13:14
7

there is a new plugin available: Fast SQL Layer.
It opens an docked sql console with code highlighting.

3
  • 1
    very cool, a good start! Note: depends on Pygments (so for OSGeo4W users, there are few manual steps to build/install this)
    – Mike T
    Commented May 24, 2011 at 23:34
  • 1
    Yes, for now the solution is to copy pygments to the site-packages folder of osgeo4w instalations. It worked for me. Soon I will release and updated version to solve that.
    – Pablo
    Commented May 24, 2011 at 23:54
  • 1
    I downloaded and extracted Pygments-1.4.tar.gz, then in an OSGeo4W shell within the Pygments-1.4 directory, type python setup.py build then python setup.py install
    – Mike T
    Commented May 25, 2011 at 1:01
2

is SQL Query Editor (for PostGIS) what your looking for?

http://plugins.qgis.org/plugins/version/12/

1
2

I don't know such a tool in QGIS. Another open-source GIS software offers such capabilities, however, that is named OrbisGIS : http://www.orbisgis.org

Unfortnuately, as one is written in C++ and the other is in Java, it would be certainly difficult to link them... :-(

2
  • Actually, i'm also an orbisgis user (i'm a former STEU student) ;-) -switching from one to other ... and I think your SQL console so efficient that I'd like to have the same on qgis (I mentionned mapbasic in my question because it's more known!). Orbisgis allows a full control through the SQL console but it can take time to perform some basic operations. At the opposite, Qgis is designed to perform easily some basic operations but make it harder for full control operations.
    – simo
    Commented Mar 16, 2011 at 9:10
  • I understand what you mean... Fortunately, the last version of OrbisGIS add auto-completion in the SQL console. And we are working to add the ability to perform basic operations outside of the SQL console.
    – Agemen
    Commented Mar 16, 2011 at 16:39

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.