{"id":251,"date":"2017-03-14T01:08:33","date_gmt":"2017-03-14T01:08:33","guid":{"rendered":"https:\/\/www.acugis.com\/docs\/?p=251"},"modified":"2025-02-06T12:32:13","modified_gmt":"2025-02-06T12:32:13","slug":"add-postgis-layers-to-qgis","status":"publish","type":"post","link":"https:\/\/acugis.com\/docs\/postgis\/add-postgis-layers-to-qgis\/","title":{"rendered":"Add PostGIS Layers to QGIS"},"content":{"rendered":"<h1><span style=\"color: #800000;\">Add\u00a0PostGIS Layers to QGIS<\/span><\/h1>\n<p>To add layers from your PostGIS database(s) to your QGIS Desktop, follow below.<\/p>\n<p>1.\u00a0 Create a pg_service.conf entry for your database connection.<\/p>\n<p>For example:<\/p>\n<p>[demodb]<br \/>\nhost=mydomain.com<br \/>\nport=5432<br \/>\ndbname=mydb<br \/>\nuser=myuser<br \/>\npassword=MyPassword<\/p>\n<p>&nbsp;<\/p>\n<p>2. On the PostgreSQL icon in the left menu, right-click and select &#8220;New Connection&#8221;<\/p>\n<p><a href=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-conn.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-308 size-full\" src=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-conn.png\" alt=\"\" width=\"366\" height=\"183\" srcset=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-conn.png 366w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-conn-300x150.png 300w\" sizes=\"(max-width: 366px) 100vw, 366px\" \/><\/a><\/p>\n<p>3. Give your connection a name and enter the Service name from your pg_service.conf entry (&#8220;demodb&#8221; in our example).\u00a0 Click Test Connection to test and then click OK.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/testconn.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-309 size-full\" src=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/testconn.png\" alt=\"\" width=\"467\" height=\"751\" srcset=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/testconn.png 467w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/testconn-187x300.png 187w\" sizes=\"(max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>3. \u00a0Expand the node for the new connection you just created as shown below.<\/p>\n<p><a href=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/select-db.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-310 size-full\" src=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/select-db.png\" alt=\"\" width=\"349\" height=\"59\" srcset=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/select-db.png 349w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/select-db-300x51.png 300w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>4. Right click on the table(s) you wish to add and select &#8220;Add Layer to Project&#8221;<\/p>\n<p><a href=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-layer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-311 size-full\" src=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-layer.png\" alt=\"\" width=\"387\" height=\"223\" srcset=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-layer.png 387w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/add-layer-300x173.png 300w\" sizes=\"(max-width: 387px) 100vw, 387px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>5. Your PostGIS layer has now been added!<\/p>\n<p><a href=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/layer-added.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-312 size-large\" src=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/layer-added-1024x710.png\" alt=\"\" width=\"525\" height=\"364\" srcset=\"https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/layer-added-1024x710.png 1024w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/layer-added-300x208.png 300w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/layer-added-768x533.png 768w, https:\/\/acugis.com\/docs\/wp-content\/uploads\/2017\/03\/layer-added.png 1153w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/a><\/p>\n<p>Before publishing your layer to Lizmap, G3W-Suite, or QGIS Server, be sure there is a pg_service.conf entry corresponding to the one you created on the server.<\/p>\n<p>For example:<\/p>\n<p>[demodb]<br \/>\nhost=localhost<br \/>\nport=5432<br \/>\ndbname=mydb<br \/>\nuser=myuser<br \/>\npassword=MyPassword<\/p>\n<p>The file on the server is located at<\/p>\n<p>\/etc\/postgresql-common\/pg_service.conf<\/p>\n<p>If you have any questions or require assistance, simply raise a support ticket and we are here to assist.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add\u00a0PostGIS Layers to QGIS To add layers from your PostGIS database(s) to your QGIS Desktop, follow below. 1.\u00a0 Create a pg_service.conf entry for your database connection. For example: [demodb] host=mydomain.com port=5432 dbname=mydb user=myuser password=MyPassword &nbsp; 2. On the PostgreSQL icon in the left menu, right-click and select &#8220;New Connection&#8221; 3. Give your connection a name &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/acugis.com\/docs\/postgis\/add-postgis-layers-to-qgis\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Add PostGIS Layers to QGIS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,20],"tags":[],"class_list":["post-251","post","type-post","status-publish","format-standard","hentry","category-postgis","category-qgis"],"_links":{"self":[{"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/posts\/251"}],"collection":[{"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":3,"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"predecessor-version":[{"id":313,"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/posts\/251\/revisions\/313"}],"wp:attachment":[{"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/acugis.com\/docs\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}