Select to view content in your preferred language

Error creating SQL label expression for Shape.STArea() >300000 in ArcGIS Pro

1200
6
04-28-2022 03:22 PM
DavidAlfordLPAO
Emerging Contributor

I am trying to recreate a SQL expression in ArcGIS Pro that I have in ArcMap. It is a label expression that was in ArcMap to label the parcel # for parcels with Shape_Area > 300000 in my FGDB. I have migrated my FGDB to SQL and are trying to write the same expression. In SQL the Shape_Area field is now Shape.STArea() will not work with the expression Shape.STArea() >300000.  I can recreate that expression in ArcMap connected to SQL, but not Pro. I am on Pro 2.9.2 and ArcMap 10.9.1

6 Replies
JohannesLindner
MVP Alum

There are 2 ways to do this.

 

You can have the condition in the Arcade expression:

if($feature.Shape_Area > 300000) {
    return $feature.OBJECTID
}

// if $feature.Shape_Area doesn't work, you can also try Area($feature)

 

Or you can have the condition as SQL statement, making the expression very simple:

return $feature.OBJECTID

JohannesLindner_1-1651223900427.png

 


Have a great day!
Johannes
0 Kudos
alex_friant
Frequent Contributor

Did you ever figure out a solution, @DavidAlfordLPAO?

I'm in ArcGIS Pro 3.2.2 and I'm getting the same error message/alert in Notifications.

What's perplexing is that the query is confirmed as "valid" by the label tool, but when you apply it to the label class the error message appears. It has something to do with the "()" I believe, but if it did then why does the validation check say it's okay? So strange.

Also, this exact same expression works perfectly well in the Definition Query and as a regular "Select By Attributes" query. This must be a bug in the labelling stack. I'll call Esri Support and see what I can learn.

NickMcNamara
Occasional Contributor

I'm running into a similar problem, but in model builder, running a query. It was fine in Oracle, but after moving to SQL Server and changing the field names, it just doesn't like them. I'm not sure how to change the query to make it work.

0 Kudos
alex_friant
Frequent Contributor

It might be related to this known bug in Pro 3.2. The issue is fixed in Pro 3.3.

BUG-000164308 

0 Kudos
NickMcNamara
Occasional Contributor

I deleted the query and used the picker to recreate it instead of typing it in. It was exactly the same (I checked them in notepad). But now it works OK. /shrug

0 Kudos
alex_friant
Frequent Contributor

Isn't that how it always works LOL. Glad it's working now.

0 Kudos