0

I have a mosaic dataset (file geodatabase) with an additional field added to it (id that is integer) and I'm trying to accomplish in ArcPy what I can do manually--which is:

  1. Add a new raster (single tif file) to the mosaic dataset in the file geodatabase.
  2. Set the additional field to a value.

I've successfully added a raster using arcpy.AddRastersToMosaicDataset_management, but I don't see how I can set that additional field.

If AddRastersToMosaicDataset_management returned objectids, I could manually set it via an update cursor but I don't see how to get that value.

Is it possible from ArcPy to update a custom field on a Mosaic Dataset?

1

If raster fields are not supported for use in an update cursor (see parameter 2 'field_names') you could consider using the Calculate Field (Data Management) tool on your mosaic dataset via arcpy? I just tested on a custom field and it worked as expected.

  • This would update every raster in the mosaic dataset--you would need a where clause using the objectid (which isn't returned). – Jay Cummins Jul 28 '15 at 15:29
  • Couldn't you just select the raster that was just added and the update cursor would only process that single selected record? – David Aug 11 '15 at 20:41
  • I think my first comment answers that question--you would need to select the raster somehow. Normally, that would be objectid but I don't see how that is returned. I've certainly used objectid+1 for testing purposes, but that is unsafe. – Jay Cummins Aug 11 '15 at 20:49
  • You're right it does, sorry I just caught that. I'm trying to think of another way to identify the last raster that was added to the MD, maybe a system managed date field? Just thinking off the top of my head here.. – David Aug 11 '15 at 21:41
0

Since we've several weeks without an answer, here is my workaround: enforce uniqueness of the raster name before adding to the mosaic dataset and then query out the row by name.

This only works if you can manage the uniqueness of the rasters that you are adding. In my case, I can and I do by renaming the rasters to a number that I obtain from a postgresql sequence. It doesn't have to be number--Name is varchar(50):
Name Field Properties

Then the raster can be queried using the Name field: Name = '24181' and you can obtain your row and do whatever you need to (like update a custom field).

ArcCatalog Numbered Rasters

A couple of notes:

  1. You are responsible for enforcing raster name uniqueness because it is allowable to add 2 rasters with the same name.
  2. Add an index to the Name field because it isn't created when the mosaic dataset is created:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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