Select to view content in your preferred language

Con tool in Spatial Analyst (Query Builder)

4280
6
Jump to solution
11-28-2014 06:12 PM
PatrickPineault
New Contributor

Hi everyone,

I am working on a tree crown delimitation project with lidar data. Everything is going well but at some point, it just seems I can't use the query builder in the con tool. I've used it in steps before this point so I don't know where the trouble might be....

Here are the steps thus far:

invert canopy raster (Math/Negate tool)

- tree peaks become ponds

- branches/crowns become watersheds

Smooth inverted raster (Filter)

Determine local minima

- focal flow to extract tree tops (Con tool, VALUE = “255”, if true, return Inverted raster

Remove lowest trees (< 7 meters) --> here comme the trouble, trying to use the con tool, I don't have access to the data in the Query Builder of the con tool!!

Any help would be appreciated!

Thanks!

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

did by chance you type "Value"<-7 ?   (it is really hard to read from the screen grabs)

if so, you need spaces between the fields, the operators and the values, ie

"Value" < -7    with a space between "Value" and < and -7

Also, did you click on the error messages to see what they said, to save us some time

View solution in original post

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

Show the exact Con syntax

0 Kudos
PatrickPineault
New Contributor

Here's a screenshot of the query builder in wich I don't have the info of the input conditional raster. Usually we get the the attributes of the raster in this window.

And then, if I enter the query as supposed:

I get this message:

Thanks again!

0 Kudos
DanPatterson_Retired
MVP Emeritus

did by chance you type "Value"<-7 ?   (it is really hard to read from the screen grabs)

if so, you need spaces between the fields, the operators and the values, ie

"Value" < -7    with a space between "Value" and < and -7

Also, did you click on the error messages to see what they said, to save us some time

0 Kudos
PatrickPineault
New Contributor

Hi Dan,

I juste tried it by putting spaces where you told me and it worked!

I stil don't get it why I can't build the query in the query builder by clicking on the value??

Thanks for debugging me!

0 Kudos
XanderBakker
Esri Esteemed Contributor

Just to add a little comment to the solution Dan Patterson‌ provided. There is a difference between integer and floating rasters. The integer rasters have an attribute table (so it has attribute fields and allows you to construct a condition) while the floating (decimal point) rasters do not. Hence the empty query builder screen.

Way back in the older versions of ArcGIS, one needed to add the spaces around floating rasters and the operators when composing map algebra. I think this is an example of what has not been corrected (yet).

curtvprice
MVP Esteemed Contributor

> Way back in the older versions of ArcGIS, one needed to add the spaces around floating rasters and the operators when composing map algebra

Xander, this isn't it - the deal here is we're trying to use a SQL expression. The SQL syntax requires the spaces.

I would avoid the SQL syntax issue altogether by using the Raster Calculator tool, which allows raster layers to be treated as raster objects so you can use a straight arcpy map algebra expression, for example:

Con("confocalflow" < -7, "confocalflow")

This gets converted by the Raster Calculator tool to the arcpy (python) map algebra expression:

Con(Raster("confocalflow") < -7, Raster("confocalflow"))

The spaces in the expressions above are totally optional -- but I like using them because it makes the expression easier to read.

Patrick, another advantage of using this tool is you can sometimes combine tools (especially local operators like Con) into a complex expressions that will run at lot faster than running each tool one at a time.

Also, Patrick, please consider moving this thread to the Spatial Analyst‌ space.