1

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)[0]

The metaCount = arcpy.GetCount_management(metaTable)[0] 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.

Any ideas?

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Jul 14, 2020 at 23:04
2
  • 1
    Do you delete the TableView anywhere in your code arcpy.Delete_management("tempMetaTable") before you try to create it again? Commented Jul 14, 2020 at 23:36
  • 1
    Yes, I delete TableView at the end of each function call. Although I just realized I'm use del and not arcpy.Delete_managment() Commented Jul 14, 2020 at 23:40

1 Answer 1

1

So Bjorn was right (in the comments). Turns out the issue had nothing to do with the suffix. I was deleting the table view using del, instead of arcpy.DeleteManagement(). That solved it!

answered Jul 15, 2020 at 0:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.