- ArcGIS Pro 2.x Cookbook
- Tripp Corbin GISP
- 1232字
- 2021-06-24 19:10:52
How to do it...
- If you closed ArcGIS Pro after completing the previous recipe, open the Joining Data.aprx project by following the same instructions as shown in the beginning of the previous recipe.
- Click on Bookmarks on the Map tab in the ribbon. Select the Labeling bookmark. This will zoom you in to an area located in the center of the City.
- Select the Parcels layer in the Contents pane so that the Feature Layer Contextual menu appears with three new tabs.
- Click on the Labeling tab in the ribbon.

- Click on the Label button located in the Layer group on the Labeling tab. It should be the located on the far-left side of the ribbon.
Text will appear in the map showing the PIN for each parcel. The values being displayed are being pulled from the Attribute Table for the Parcels layer. If you look in the Label Class group on the Labeling tab, you will see a setting for Field. It is set to Parcels.PIN. This means that the values being displayed are those found in the PIN field from the original Parcels table. You will now build an expression using the Arcade language, which will label each parcel with its PIN from the Parcels table and with its owner from the joined Owners table.
- Click on the Expression button located to the right of the Field cell in the Label Class group. The Label Class pane should appear on the right of the interface. This is where you will build your labeling expression:

- Click in form of $feature[‘Parcels.Pin’], the expression area in the Label Class pane. Type “PIN: “+ in the expression area, as shown ahead:

- Click on the Validate button located at the bottom of the expression area. It looks like a green check mark. If it says Expression is valid, continue. If it does not, double check your expression against the previous graphic to make sure you typed in the correct syntax.
- In the expression area, add the following to the end of the expression you have already created: +Textformatting.Newline+"Owner: ".
- In the Fields window in the Labeling Class pane, scroll down until you see Owners.LASTNAME. Double click on Owners.LASTNAME to add it to the expression.
Your full labeling expression should now say:
"PIN: "+$feature['Parcels.PIN']+Textformatting.Newline+"Owner: "+$feature['Owners.LASTNAME']
- Click on the Validate button once again to verify your syntax. If it says, Your expression is valid, click Apply. If it does not, verify your expression. If you continue to have issues, read the following tip:
If you are having issues creating the expression, you can load one that has already been created. Just click on the Import button located next to the validate button and navigate to C:\Student\ArcGISProCookbook\Chapter3\Joining Data. Select the PIN_Owner_Label_Expression.lxp. Then click OK to import the expression.
- Save your project.
You have just labeled each parcel using the PIN field found in the original Parcels Attribute Table and the LastName field from the Owners table. You also added descriptive text to the label to make it easier to know what the labels were. Now you will clean up your labels so they are easier to read.
ArcGIS Pro supports several languages for writing labeling expressions. In addition to Arcade, you can write expressions using Python, VBScript, and Jscript. Labeling expressions written for ArcMap and saved to expression files (.exp) are not compatible with ArcGIS Pro.
- Click on the Position tab in the Label Class pane, as shown in the following screenshot:

- Click on the Position button in the Position tab in the Label Class pane.
- If required, expand the Placement option and select Land Parcel placement from the drop-down menu.
- Locate where it says Horizontal in polygon and click on the drop-down arrow. Select Straight in polygon.
- Click on the Fitting Strategy button located at the top of the Labeling Class pane. It looks like a Knight chess piece.
- Expand Reduce size by clicking on the small arrowhead.
- Click on the box next to Reduce font size to enable this function.
- Set the following parameters:
- Font size reduction:
- Lower limit: 4.0
- Step interval: 1.0
- Font width compression:
- Lower limit: 60
- Step interval: 5.0
- Font size reduction:
The Label Class pane should now look like the following screenshot:

- Click on the Labeling tab in the ribbon.
- In the Visibility Range group, click on the drop-down arrow for Out Beyond and select <Current>. This will mean that the labels you just configured will only appear when you zoom in to the current scale of your map. If you zoom out to show a larger area, the labels will not be displayed.

- Save your project.
In this recipe, you labeled the parcels in the map with values from the PIN field in the Parcels Attribute Table and the LASTNAME field in the Owners table which you had joined to the parcels in the last recipe. You did this using Esri’s new Arcade expression language.
In the first part of your expression, you added descriptive text which allowed users to know what the labeled values were. You did this in Arcade by using double quotes. This tells ArcGIS Pro to simply display the text values found inside the double quotes. For example, your expression contained “PIN: “. This produced a label which showed up in the map a PIN: .
This was then followed up with a reference to a database field. In Arcade, you did this using the + to indicate another part of the expression, followed by $feature[‘Parcels.PIN]. This displays the value found in the PIN field within the Parcels Attribute Table. The + sign must be used between each part of the expression. You then displayed the owner name on another line in the label using Textformatting.Newline in your expression. Once you set the owner name to be displayed on a separate line, you add more descriptive text by including “Owner: “ in your expression. Lastly, you displayed the owners name by calling to the LASTNAME field in the joined Owners table by including $feature[‘Owners.LASTNAME’] at the end of your expression. This produced a label for each parcel that looked like this in the map:
- PIN: T22 028
- Owner: Unknown
You then adjusted several configuration settings for the labels in the Label Class pane to make the labels fit in the parcels better and to be easier to read. You did this by setting the placement option to Land parcel placement. This automatically applies some settings that are preconfigured in ArcGIS Pro for placing text within a parcel. This cleaned up several of the overlapping labels, but left many parcels without a label.
So, next you set the positioning to be Straight in a polygon as opposed to the default Horizontal in a polygon. This allows ArcGIS Pro to fit labels diagonally within the polygon if needed, first adjusting the size of the font. This allowed ArcGIS Pro to label a few more parcels, but still not all of them.
Next, you moved over to the Fitting Strategy to adjust the font size for your labels. You enabled Reduce font size. This allowed ArcGIS Pro to automatically resize the font within the parameters you designated to help fit the label within the parcels. By making this adjustment you were able to get all the parcels in the view labeled.
- Unity 2020 By Example
- Learning Java Functional Programming
- Arduino by Example
- Learning ELK Stack
- Java EE 7 Performance Tuning and Optimization
- Scientific Computing with Scala
- 從零開始學C語言
- 第一行代碼 C語言(視頻講解版)
- Flask Web開發:基于Python的Web應用開發實戰(第2版)
- Photoshop CC移動UI設計案例教程(全彩慕課版·第2版)
- 超簡單:用Python讓Excel飛起來(實戰150例)
- Advanced Python Programming
- 大規模語言模型開發基礎與實踐
- Mastering PowerCLI
- Processing開發實戰