Hope you are keeping safe in current events.
Im trying to Save new mosaic dataset with new definition query. But it seems that the script below saves new mosaic dataset, but without a query. Any advise would be appreciated.
import arcpy mxd = arcpy.mapping.MapDocument(\Historic_Maps.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers") field = 'Date' values = "'1950'" query=str(field) +" "+ "=" + str(values) for lyr in arcpy.mapping.ListLayers(mxd, "*"): if lyr.name == "Sacle_1250": lyr.definitionQuery = query arcpy.mapping.AddLayer(df, lyr, "BOTTOM") arcpy.RefreshActiveView() arcpy.RefreshTOC() mxd.saveACopy (\my_mxd3.mxd") del mxd
The typo happened while copying the code into Geonet.
I have tried your suggested query. unfortunately it doesnt do the trick.
Mosaic datsets have three component: Boundary, Footprint and Image.
Definition queries are set in Footprint.
The naming of footprint is a mystery for me as well.
For instance I have some possible options in
lyr.name == :
I have tried Scale_1250\Footprint, I have tried Scale_1250\AMD_Scale_1250_CAT.
Nothing seems to work.
This is what confusing me. When I view properties it is Mosaic dataset. I also created a new from scratch as a mosaic dataset.
But when I view properties of Footprint, it says its Raster catalog:
I've tried multiple syntax but no avail. I've been able to apply definition queries to feature classes using your code, but not a MD.
wrt the raster catalog footprints, it seems this is correct for a mosaic dataset (I think the MD is a repackaged raster catalog rolled in glitter)
Look forward to someone solving this.