I am calculating a mosaic dataset's DATE field, which is a combination of a portion of the rasters' names and the directory they exist in; for example, 'rastername_0131.tif' will exist in both the '2020' and '2021' folders.
Will I have to export the raster paths, join field to pull the paths back in to an accessible field and then split the path components to find out the year of that particular raster's January 31 in order to accomplish this through the Calculate Field functionality?
Is it possible to access the path of a mosaic dataset row's raster in a field calculation run on a mosaic dataset? Similar to accessing the shape.area value for a feature dataset? Like, raster.path?
I can't find any docs that suggests this is possible but thought I'd ask before carrying on with the above, more complicated, process.
ps. No, I can't change the directory structure I am working with; other apps access these rasters as they are and they must remain there.
Hmmmm, if I'm interpreting correctly - you can access the raster name in the MD Footprint attribute table, and can thus calculate the Day and Month, but would need the full path to get the year.
There may well be a simple way, and I'm just not aware of it, but:
do an os.walk to get a list of all the full filepaths of rasters in the worksapces (if these are in FGDBs you'll need to use a listRasters method instead).
Add a new Date field to the attribute table then Run an arcpy.da.UpdateCursor on the footprint attribute table, see where the 'Name' field matches with the end of the full path.
Then just some logic to calculate the Date.
A simple way (as you mentioned) could be to use Export Mosaic Dataset Paths. This will create a separate table with the full paths along with the original IDs of the rasters in the Mosaic Dataset.
Then the Full_Path field can be used to fill the Raster_Date field(DataType=Date) using Field Calculator (Maybe using Mid Function and its concatenation in VBScript). And joining the Raster_Date field back to the Raster Footprint Attribute Table.
It's just one of the few workarounds.
I like this idea (because I am doing the field calculation as part of a larger Python script already so it would be easy to introduce). I'd use it if I could...
Unfortunately, I was mistaken in the filename example I gave originally and have now revisited the folders. Names are duplicated in the different years because the date information is provided in the file name by identifying the week the raster was captured, which is further understood to be the Monday of that identified week.
If something like raster.path isn't available to me through the Calculate Field interface, I don't see that I have any option except exporting the mosaic dataset's paths as originally thought.
Thank you for taking the time to respond with the new idea, though!