I am trying to create curved lines between two point in QGIS. There are a few posts that show how to create these lines (hyperlinks below). However, I am having trouble executing the code in QGIS.

This article says one could use the following code:

SELECT st_makeline(st_segmentize((SELECT geog FROM paths WHERE gid = 1), 50000)::GEOMETRY);

This article says one could use this code:

UPDATE experimental.airroutes
SET the_geom = 
(SELECT ST_Transform(ST_Segmentize(ST_MakeLine(
       ST_Transform(a.the_geom, 953027),
       ST_Transform(b.the_geom, 953027)
     ), 100000 ), 4326 ) 
 FROM experimental.airports a, experimental.airports b
 WHERE a.id = airroutes.source_id  
   AND b.id = airroutes.dest_id

It's unclear where to execute this code. I have tried several options that I outlined below which so far have not been successful. Here is what I did so far:

I think I may need to utilize the "Add PostGIS Table(s)" (the elephant icon) function. If so it's unclear to me what the Name, Service, Host, Database, Username and Passwords should be. This post asked about this and the respondent suggested accessing pgAdmin, which I do not have and can't figure out how to get.

This post suggests executing the PostGis SQL code from the PostGIS Manager Plugin. However, this is not an available plugin from the Plugins library.

I have also tried to use DB Manager but when I click on the SQL Window icon I receive a message noting "No database selected or you are not connected to it."

Finally, I installed the Post GIS SQL Editor plugin but when I open the plugin I receive the following error "An error has occured while executing Python code:

TypeError: QComboBox.findText(QString, Qt.MatchFlags flags=Qt.MatchExactly|Qt.MatchCaseSensitive): argument 1 has unexpected type 'QPyNullVariant' 
  • You should start by installing PostgreSQL and PostGIS. Then you will be able to connect to it from QGIS. If you are on Windows the EnterpriseDB Stack Builder is the easiest way to install PostgreSQL, PostGIS and pgAdmin III at the same time.
    – thibautg
    Jun 9, 2016 at 5:14
  • @thibautg I'm working on a Mac and have installed PostgreSQL and PostGIS through the postgris.app. When I launch PostGIS my terminal opens outside of QGIS. It seems like I shouldn't have to do anything out of QGIS right? When I launch the PostGIS function in QGIS I am asked to enter a username and password which was was never previously prompted to create.
    – Danny
    Jun 9, 2016 at 13:52
  • you must create a connection between QGIS and PostGIS. (Similar question)
    – thibautg
    Jun 9, 2016 at 14:12
  • @thibautg It is unclear to me how to do this. I clicked the "Add PostGIS Layers" icon. I then selected "New." A screen comes up where I am asked to enter a username and password and several other credentials. I never created a username and password and when I leave these fields blank or put in random names I get an error message saying "could not connect to server: No such file or directory Is the server running locally and accepting conections on Unix domain socket "/tmp/.s.PSQL.5432"?
    – Danny
    Jun 9, 2016 at 14:25
  • there are many tutorials on the web on how to set up PostGIS like this one. For the Mac I recommend KyngChaos binaries or Homebrew.
    – thibautg
    Jun 9, 2016 at 14:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.