[GIS] Add a time dimension in ESRI mosaic raster dataset

arcpymosaicraster

I am in the process of creating a script to pull daily .asc files from a ftp server, convert them to a raster format, and push them into a mosaic raster dataset. Ultimately, the raster dataset will be updated with a new image every day, and I would like a time slider to appear when the dataset is viewed in ArcMap.

I think I will want to use:

AddRastersToMosaicDataset_management(in_mosaic_dataset, raster_type, input_path,
                                           {UPDATE_CELL_SIZES | NO_CELL_SIZES},
                                           {UPDATE_BOUNDARY | NO_BOUNDARY},
                                           {NO_OVERVIEWS | UPDATE_OVERVIEWS},
                                           {maximum_pyramid_levels},
                                           {maximum_cell_size},{minimum_dimension},
                                           {spatial_reference},
                                           {filter}, {SUBFOLDERS | NO_SUBFOLDERS},
                                           {INCLUDE_DUPLICATES | EXCLUDE_DUPLICATES},
                                           {NO_PYRAMIDS | BUILD_PYRAMIDS},
                                           {NO_STATISTICS | CALCULATE_STATISTICS},
                                           {NO_THUMBNAILS | BUILD_THUMBNAILS},
                                           {operation_description},
                                           {NO_FORCE_SPATIAL_REFERENCE | FORCE_SPATIAL_REFERENCE})

This seems to be used for a 'batch' of raster files, however (e.g. fiter='*.tiff'). I will only be adding one raster at a time (1/day after processing the received .asc files). It is not clear to me exactly how / where I'll add the time information. The rasters will all be overlapping, so having a time slider is rather critical… or it won't be so interesting!

Does someone have suggestions on how to accomplish what I am trying to achieve?

Best Answer

I am now using an python+arcpy script for adding the raster to the Mosaic DataSet and then updating the value in the time field.

For this, I am using some Python time/date time Manuipulation to get the correct expressions. My code is as follows:

import arceditor
import arcpy
import datetime
import time

#time manipulations

n=datetime.datetime.now()
dt=datetime.datetime(n.year, n.month, n.day, n.hour)
timeString=dt.strftime('%Y-%m-%d %H:%M:%S')#this is a string like 2013-08-21 08:00:00

#now we need to get the time in epoch for the name of the raster
tt=datetime.datetime.timetuple(dt)
ep=str(int(time.mktime(tt))) #datetime expressed as Unix epoch secods


rPath="%scratchWorkspace%\\"+ep+".img" #This is my input image, which is created by a different script

sde_path=r"C:\Users\<myUser>\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\NewServer.sde" #SDE connection
m_dataset="foo.bar.MD_p" #The Mosaic DataSet

arcpy.env.workspace=sde_path

#add Interpolated Data into Mosaic DataSet
arcpy.AddRastersToMosaicDataset_management(m_dataset,"Raster Dataset", rPath,"UPDATE_CELL_SIZES","UPDATE_BOUNDARY","NO_OVERVIEWS","#","0","1500","#","#","SUBFOLDERS","ALLOW_DUPLICATES","NO_PYRAMIDS","NO_STATISTICS","NO_THUMBNAILS","#")


# We need to Update the 'Time' value in the table
Expression = "Name= '"+ ep+"'"

#Use an Update Cursor
rows=arcpy.UpdateCursor(m_dataset, Expression) #The rows will ahve only those rows which meet the query expression

#loop over the row(s)
for r in rows:
    r.Tm_Data=timeString #here the value is being set in the proper field
    rows.updateRow(r) #update the values

print "Finished"
Related Question