HOW TO

Berechnen von XY-Werten in ArcGIS Pro unter Verwendung eines Arcade-Ausdrucks

Last Published: June 20, 2023

Zusammenfassung

In ArcGIS Pro, the spatial and location information of point features can be added to the attribute table. This task can be automated using the Arcade expression. Follow the instructions provided in this article to calculate XY values of point features using an Arcade expression.

Vorgehensweise

  1. Open the ArcGIS Pro project.
  2. Add a new field to the feature class in ArcGIS Pro for the x-value.
    1. In the Contents pane, right-click the layer and click Attribute Table.
    2. In the attribute table, click Add Field The Add Field icon..
    3. In the Fields view, specify a name for the field in the Field Name column.
    4. Double-click the Alias column of the field and specify an alias for it.
    5. Double-click the Data Type column of the field and select Long from the drop-down menu.
The Field name, Alias, and Data Type field in the attribute table.
  1. On the top ribbon, on the Fields tab, click Save.
The Save option in the Changes group.
  1. Follow step 2 to add a new field to the class for the y-value.
<Null> results in the X and Y-values column.
  1. Calculate the x-value field.
    1. In the table view, right-click the x-value field header and select Calculate Field.
    2. In the Calculate Field window, select Arcade from the Expression Type drop-down.
    3. Type the following expression and click Verify.
Round(Geometry($feature).X, 6)
The x-value expression configured.
  1. When the message, “Expression is valid” is returned, click OK.
The
  1. Calculate the y-value field.
    1. In the table view, right-click the field’s header for the y-value and select Calculate Field.
    2. In the Calculate Field window, select Arcade from the Expression Type drop-down.
    3. Type the following expression and click Verify.
Round(Geometry($feature).Y, 6)
The y-value expression configured.
  1. When the message, “Expression is valid” is returned, click OK.

The image shows the attribute table with the XY values in meter.

The results of the XY values in the attribute table.

Optionally, calculate the XY values in decimal degrees.

  1. Open the ArcGIS Pro project.
  2. Add a new field to the feature class in ArcGIS Pro for the x-value.
    1. In the Contents pane, right-click the layer and click Attribute Table.
    2. In the attribute table, click Add Field The Add Field icon..
    3. In the Fields view, specify a name for the field in the Field Name column.
    4. Double-click the Alias column of the field and specify an alias for it.
    5. Double-click the Data Type column of the field and select Double from the drop-down menu.
The Field Name, Alias, and Data type in the attribute table.
  1. On the top ribbon, on the Fields tab, click Save.
The Save option in the Changes group.
  1. Follow step 2 to add a new field to the class for the y-value.
  2. Calculate the x-value field.
    1. In the table view, right-click the x-value field header and select Calculate Field.
    2. In the Calculate Field window, select Arcade from the Expression Type drop-down.
    3. Type the following expression and click Verify.
//To populate X coordinate in decimal

function MetersToLon(x) {

    var originShift = 2.0 * PI * 6378137.0 / 2.0;

    var lon = (x / originShift) * 180.0;
        
    return Round(lon, 3);
}

return MetersToLon(Round(Geometry($feature).X, 6));
The x-value expression is configured in the expression box.
  1. When the message, “Expression is valid” is returned, click OK.
  1. Calculate the y-value field.
    1. In the table view, right-click the y-value field header and select Calculate Field.
    2. In the Calculate Field window, select Arcade from the Expression Type drop-down.
    3. Type the following expression and click Verify.
//To populate Y coordinate in decimal:

function MetersToLat(y) {

    var originShift = 2.0 * PI * 6378137.0 / 2.0;

    var lat = (y / originShift) * 180.0;

    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return Round(lat,3);
}
return MetersToLat(Round(Geometry($feature).Y, 6));
The y-value expression is configured in the expression box.
  1. When the message, “Expression is valid” is returned, click OK.

The image below shows the attribute table with the calculated XY values in decimal degrees in ArcGIS Pro.

The calculated XY values in decimal degrees.

Artikel-ID: 000028012

Benachrichtigungen erhalten und Lösungen für neue oder häufige Probleme finden

Unser neuer KI-Chatbot stellt zusammengefasste Antworten und Videolösungen für Sie bereit.

Esri Support App herunterladen

Zugehörige Informationen

Weitere Informationen zu diesem Thema erkunden

Unterstützung durch ArcGIS-Experten anfordern

An den technischen Support wenden

Esri Support App herunterladen

Zu Download-Optionen wechseln