Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
1  
I recently had to do the same in ArcGIS 10.0. I faced a major problem in adding the datetime to the data. I found this link to be quite useful: help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/… –  Devdatta Tengshe May 15 '13 at 14:58
    
Thanks, I followed one further link from there: help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… It is helpful, but I found this sentence, with no link for reference "Add the Year field to the mosaic dataset To make this mosaic dataset time aware, you need to create the new attribute field in the mosaic dataset and add the correct dates. You can do this using geoprocessing tools or using the steps below within ArcMap." Does anyone know to which geoprocessing tools they refer? –  John May 16 '13 at 7:12
    
I created a model, where I first add the raster to the Mosaic Dataset, then create a raster layer, then apply a selection, and finally use field calculator. This model runs every hour and updates the Mosaic dataset with new data. –  Devdatta Tengshe May 16 '13 at 7:15
add comment

2 Answers 2

up vote 2 down vote accepted

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"
share|improve this answer
    
Works! Now I have a problem that when I drag the mosaic dataset into Arc, the high/low values are crazy. The individual images seem to have the correct values. –  John Aug 22 '13 at 15:19
    
@John When I was adding the raster to the mosaic dataset, I did not need to recalculate the statistics; Maybe you can set the option to calculate the statistics when you are adding the raster to the mosaic datataset. That should help. –  Devdatta Tengshe Aug 22 '13 at 16:14
add comment

A raster mosaic dataset has an attribute table built in to it that contains a record for each raster dataset added to the mosaic. You will need to add a time field to that attribute table (or even better a start and end time field), and then set the time for each raster. This would need to be a second step after your "Add Raster to Mosaic" step.

When loaded in the map, you will be able to enable time for the mosaic dataset since there is a valid datetime field. It can then be setup with the TimeSlider.

As for loading individual raster datasets. The tool mentioned above can be used for one or many rasters. To just load one, set the input path to the individual raster. To load many point to a workspace containing many raster datasets.

share|improve this answer
    
thanks. I understand, but do you know what arcpy method I would use to "set the time for each raster". As I've read elsewhere, I can add the time to the attribute table for the 'Footprint'.. which is something that only needs to be done once, correct? But how do I access that table and 'set the time' as I'm (or just after) adding the newest raster? –  John May 15 '13 at 14:12
    
The time field only needs to be added once, and then time for each raster only needs to be set once (after its added). –  JeremyFon May 15 '13 at 14:26
1  
To set the time there are various options. You can use an update cursor on the mosaic dataset, and just update the newly added raster. Or you could select the new raster only and then use the Calculate field tool. should be no different than any other feature class or table. –  JeremyFon May 15 '13 at 14:28
    
Ok. I think I'll probably want to use the calculate field tool, perhaps and get the date from the file name... this is my first of such a script, so it's new to me even if it's not different than any other feature class or table ;) I came across this link –  John May 15 '13 at 14:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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