This post will demonstrate how a GIS Analyst can create layers in Arcmap from applying queries to PostGIS tables . This is a useful way of bringing in filtering datasets in a PostGIS database and loading them as layers into the ArcMap environment.
For our demonstration, we will be using a PostGIS database hosted in our QGIS Cloud account.
1. Go to the ArcCatalog and create a connection to your PostGIS database or refresh an earlier connection. In the screenshot below, you can see our connection and the tables.
2. Once a connection is established, go to File – Add Data – Add Query Layer
3. A. Click on the drop down button to select the PostGIS Connection.B) Select a Table in the database C) Give the query a name. D) Write the query expression, in this case- Select from the table district_lagos where the field- name_2 has the value – Agege. Click Next
5. The screenshot below shows the resultant query layer in ArcMap. Query layers have to be exported as
6. We can also query two tables simultaneously in the PostGIS connection and create a query layer in ArcMap. For the next expresion, we select data from tables’- ibadan_schools and southwest.. We ask to know the point locations in one table that intersect the feature with name-akinyele in another table called southwest.
7. The final result is a query layer comprising selected points with the attribute table shown in the screenshot below. Note that all the query requested the id and geometry fields from the ibadan_schools table and the name_2 field from the southwest table. All points have value=akinyele in the name_2 field.
Thank you for following the blog.