1

I have a raster dataset ("RDS_NFlows_3035") with several bands that I would like to reclassify to a single value and save in another raster dataset ("RDS_NFlows_reclass_3035"). When I run the script I get in the main workspace (daycentGDB) and not in the output raster dataset only one raster, called Reclass_RDS_1, correctly reclassified and I get also following error:

RuntimeError: ERROR 000732: Input Raster: Dataset E:\projects\INMAP\ArcGISProject\DAYCENT\DAYCENT.gdb\RDS_NFlows_3035\Reclass_RDS_1 does not exist or is not supported

I have no rasters in my input raster dataset with that name (Reclass_RDS_1), since this is the default name given to the output by the processing tool and I can't understand why the script looks for such a raster and why it saves it outside the output raster dataset.

NFlows_in_rds = os.path.join(daycentGDB, "RDS_NFlows_3035")
NFlows_out_rds = os.path.join(daycentGDB, "RDS_NFlows_reclass_3035")
arcpy.env.workspace = NFlows_in_rds
nflow_rs  = arcpy.ListRasters()
outRsSuff = "_reclass"
for rs in nflow_rs:
    print("Working on {}".format(rs))
    inRaster = Raster(rs)
    minVal = arcpy.GetRasterProperties_management(inRaster, "MINIMUM")
    maxVal = arcpy.GetRasterProperties_management(inRaster, "MAXIMUM")
    print("min: {}, max: {}".format(minVal, maxVal))
    remap = RemapRange([[minVal, maxVal, 999]])
    outRsName = "{}{}".format(rs, outRsSuff)
    print(outRsName)
    outRs = Reclassify(inRaster, "VALUE", remap)
    outRs.save(os.path.join(NFlows_out_rds, outRsName))

This is the structure of my GDB:

DAYCENT.gdb (File geoDB)  
    RDS_NFlows_3035 (Raster dataset)  
        mineralFertilization (Band 1 of raster dataset)  
        organicFertilization (Band 2 of raster dataset)  
        N2O (Band 3 of raster dataset)  
        N2 (Band 4 of raster dataset)  

What I expect from script is a GDB like this:

DAYCENT.gdb
    RDS_NFlows_3035
        mineralFertilization
        organicFertilization
        N2O
        N2
    RDS_NFlows_reclass_3035
        mineralFertilization_reclass
        organicFertilization_reclass
        N2O_reclass
        N2_reclass      
    

But after the script returns error, the GDB structure is:

DAYCENT.gdb
    RDS_NFlows_3035
        mineralFertilization
        organicFertilization
        N2O
        N2
    Reclass_RDS_1
        Band_1  

1 Answer 1

0

I think the issue is with your understanding of what a Raster Dataset is? I assume you have already created a Raster Dataset using the Create Raster dataset tool?

Read the first line of the usage section and it says:

When you create a raster dataset, you are creating an empty location to contain a single raster dataset. You can then mosaic or load raster datasets into this location.

The key word here is LOAD. Your code is not loading into an empty existing Raster Dataset you are saving a Raster Dataset which is the output of a reclassification.

I think the confusion is coming from ESRI calling an empty raster a raster dataset and it appears you are trying to replicate the functionality of a Feature dataset which is a kind of folder in a Geodatabase.

I would simply create the raster from the reclass and then save it to:

E:\projects\INMAP\ArcGISProject\DAYCENT\DAYCENT.gdb\myNewRaster
4
  • The error is before I save or load the raster in raster dataset. The error is here remap = RemapRange([[minVal, maxVal, 999]]) This line creates a RDS with 1 band (called Band_1 with correct value 999) in this path "E:\projects\INMAP\ArcGISProject\DAYCENT\DAYCENT.gdb\Reclass_RDS_1". But 'Reclass_RDS_1' is the processing tool default name. It seems that the script creates this default RDS, does not assign the outRsName I set and does not iterate through bands in the input RDS after first cycle. I think that I didn't write correctly the iteration Commented Jun 25, 2021 at 14:35
  • Can you share your raster dataset ("RDS_NFlows_3035") with the several bands? It's difficult to identify the problem if we can't replicate it.
    – Hornbydd
    Commented Jun 25, 2021 at 14:42
  • Sorry I can't since data are confidential for the moment. I've edited my question Commented Jun 25, 2021 at 15:14
  • I'm not sure how you load your rasters into an existing blank raster dataset (never done that) but may I suggest an alternative workflow, reclassify your individuals bands into separate rasters (think of 1 TIFF file for each band) then reconstruct your multi-band raster (now with the reclassified values) using the Composite Bands tool rather than trying to insert each band on each iteration of your loop?
    – Hornbydd
    Commented Jun 25, 2021 at 16:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.