Select to view content in your preferred language

Extract By Attributes failing - question about correct SQL input for raster data

5723
8
Jump to solution
10-05-2015 02:19 PM
KaraJacobacci
Deactivated User

I'm trying to extract only a certain value from a raster and display that as a new layer - I'm working with an Aspect raster derived from a DEM and want to select only Southwest (Class Value = 6) facing cells for display in a new layer.

I'm using the Extract by Attributes tool under the Spatial Analyst set.

Input raster is my aspect raster, for the SQL builder I was trying the following

"CLASS VALUE" = '6' (class value is a field that comes up when using the Identify tool on the layer).

It won't complete the process and gives me error 999999 [error executing function]

The Table was not Found

A column was specified that does not exist

Cannot acquire a lock

No Spatial reference exists,
Error 010213

Error 010325

Error 010067

Any idea why it won't complete/what steps I need to take to provide whatever information is missing? I have used the SQL builder a lot for vector data but not on raster data without an attribute table.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

Ahhhh it isn't reclassed...as I had assumed...which is what you have to do.  the quickest is to use reclassification and reclass everything < 202.5 to 0 and > 247 to 0 and between to 1, or you could query using 'Aspect_dem14' > 202.5 and 'Aspect_dem14' <247.5   of course not typing and I am pretty sure it is 'and' if it is there or perhaps & but think that may be bit-wise and.  Sorry I can't check...on an Arc-less iThingy​

View solution in original post

8 Replies
DanPatterson_Retired
MVP Emeritus

did you type any of that expression?

I would check the query in the Raster calculator first

I you are using the raster calculator, select the field, equality sign and value from what is provided ...typing is not preferred

Sadly, there still exists a misnomer in equality checks that aren't standard.  In some places = is used, in others ==.  the latter is prefered, since = mean 'assignment' in most languages (of consequence)

If you are coding, check Specifying a query in Python—Help | ArcGIS for Desktop

0 Kudos
KaraJacobacci
Deactivated User

Thanks for the reply!


I did type the expression out (I'm aware of the pitfalls with typing instead of selecting from the lists... grrr) and I was wondering if that was the problem.

I don't fully understand the raster calculator - i can select the raster of consequence (aspect_dem14) but I do not understand what to choose from the right side column. Within the raster, there's a field called Class Value but I don't see where to select it. I've never used this tool before

0 Kudos
DanPatterson_Retired
MVP Emeritus

screen shot of the raster table?  what type of raster?  esri integer grid perhaps?  ​

If it is an integer grid as described, then you should just be able to query the raster like

'myraster' == 6

since integer grids will contain a Value field and a Count field

0 Kudos
KaraJacobacci
Deactivated User

raster_aspect.png
here's a screenshot. it's the 32 bit floating point type.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Ahhhh it isn't reclassed...as I had assumed...which is what you have to do.  the quickest is to use reclassification and reclass everything < 202.5 to 0 and > 247 to 0 and between to 1, or you could query using 'Aspect_dem14' > 202.5 and 'Aspect_dem14' <247.5   of course not typing and I am pretty sure it is 'and' if it is there or perhaps & but think that may be bit-wise and.  Sorry I can't check...on an Arc-less iThingy​

KaraJacobacci
Deactivated User

The reclassification I think has solved my problem!! I was doing something similar to what you typed out in the Raster Calculator but I keep getting a syntax error. I think I'll stick with the reclassification!

Thanks a bunch!!

0 Kudos
curtvprice
MVP Esteemed Contributor
I don't fully understand the raster calculator - i can select the raster of consequence (aspect_dem14) but I do not understand what to choose from the right side column.

This is totally a job for Raster Calculator and the Con tool:

Con("Aspect_dem14" > 202.5 & "Aspect_dem14" < 247.5, 1, 0)


If you want to use SQL syntax you can but for continuous data I don't recommend it. (I find doing the straight Python a lot more flexible and easier to understand.)

Con("Aspect_dem14", 1, 0, "VALUE > 202.5 AND VALUE < 247.5")

KaraJacobacci
Deactivated User

Thanks for the reply - I will be giving this a try too!

0 Kudos