AnsweredAssumed Answered

Create a new layer of mosaic dataset with definition query in ArcMap.

Question asked by benas.pekarskis_arcadis_uk on Mar 31, 2020
Latest reply on Mar 31, 2020 by benas.pekarskis_arcadis_uk

Hello GISesrs,

 

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")[0]
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

Outcomes