Select to view content in your preferred language

quarry attributes table and rasters

1024
2
05-23-2012 03:09 PM
NickDavies
Emerging Contributor
Hi everyone,
I have a made a code that takes user inputs of height categories and classifies calculated heights from .las data into them.
I have two questions:
How can I quarry a raster for cells with nodata or a less than zero value. I dont want to know the location or the number of them, just a simple output of yes there is one or more or no there is not any. It is so that a warning can be printed to tell the user that the script has set these cells to value zero.

The next question is how can I quarry an attributes table, I have a generated field that takes the value of the user height categories, eg low, med, or high. If the user specifies the upper limit of high to be say 10m and there is a 20m object the code fills the field as 'out of range' I would like to quarry the field to find out if there are one or more 'out of range' cells. Again only a yes there is one or more 'out of range' cells, or no there are no 'out of range' cells. This is to warn the user that they have height categories which don't include all of the data.

My system is 9.3.1

Thanks for any help
Tags (2)
0 Kudos
2 Replies
FabianBlau
Deactivated User
I know no easy way.
You could use isNull and LessThan from SpatialAnalystToolbox (Math/Logical).
Results are to new rasters. Combine them with Boolean Or.
(RasterCalculator (ArcGIS10):
IsNull("Block_1_0")  |  "Block_1_0" < 0)
)
Now use ZonalStatisticsAsTable with the result and SUM.
(ZonalStatisticsAsTable needs a Zonalraster or Polygon Create Constant Raster with extent from your Raster in Environmentsettings should do.)
Result is a new table.
Use a cursor for getting the table-values and check if SUM>0.

The second problem: Use ZonalStatisticsAsTable with MAXIMUM.
Use a cursor for getting the table-values and check if MAXIMUM>10.
0 Kudos
NickDavies
Emerging Contributor
Thanks for that,
For future reference here one of the code blocks
try:
     gp.IsNull_sa(inRaster, isnull_raster)
    
    gp.ZonalStatisticsAsTable_sa(isnull_raster, "Value", isnull_raster, zonal_nodata_output)

    rows = gp.searchcursor(zonal_nodata_output,"VALUE>0","","SUM")
    rows = rows.next()
    rows = rows.getvalue("SUM")

    if rows >=1:
        print "error nodata cells exist"

except:
    # If an error occurred while running a tool, then print the messages.
    print gp.GetMessages()
0 Kudos