0

I would like to change the default mosaic operator on mosaic datasets my script creates. However, I can only manually change the mosaic operator from mosaic dataset properties from ArcCatalog by right clicking the mosaic dataset. Is there a way this could be access and changed from the script itself?

This is the properties window that I am trying to access using arcpy: enter image description here

I'm trying to accomplish something similar to this:

for mosaic_dataset in mosaic_datasets:
    arcpy.CreateMosaicDataset_management(gdb_path, mosaic_dataset, coord, "1","8_BIT_UNSIGNED")

which works fine, but the next step is to change the mosaic operator from python rather than manually changing it and I cannot find any documentation.

5
  • I've added the code, but there is no documentation on how to access mosaic dataset properties from python, so I have no idea how to code next step.
    – user81784
    Commented Jan 24, 2017 at 19:48
  • 1
    According to geonet.esri.com/thread/84146#comment-354355 there is no way to access the properties through python, you need to use arcobjects
    – Midavalo
    Commented Jan 24, 2017 at 19:54
  • You may need to consider looking for or submitting an ArcGIS Idea.
    – PolyGeo
    Commented Jan 24, 2017 at 19:58
  • I found a workaround for this problem but this is good to know. Ty.
    – user81784
    Commented Jan 24, 2017 at 20:28
  • @cptpython there's a standard arcpy tool to do this. See my answer.
    – user2856
    Commented Jan 25, 2017 at 5:15

2 Answers 2

1

Use the Set Mosaic Dataset Properties tool.

arcpy.SetMosaicDatasetProperties_management(mosaic, default_mosaic_method='First')

You can set more than one property at a time:

arcpy.SetMosaicDatasetProperties_management(mosaic,
    allowed_compressions='NONE;LZ77',
    default_compression_type='LZ77',
    resampling_type='NEAREST',
    allowed_mensuration_capabilities='NONE',
    default_mensuration_capabilities='NONE',
    allowed_mosaic_methods='Center;LockRaster;ByAttribute;None',
    default_mosaic_method='ByAttribute',
    order_field='RANK',
    sorting_order=True,
    mosaic_operator='MIN',
    max_num_per_mosaic=500,
    metadata_level='BASIC',
    data_source_type='THEMATIC')
1
  • Wonderful! Shame on me for not digging hard enough.
    – user81784
    Commented Jan 25, 2017 at 16:31
1

My workaround for this problem was to create an empty mosaic dataset, make the desired changes and then place it in a loop using arcpy.Copy_management to create multiple copies. It is not ideal, but gets the job done with minimal reworking of workflow:

for mosaic_dataset in mosaic_datasets:
    mosaic_data_template = "C:/MD.gdb/template"     
    arcpy.Copy_management(mosaic_data_template, mosaic_dataset)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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