arcpy and Combineraster (arcpy.gp.Combine_sa)

237
4
11-18-2021 12:32 PM
AndersMark
New Contributor II

I got a strange problem that occur when I combine rasters in my pythoncode. 

Say I have rasters "NMD_COMBINE", "DosAreaRaster_r" and the result ends up in "rasterOut".

Call in code: arcpy.gp.Combine_sa(["NMD_COMBINE", "DosAreaRaster_r"], "combineRaster")

Actually all these rasters are "in_memory" so the actual path for all of them are :

  • "in_memory\\NMD_COMBINE"
  • "in_memory\\DosAreaRaster_r"
  • "in_memory\\combineRaster"

The call to combine is fine but the result is a little strange regarding the given column names in the "combineRaster". 

The first 3 column are standard: "OID", "Value", "Count". The other 2 for the combined rasters are:

  • "NMD_COMBIN"
  • "gptmpraste"

Look at the columns above! The first one has almost a correct name but are truncated to 10 characters. The second has a completely different name compared to the source but is also 10 chars long. Doesn't it look like it's also truncated and that an "r" is missing? 

Question: Why does this happen?

Normally this Pythoncode is embedded in FME-script but is now extracted and run i Arcmap 10.3 Python window. 

If I run the exact same thing in ArcMap 10.7 the column names are correct in the combineRaster. Though I don't think it is the versions that make the difference in this case but what is? Something wrong with the installation? Environment variables?

 

 

 

 

 

Tags (1)
0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

esri raster fields are truncated at 10 chars.  this has always been the case.  you could try a different raster output, like the recommended *.tif format


... sort of retired...
0 Kudos
AndersMark
New Contributor II

Thanks but as I wrote, this is not true all the time. When I run the exact same code in ArcMap 10.7 the columns are created correctly. 

2021-11-18_21-54-35.png

0 Kudos
DanPatterson
MVP Esteemed Contributor

Probably been fixed post 10.3 (which is retired Esri Support ArcMap 10.8 (10.8.1) )


... sort of retired...
0 Kudos
AndersMark
New Contributor II

Maybe you're right about that. The one thing thats suggest something else is that when I run this code embedded in FME-script on FME-server with ArcGIS 10.3 installed i got no problem. 

I have specified column names in a json-structure. I use this json specification both when I read the combineRaster and when I write outcome vat-table. It work perfectly. 

{'tblColsVat': {
'Value' : 'LONG',
'Count' : 'DOUBLE',
'NMD_COMBINE' : 'LONG',
'DosAreaRaster_r' : 'LONG'
}
}

Python:

>>> vatTable
'Combine_DOSOBJEKT_r_VAT'

>>> vatColumns
['Count', 'DosAreaRaster_r', 'NMD_COMBINE', 'Value']

 

A verification of vat-table in ArcMap:

2021-11-18_22-29-53.png

 

Question: If the names where truncated in the "in_memory\\combineRaster", how can I then access them with my json specification of fields? I.e. full length column names. 

 

 

0 Kudos