Select to view content in your preferred language

ExtractByAttributes() breaks in PYT, even when copied from GP Pane?

215
3
Jump to solution
07-17-2025 11:56 AM
AlfredBaldenweck
MVP Regular Contributor

I'm trying to use ExtractByAttributes() in a PYT.

I couldn't get it to work, so I tried the GP Pane. That worked fine. So, I copy-pasted the command from GP Pane into my PYT and it still failed.

Code:

with arcpy.EnvManager(scratchWorkspace=r"\\...\Default.gdb"):
    out_raster = arcpy.sa.ExtractByAttributes(
        in_raster=r"\\...\Default.gdb\SurfaceDEMClip_A",
        where_clause="VALUE <= 2007.11"
    )

 

Errors:

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.ERROR 000864: Input raster: The input is not within the defined domain.ERROR 000969: The input raster is not integer type.ERROR 000864: Field: The input is not within the defined domain.ERROR 000889: Invalid field type.
Failed to execute (RasterToPolygon).


Does anyone know what's going on or how to fix it? (Or an alternative?)

0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Regular Contributor

Update: It looks like the issue is when it's inside a SearchCursor.

Bizarre.

I'll write up a support ticket and update this when I have more information.

EDIT: Actually I was just looking at the wrong lines.

Sorry everyone.

View solution in original post

0 Kudos
3 Replies
AlfredBaldenweck
MVP Regular Contributor

Update: It looks like the issue is when it's inside a SearchCursor.

Bizarre.

I'll write up a support ticket and update this when I have more information.

EDIT: Actually I was just looking at the wrong lines.

Sorry everyone.

0 Kudos
HaydenWelch
MVP Regular Contributor

Did your issue have something to do with how the code was copied from the GP Pane?

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Alas, it really was I just can't read. The issue was from a few lines down where I was trying to convert a float raster to polygon and I guess I didn't notice that my line numbers didn't match. And if I had been reading carefully, I would have noticed that it even said "Raster to Polygon" in that error message I shared.

Embarrassing lol.

This project is super annoying-- I just want a polygon from the raster, but the values are close enough that doing INT() on it gets me all the same values, and if I try multiplying to remove the significant digits, I can't get calculate statistics to work on the output, so Extract() fails. Huge mess. 

I ended up giving up and just stopping at the Extract() step because the polygons required human checking anyway.