I've encountered a very strange problem involving a geoprocessing tool in ArcPy that I have spent too much time trying to solve on my own.
Specifically, I have a process that iterates through a list of folders with images, adds those images to an existing mosaic dataset (in a file geodatabase), and then updates metadata for the added raster within the mosaic dataset attribute table, based on metadata stored in an associated JSON file.
Earlier in this workflow, a previously-run tool generates folder names (based on an image name obtained from the JSON file), and if the process finds a folder name will be duplicated, the folder name is appended with a numerical suffix (i.e. '..\20200509_135639_1010', '..\20200509_135639_1010_01' ).
All raster files are added to the mosaic dataset w/o issue. However, when I try to update the metadata associated with each rasterin the mosaic dataset attribute table (again based on values stored in an associated JSON file) the problem occurs.
I attempt to create a temporary Table View for one raster record, based on a query in which I select the newly-added raster based on the image's "product name" in the mosaic dataset attribute table. This works for the first image in a list, but NOT for the subsequent images which have the appended suffix (i.e. "_01", "_02", etc.)
No matter how I change the values associated with the suffix ("01" or "_1", etc.) the arcpy.MakeTableView_management always return an empty result object on all subsequent "suffixed" raster names.
Here is the offending code snippet that returns an empty result on the "suffixed" raster names:
Example variable values
srcMosaic = '\\\\SERVER_NAME\\DIR\\SUBDIR\\SourceMosaics.gdb\\PlanetScope'
whereClause = "ProductName = '20200509_135639_1020_01'
def updateMetadataFromUser(srcMosaic, whereClause, collectionName, collectionType, imageType, source, sensor, year, startDate, endDate, resolution_meters, loadedBy): metaTable = arcpy.MakeTableView_management(in_table=srcMosaic, out_view="tmpMetaTable", where_clause=whereClause) #Populate the table with attributes collected from getRasterCollectionInfo and getRasterInfo metaCount = arcpy.GetCount_management(metaTable)
metaCount = arcpy.GetCount_management(metaTable) returns an error when the metaTable result object is empty.
Here's an example of the image names:
- '20200509_135639_1020' (metadata fields updated successfully in mosaic attribute table)
- '20200509_135639_1020_01' (returns empty result from MakeTableView)
Another bizarre aspect to this is that if I just run the tool using only the image with the suffix (for instance 20200509_135639_1020_01), then arcpy.MakeTableView find the record and returns a result.