Introduction to ArcGIS Pro (Part 3): Definition Queries
Welcome back! So we are doing great and got railroads, stations and city parks shown on our map. The railroads and stations are shown with different colors based on the mode of transport. For the parks, we used a more advanced symbology, with different colors for different park size classes. Finally, we added labels to show city park names. In part 3 of this series, we will continue styling the final 2 layers of our project: Districts and Empty Buildings. In the process, we will start using definition queries. Let’s start with former, as this one will be quick and easy.
This layer only exists of 7 records, each a polygon representing a city district. Try and turn the layer on, making sure that it is on the bottom of the layer list. This means that it will get rendered last, so it won’t cover other layers. We could decide to create a symbology based on the district name. This will give us the following result:
While this provides some information, it is not particularly beautiful or useful. We are actually only interested in the central district, and will not necessarily use the Districts layer for visualization. I suggest we use a filter to only show the central district, and visualize it using a transparent fill and a thick border. This way we can see if the offices we are interested in actually lie in the central district. Let’s start by filtering the layer to only show one specific district. For this, we will use Definition Queries. These are clauses defining what information we want to show.
- Right-click the Districts layer and select Properties.
- On the menu to the left, select Definition Query.
- Press the Add Clause button.
- Now we want to select Stadsdeel for the field, is equal to, and Centrum as value. Your window should now look this:
Next, press Add to add the statement to your layer. Your query statement should now show up in the list as below.
- Your map should reflect these changes by only showing the Centrum polygon of the Districts layer. Let’s change the symbology to only show its outline. The quickest way of doing this is by clicking the colored symbol below the layer name. This will bring you directly to the Format Polygon Symbol section of the Symbology pane. Under appearance, select No color for Color, and a dark blue (I chose Lapis Lazuli) for Outline. Finally, increase the outline width up to 3 pt. Finally, hit Apply.
It’s not very pretty, but it works. You can go ahead and deselect the layer now. We will only use it during our analyses, and afterward to check our results. That was all we need to do with District. We will move on to getting our final layer setup: Empty_Buildings.
This dataset covers a list of empty buildings in Amsterdam. As we are only interested in offices we would like to do some more definition querying. Afterwards, we will display these. This process will be largely a repetition of steps we have implemented before.
Definition queries (1)
- First, let’s have a look at the attribute layer of the Empty_Buildings layer.
For those of you knowing Dutch, there are two fields related to building use. Huidige_fu with means the building’s current use, and Toekomstig, which relates to the future building use. Let’s make sure we only find buildings that can be used as offices in the near future.
- As you might have guessed, it is time to use some definition queries again. Before moving on, enable the Empty_buildings layer in the contents pane so we can see if our definition query takes effect.
- Right-click the layer in the contents pane, select Properties, select Definition Query, and finally press Add Clause.
- For Field select Toekomstig, keep is Equal to, select Kantoor (office) under Values, press Add and finally OK.
- Note that there are different values that include office as well. We could add different clauses to our definition query for each of these. I will limit myself to adding one other clause to show you how it is done, but it is a very similar process to before. Start with pressing Add Clause. In front of the field selection drop-down, you can select a logical operator (And or Or). Make sure OR is selected. This makes sure that we sure that we want to show all records which are equal to either the value in our first clause OR our second clause. Selecting and would mean that only fields get shown that have two specific value for Toekomstig. Since this is impossible (fields only have one value), no records would get shown.Continue by selecting Toekomstig for the field, keep is Equal to, select Kantoor (office) under Values and finally press Add. Your window should look like this:
One issue remains. We actually also want to set a minimum size for offices. We can do this with definition queries as well, but when we try to add a definition query for this field it will not allow setting conditions based on its numeric value (e.g. the field must be greater or equal to 100). This is once again due to the text type of the field. This means we will have to use our beloved field calculator again to convert our values to a numeric (long) value.
Let’s go through it quickly. If you have trouble remembering how exactly to do this you can refer back to part 2.
- Open the attribute table of the EMPTY_BUILDINGS layer if it is not open.
- Click the Add field button above the attribute table. Set Field Name is set to Size and make sure the Data Type is set to Long.
- On the ribbon and the Fields tab, find the Changes group and select Save.
- Back on the attribute table, right-click the Size field, and select Calculate Field. The only thing you should have to change on the Geoprocessing pane is the expression field. Make sure the text field under Size = equals !Bruto_vloe!. To finish, press run at the bottom right of the window. The Size field should now be updated with the values of the Bruto_vloe field, but now as numeric (long) type.
- Close the geoprocessing pane.
Definition Queries (2)
- Now, let’s return to the definition query window (Right click layer, Properties, Definition Query). Press Add Clause.
- This time, make sure the logical operator is set to And. This is because we want the office area always to be greater than or equal to 1000 square meters, while the Toekomstig field can be one of the two field values (but not both).
- For Field select Size.
- To the right is another dropdown. Make sure this one is set to is Greater Than or Equal To.
- Underneath values select 1000.
- Press Add. Your definition query window should look like this:
- It might look fine now, but there is an issue. The two statements using the Toekomstig field need to be grouped so that ArcGIS Pro understands that these statements are related and that the OR only related to these. The size statement is independent of these. In other words:(TOEKOMSTIG = ‘KANTOOR’ OR TOEKOMSTIG = ‘BEDRIJF – KANTOOR’)
AND (SIZE >= 1000)To group the two statements related to future office use (Toekomstig), select them both (left click both statement while holding control), and press the Group clauses (highlighted in yellow below) button. The end result should look like this:
- Press OK to confirm the changes. The map and attribute table should reflect the filtering we have done with our attribute queries. The number of point on the map should have been decreased, and the attribute table should only include records with one of the two previously mentioned field values, and with a certain minimum size.
We are nearly done with this part! Let’s quickly style this layer to make the offices more visible. By now this is hopefully nearly second nature.
It would be nice to display offices with a symbol size depending on the square meter value of the office.
- Open the Symbology pane.
- Under symbology, select Graduated Symbols.
- For field, select Size.
- Next to symbol, click the circle.
- Find the style button, and click it. This allows you to choose the shape of the points on the map.
- Pick a shape from the list. I chose Diamond 3.
- Pick a color you like. I chose Electron Gold.
- Leave everything else at it is. Hit Apply.
- Click on the back arrow in the top left corner. The symbols should show up on your map. I find them a little difficult to see. Increase the minimum size to 15 and the maximum size to 30. And we are done!
That’s it. All our layers are visualized. You could skip to part 5 where we will run some analyses. In the next part, we are going to learn how to edit, create, and delete new features for our layers. Skills that you will need very regularly as GIS analyst.