HOW TO

Remove rasters from a mosaic dataset using an area of interest polygon in Python

Last Published: April 25, 2020

Summary

The Remove rasters from Mosaic Dataset tool does not have the option for spatial query. The code below illustrates the use of ArcPy to remove rasters based on a polygon area of interest.

Procedure

The code sample can be used as a stand alone Python script to remove rasters from a mosaic dataset based on a spatial query. A polygon is used in this example.


  1. Code:
    import arcpy
    from arcpy import env

    #set variables
    env.workspace = r"D:\Documents\Northwest.gdb"
    clipShape = "parks"
    mosaicDataset = "CityOfPortland"

    # Make a mosaic layer to be able to select the footprint
    arcpy.MakeMosaicLayer_management(mosaicDataset, "mdlayer")

    # Select the footprint based on polygon clipShape using the intersect method
    arcpy.SelectLayerByLocation_management("mdlayer", "INTERSECT", clipShape)

    # Run the remove rasters tool without any query on the selection
    arcpy.RemoveRastersFromMosaicDataset_management("mdlayer", "#", "UPDATE_BOUNDARY", "MARK_OVERVIEW_ITEMS")

Article ID:000011807

Software:
  • ArcMap

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options