Hi - I'm just trying to work round this error in my script....
"To test if a Raster has all NoData run the IsNull tool. If the output is all 1 then it only has NoData"
How do you test whether the whole raster is 1?
Here is an example of getting the % of nulls in a raster.
# calculate % no data cells in a raster. import sys, os, arcpy from arcpy import env from arcpy.sa import * if arcpy.CheckExtension("Spatial"): arcpy.CheckOutExtension("Spatial") else: print "No SA licence" exit HomeDir = "c:/Data/Swala/BurkinaFaso/IPSurvey/" fgdb = "IPRasterData.gdb" InData = os.path.join(HomeDir, fgdb) env.workspace = InData env.overwriteOutput = True ListRast = arcpy.ListRasters() # ListTable = arcpy.ListTables() for r in ListRast: print "Processing", r Ras = arcpy.Raster(r) NullRas = IsNull(Ras) NCol = NullRas.width NRow = NullRas.height NCell = NCol * NRow Mean = NullRas.mean NNull = Mean * NCell print "{} % Null {}".format(r, NNull / NCell * 100)
or
look at the GetRasterProperties gp tool
-Steve
Although Neil's snippet allows for determining the percentage of NoData in a raster, Steve provides a solution that does exactly what you are looking for and does not require Spatial Analyst. To show a little what you can do with it, here's a litte sample:
import arcpy ras = r"D:\Xander\LineasTransmision\Modelo\fgdb\RastersModelo.gdb\cmp_totexl02a" props = ['MINIMUM', 'MAXIMUM', 'MEAN', 'STD', 'ALLNODATA', 'ANYNODATA', 'UNIQUEVALUECOUNT'] for prop in props: try: print "{0}: {1}".format(prop, arcpy.GetRasterProperties_management(ras, prop)) except Exception as e: print "{0}: {1}".format(prop, e)
Returns:
# MINIMUM: 22 # MAXIMUM: 396 # MEAN: 97,7094252332071 # STD: 51,5918279932734 # ALLNODATA: 0 # ANYNODATA: 1 # UNIQUEVALUECOUNT: 327
So you will just have to test for the property "ALLNODATA" and when the result is '1', skip that raster.
Kind regards, Xander
Useful script!
Is it possible however that a raster has the ALLNODATA = 1 but looks visually ok, has a nodata value defined and the statistics are ALSO provided from the Get Raster Properties parameters: MEAN, MAXIMUM, MINIMUM, STANDARD DEVIATION ??
I am trying to understand why this happens to be able to convert to points afterwards...
Any suggestions for a workaround?
Thanks
Not sure if I understand... You have a raster that returns ALLNODATA = 1 (so all pixels are NoData values) but does have values (hence the valid stats for MEAN, MAXIMUM, MINIMUM, STANDARD DEVIATION)? If that happens it should be a bug. Is it possible to share the raster? Did you contact support?
Yes, you understood correctly.
Strange as it comes from masking a source raster (like spliting it). The source raster also shows allnodata = 1, but looks ok, stats ok, values ok, nodata defined ok.
The split rasters some show the allnodata 1 and some allnodata =0. All of them looking ok, stats ok, nodata defined ok.
Sure. I can share. How do we exchange the file?
I only wrote here, as I saw the issue of the allnodata thread.
Thank you! Really surprised with this artifact.
Can't figure out what it is.
Enviado desde Yahoo Mail con Android
El jue., jul. 26, 2018 a 18:38, Xander Bakker<geonet@esri.com> escribió:
#yiv9856133252 * #yiv9856133252 a #yiv9856133252 body {font-family:Helvetica, Arial, sans-serif;}#yiv9856133252 #yiv9856133252 h1, #yiv9856133252 h2, #yiv9856133252 h3, #yiv9856133252 h4, #yiv9856133252 h5, #yiv9856133252 h6, #yiv9856133252 p, #yiv9856133252 hr {}#yiv9856133252 .yiv9856133252button td {}
|
GeoNet
Re: Raster to Polygon fails with empty input
reply from Xander Bakker in Spatial Analyst - View the full discussion
Reply to this message by replying to this email, or go to the message on GeoNet
Start a new discussion in Spatial Analyst by email or at GeoNet
Following Re: Raster to Polygon fails with empty input in these streams: Inbox
This email was sent by GeoNet because you are a registered user.
You may unsubscribe instantly from GeoNet, or adjust email frequency in your email preferences
When you reply to this thread you can use the advanced editor using the link in the upper right part of your reply:
In the advanced editor you will find in the lower left corner a link that enables you to attach your data (if it is smaller than 50MB):
It would be best to use the format you are using, since converting to another format might have a different result when we run the code on it.
Hi again,
I contacted the ESRI support.
Meanwhile, how can I share the tif file with you?
I share some screenshots and echo lines:
PRIOR TO EXTRACT BY MASK (SOURCE RASTER)
Get raster properties shows:
MINIMUM: -107dem_EU8.tifMAXIMUM: 5112dem_EU8.tifMEAN: 701.50966808932dem_EU8.tifSTD: 613.36991449625dem_EU8.tifALLNODATA: 1dem_EU8.tifANYNODATA: 0dem_EU8.tifUNIQUEVALUECOUNT: 5209dem_EU8.tif
AFTER PROCESSING, EXAMINING WITH GET RASTER PROPERTIES:
MINIMUM: 0slope_cr.tifMAXIMUM: 81.714889526367slope_cr.tifMEAN: 7.7882586697231slope_cr.tifSTD: 7.6317294646923slope_cr.tifALLNODATA: 1slope_cr.tifANYNODATA: 0slope_cr.tifUNIQUEVALUECOUNT: ERROR 000864: Property type: The input is not within the defined domain.
MINIMUM: 0slope_fr.tifMAXIMUM: 87.347358703613slope_fr.tifMEAN: 6.697570111711slope_fr.tifSTD: 8.029112308876slope_fr.tifALLNODATA: 1slope_fr.tifANYNODATA: 0slope_fr.tifUNIQUEVALUECOUNT: ERROR 000864: Property type: The input is not within the defined domain.
MINIMUM: 0slope_gr.tifMAXIMUM: 86.183372497559slope_gr.tifMEAN: 13.185961209459slope_gr.tifSTD: 10.142107658809slope_gr.tifALLNODATA: 1slope_gr.tifANYNODATA: 0slope_gr.tifUNIQUEVALUECOUNT: ERROR 000864: Property type: The input is not within the defined domain.
MINIMUM: 0slope_it.tifMAXIMUM: 88.314254760742slope_it.tifMEAN: 12.155243931512slope_it.tifSTD: 11.308642649386slope_it.tifALLNODATA: 1slope_it.tifANYNODATA: 0slope_it.tifUNIQUEVALUECOUNT: ERROR 000864: Property type: The input is not within the defined domain.
MINIMUM: 0slope_pt.tifMAXIMUM: 86.680160522461slope_pt.tifMEAN: 7.9297302374002slope_pt.tifSTD: 6.9735340036504slope_pt.tifALLNODATA: 1slope_pt.tifANYNODATA: 0slope_pt.tifUNIQUEVALUECOUNT: ERROR 000864: Property type: The input is not within the defined domain.ERROR 000800: The value is not a member of MAXIMUM | MINIMUM | MEAN | STD | TOP | LEFT | RIGHT | BOTTOM | CELLSIZEX | CELLSIZEY | VALUETYPE | COLUMNCOUNT | ROWCOUNT | BANDCOUNT | ALLNODATA | ANYNODATA | SENSORNAME | PRODUCTNAME | ACQUISITIONDATE | SOURCETYPE | CLOUDCOVER | SUNAZIMUTH | SUNELEVATION | SENSORAZIMUTH | SENSORELEVATION | OFFNADIR | WAVELENGTH.slope_pt.tif baaadMINIMUM: 0slope_sl.tifMAXIMUM: 83.555519104004slope_sl.tifMEAN: 13.833553877048slope_sl.tifSTD: 10.842502128808slope_sl.tifALLNODATA: 0slope_sl.tifANYNODATA: 1slope_sl.tifUNIQUEVALUECOUNT: ERROR 000864: Property type: The input is not within the defined domain.
Any insight?
Thank you
Eva
El jue., jul. 26, 2018 a 22:00, Xander Bakker<geonet@esri.com> escribió:
https://community.esri.com/servlet/JiveServlet/downloadImage/2-787828-415222/300-156/pastedImage_1.png
https://community.esri.com/servlet/JiveServlet/downloadImage/2-787828-415259/360-154/pastedImage_1.png
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.