Select to view content in your preferred language

Accessing Paths for rasters in a mosaic dataset

4258
9
08-28-2013 01:32 PM
MarcGraham
Deactivated User
Hi everybody!

Can anyone direct me to the best method for getting the paths to rasters that are managed by a mosaic dataset.  I see that there is a raster object stored in the attribute table of the mosaic footprints.  I thought perhaps that will store the information that I am after.  So I tried this:

arcpy.MakeMosaicLayer_management(r'C:\Users\Marc\Documents\ArcGIS\Raster_Mosaic\Waiheke_Imagery_Mosaic.gdb\waiheke_test_mosaic', 'mosaic') 

fc = 'mosaic\Footprint'

field = ['Raster']

with arcpy.da.SearchCursor(fc, field) as cursor:
     for row in cursor:
         print row[0].name
None
None
None


and this:

with arcpy.da.SearchCursor(fc, field) as cursor:
     for row in cursor:
         print row[0].path
None
None
None


Then I thought maybe I need to use the describe function:

with arcpy.da.SearchCursor(fc, field) as cursor:
     for row in cursor:
         desc = arcpy.Describe(row[0])        
         print desc.name
AMD_waiheke_test_mosaic_CAT\Raster.OBJECTID = 1
AMD_waiheke_test_mosaic_CAT\Raster.OBJECTID = 2
AMD_waiheke_test_mosaic_CAT\Raster.OBJECTID = 3


with arcpy.da.SearchCursor(fc, field) as cursor:
     for row in cursor:
         desc = arcpy.Describe(row[0])        
         print desc.path
C:\Users\Marc\Documents\ArcGIS\Raster_Mosaic_FME_Tests\Waiheke_Imagery_Mosaic.gdb\AMD_waiheke_test_mosaic_CAT
C:\Users\Marc\Documents\ArcGIS\Raster_Mosaic_FME_Tests\Waiheke_Imagery_Mosaic.gdb\AMD_waiheke_test_mosaic_CAT
C:\Users\Marc\Documents\ArcGIS\Raster_Mosaic_FME_Tests\Waiheke_Imagery_Mosaic.gdb\AMD_waiheke_test_mosaic_CAT


Obviously none of these are returning the filenames or the paths to the original rasters.  Can anybody tell me if I am doing something completely wrong, or if this is just not possible.

I see there is this tool: http://resources.arcgis.com/en/help/main/10.1/index.html#/Export_Mosaic_Dataset_Paths/00170000017m00... but I would like to access the paths directly, rather than having to use an intermediate dbf file.

Thanks heaps,

Marc
Tags (2)
0 Kudos
9 Replies
MattSayler
Frequent Contributor
What's your ultimate goal, out of curiousity?
0 Kudos
MarcGraham
Deactivated User
What's your ultimate goal, out of curiousity?


Creating a geoprocessing tool that allows users to select an AOI, then downloads the mosaic rasters to a local folder that they specify.  Useful for grabbing a few tiles to a laptop when heading out the door on fieldwork.
0 Kudos
MattSayler
Frequent Contributor
Got ya.

Doing some research, it looks to me like that info is stored in the "Raster" column which is likely in a proprietary format. That might be why they provided that export tool in the first place.

I didn't find anything 100% concrete though, so maybe there's still some hope. You might not need the actual file path to do an export.
0 Kudos
MarcGraham
Deactivated User
I have since found this:

http://support.esri.com/es/knowledgebase/techarticles/detail/40054

and this:

http://resources.arcgis.com/en/help/main/10.1/index.html#//009t00000018000000

but I'm not sure if the raster dataset properties that are mentioned are accessible via arcpy.

Any ideas?
0 Kudos
ModyBuchbinder
Esri Regular Contributor
Hi

Use can run Data management->Raster->Mosaic->Export Mosaic Dataset Paths GP tool.
Then use Python to match the two on the OBJECTID.

Mody
0 Kudos
MarcGraham
Deactivated User
Hi

Use can run Data management->Raster->Mosaic->Export Mosaic Dataset Paths GP tool.
Then use Python to match the two on the OBJECTID.

Mody


Hi, thanks for your suggestion, but that doesn't seem to be an option.  I am actually doing a select by location based on a digitised AOI and the footprints of the mosaic.  Then I want to access the selected footprints and copy the rasters that are referenced by these to a folder.  I can't run the Export Mosaic Dataset paths tool every time the script is run as one of the mosaics I am dealing with has over a hundred thousand records, and it seems like a massive overhead to do this each time.  I am not willing to export it once and hard code the script to read that table, as it may get out of date.

I know that the path is saved as a property of the raster object in the Raster Field, I just need to know how to access this programmatically.  There must be a way.
0 Kudos
MarcGraham
Deactivated User
Got it: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000159000000.

Now just need to work out how to use it, shouldn't be too hard though.

Edit: It's easy and awesome.  Best way to get your hands on mosaic/image service rasters.
0 Kudos
DaveBarrett
Deactivated User
Got it: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000159000000.

Now just need to work out how to use it, shouldn't be too hard though.

Edit: It's easy and awesome.  Best way to get your hands on mosaic/image service rasters.


This is pretty much the best way to achieve what you are trying to do but you need to be aware of the tile download limit for each mosaic dataset/image service.  I believe the default is 20 tiles but you can change this using the Set Mosaic Dataset Properties tool in the data management toolbox. This is the help link.

http://resources.arcgis.com/en/help/main/10.1/index.html#/Set_Mosaic_Dataset_Properties/001700000161...

The download tool also provides an easy way to convert the format of the rasters and maintain the original file structure if you require it.

Dave
0 Kudos
MattSayler
Frequent Contributor
I have since found this:

http://support.esri.com/es/knowledgebase/techarticles/detail/40054

and this:

http://resources.arcgis.com/en/help/main/10.1/index.html#//009t00000018000000

but I'm not sure if the raster dataset properties that are mentioned are accessible via arcpy.

Any ideas?


That's much of the same info I came across. The path is definitely in that 'Raster' field, but so far I'm not seeing a way to get at it through python or geoprocessing other than that table export tool. Not even the Get Raster Properties tool has it, oddly enough, unless they just didn't document it. I'm thinking it might be accessible using ArcObjects, but that probably doesn't help.

Regardless, it sounds like you found a good solution. Don't forget to mark your post as the answer, and congrats!
0 Kudos