Select to view content in your preferred language

Using Mosaic footprints and Boundaries as GP inputs using python

1289
4
Jump to solution
02-07-2014 05:37 AM
MichaelNesius
Deactivated User
Hi All,

I'm a python newbie with a fairly basic question. I'm having a hard time getting arcpy.Integrate_management to accept a mosaic's boundary as input. I get a "does not exist or is not supported" error message. I tried a number of syntax variations on the boundary's filepath without any luck.

If I have the MD added to ArcMap, I can run the Integrate tool, by itself, on the boundary through ArcToolbox but not when trying to use my script.

Here's my script so far:

# Import system modules import arcpy  import os  # Set the necessary product code import arceditor  # Set the gdb for the mosaic inWS = arcpy.GetParameterAsText(0)  MoDataName = arcpy.GetParameterAsText(1)  arcpy.env.overwriteOutput = True  #Set projection to be used by the mosaic  prjfile= arcpy.GetParameterAsText(2)  # Create the mosaic dataset  arcpy.CreateMosaicDataset_management(inWS,MoDataName,prjfile,"","","", "")   # Adding the Rasters Input = inWS+"\\" + MoDataName InPath = arcpy.GetParameterAsText(3) arcpy.AddRastersToMosaicDataset_management(Input,"Raster Dataset",InPath,"UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "", "NO_SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "Add Raster Datasets")  # Integrate the MD's boundary to remove any slivers by using the XY tolerance of 0.31 meters Boundary = "MoDataName\\Boundary" xyTolerance = "0.31 Meters"  arcpy.Integrate_management("Input\\Boundary", xyTolerance)



If I just execute the Integrate GP tool on the boundary locally, this is how ModelBuilder exports the script:

# Import arcpy module import arcpy   # Local variables: Boundary = "DUV2013\\Boundary"  # Process: Integrate arcpy.Integrate_management("DUV2013\\Boundary #", "0.31 Meters")


I can run the script fine without the integrate gp, but this results in a bunch of slivers in the boundary. I don't want to, but I may just end up using the make mosaic layer tool. Any help figuring this out would be greatly appreciated.
Thanks,
Mike
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Mike,

First create a mosaic layer using the Make Mosaic Layer tool, and then you can access the footprint or boundary very easily.  Ex:

arcpy.MakeMosaicLayer_management("Philadelphia", "MosaicLayer") boundary = ("MosaicLayer/Boundary")

View solution in original post

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Mike,

First create a mosaic layer using the Make Mosaic Layer tool, and then you can access the footprint or boundary very easily.  Ex:

arcpy.MakeMosaicLayer_management("Philadelphia", "MosaicLayer") boundary = ("MosaicLayer/Boundary")
0 Kudos
MichaelNesius
Deactivated User
Thanks Jake,

So I should create the mosaic layer, modify it and then use the Import Mosaic Dataset Geometry to change the MD's boundary?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
You will just need to add these lines to your code.  Ex:

import arcpy 
import os

# Set the necessary product code
import arceditor

# Set the gdb for the mosaic
inWS = arcpy.GetParameterAsText(0)

MoDataName = arcpy.GetParameterAsText(1)

arcpy.env.overwriteOutput = True

#Set projection to be used by the mosaic

prjfile= arcpy.GetParameterAsText(2)

# Create the mosaic dataset

arcpy.CreateMosaicDataset_management(inWS,MoDataName,prjfile,"","","", "")


# Adding the Rasters
Input = inWS+"\\" + MoDataName
InPath = arcpy.GetParameterAsText(3)
arcpy.AddRastersToMosaicDataset_management(Input,"Raster Dataset",InPath,"UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "", "NO_SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "Add Raster Datasets")

# Integrate the MD's boundary to remove any slivers by using the XY tolerance of 0.31 meters
arcpy.MakeMosaicLayer_management(Input, "MosaicLayer")
Boundary = "MosaicLayer/Boundary"
xyTolerance = "0.31 Meters" 
arcpy.Integrate_management(Boundary, xyTolerance)
0 Kudos
MichaelNesius
Deactivated User
Thanks again Jake.


For those interested, my solution was:

I created the temporary mosaic layer, used the Copy Features tool on this mosaic layer to create a feature class of the boundary, modified this boundary feature class using the Integrate tool, and then used the Import Mosaic Geometry to change the original mosaic dataset's boundary to match the modifications made to the feature class.
0 Kudos