Hello,
I am trying to read metadata from mosaic datasets, related to band information using Python. Below I have attached an image showing what I need to read.
I have tried using arcpy.Describe method, but it won't return the info I need. Is there another way to obtain this info in an automated way?
Thanks a lot,
Alin
Is this info not part of the raster object properties?
Thanks for the reply, Neil.
I tested all the tools related to describing objects:
- Raster Band properties—Help | ArcGIS Desktop
- Get Raster Properties—Help | ArcGIS Desktop
- Raster Dataset properties—Help | ArcGIS Desktop
But none of these give me the info I need. That info I believe is stored at the mosaic dataset level, not at the raster level. The describe tool on mosaic datasets does not seem to have a method for that info:
Mosaic Dataset properties—ArcPy Functions | ArcGIS Desktop
Thanks again,
Alin
Hi Alin,
The get raster properties tool should do this. wavelength is one of the properties that the tool returns.
Mosaic datasets are supported in this tool as well. Most of our tools treat mosaic datasets as rasters. If you would like to read porperties individual rasters within a mosaic dataset you will need to use a search cursor. For example:
for row in arcpy.da.SearchCursor(mdPath, ["OBJECTID", "Name", "Raster"]): GetRasterProperties_management(row, "WAVELENGTH", "Band_2")
Hi Jamie,
I tried to use your example on the rasters in the footprint table, but it returned 'UNKNOWN', because that info is not included in the raster's key metadata. Then I tried on the mosaic dataset, and it worked fine.
Example:
Thanks a lot!
Alin
Sorry Alin. My mistake.
Give this a shot.
import arcpy for row in arcpy.da.SearchCursor("c:\\test\\IKONOS.gdb\\IKONOS_CalVal_16bit", ["Raster"]): res = arcpy.GetRasterProperties_management(row[0], "WAVELENGTH", "BLUE") print(res)
I tried that example, but I get this error:
ERROR 000864: Band Name: The input is not within the defined domain. ERROR 000800: The value is not a member of Band_1 | Band_2 | Band_3 | Band_4 | Band_5 | Band_6 | Band_7 | Band_8 | Band_9. Failed to execute (GetRasterProperties).
Thanks,
Alin
Hi Guenter,
Thanks for the suggestion and the code. While that script works great for retrieving wavelength metadata from rasters in the footprint of a mosaic dataset, my rasters does not have that property set, because they are simple band composites I create, and they don't follow a common sensor scheme. I only needed to retrieve wavelength info at the mosaic dataset level, which I did with the code I posted above.
Thanks,
Alin
Thanks Guenter. He is correct. It depends on the raster you are using. I wrote the code based on a geoeye raster product. These products actually store the band names as colors. If you are using a more generic raster it will be what Gunter suggested.