1

I have a bunch old DOQQs from the 90's that are projected in NAD27, giving them the black angled collar you see in the image. I am trying to set the collar to null by running SetNull on Value = 0. If I run the Set Null tool from the SA toolbox it turns out perfectly. If I run SetNull in the python window however, it changes the symbology from stretched to unique values, requiring me to manually change it back on every DOQQ. Is there a way to keep the symbology set to stretched in the save output, or to change it back in Python?

from arcpy.sa import *
arcpy.env.workspace = r'F:\DOQQ1991\Tiles'
rastiles = arcpy.ListRasters()
for tile in rastiles:
    nullras = SetNull(tile, tile, "VALUE = 0")
    nullras.save("{0}\{1}".format(r'F:\DOQQ1991\NullTiles', tile))

Results

3
  • 1
    From memory DOQQ are an integer data type which is why the change to classified.. try Set Raster Properties resources.arcgis.com/en/help/main/10.2/index.html#//… to enforce nodata = 0 instead of SetNull, you can also reinforce the data_type = 'GENERIC' just to be sure. Note this tool works on the input image and doesn't create a new one so will be much faster, please ensure you have a backup of your originals before proceeding just in case the Set Raster Properties ruins the raster. Commented Feb 25, 2019 at 23:16
  • You were right about the integer type. Converting the SetNull output to float will force it to revert back to a stretched symbology (and will even retain it after converting back to Int). So thank you for that workaround. The properties tool isn't effective in this case as I need the values to actually change to NoData. Still wondering why they would make it so running it through python causes the symbology change when the tool does not. I suppose I could just script it as arcpy.gp.SetNull_sa, but I feel like there should be another way to preserve the stretched setting.
    – Luke
    Commented Feb 27, 2019 at 17:38
  • Luke, if you found the solution to your question (as pointed ou by Michael) you can add your own answer. See gis.stackexchange.com/help/self-answer. Tks. Commented Apr 2, 2019 at 13:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.