0

I'm trying to create a list of shp that are within my map and get the pathname of each shp so I can then add it as an attribute. Within the process I want to merge them and that's where I'm getting an error line 16:

Failed to execute. Parameters are not valid. ERROR 000400: Duplicate inputs are not allowed Failed to execute (Merge).

I'm not sure if this due because my shp. have almost the same name or if it's something within my code. I must say I'm quite new to python so not really sure what I'm missing.

This is the script I'm using: enter image description here

2
  • 3
    Please paste code and not a screen snot, it's easier to copy and modify into an answer. I think the problem is you're supplying layers that are duplicates from your mxd.. is it that you only want to include your shapefile layers? You will need to test their geometry type before merge as you can't merge a mix of line/point/polygons into a single shapefile. Commented Nov 2, 2018 at 4:37
  • Welcome to GIS SE! We're a little different from other sites. We're a Q&A site, not a discussion forum. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. Please check out our short tour for more about how the site works. Thanks.
    – PolyGeo
    Commented Nov 2, 2018 at 4:48

1 Answer 1

1

It seems you're going through your layers looking for shape files but not doing anything when you find them.. consider doing it this way:

output=r'N:\Path'
mxd = arcpy.mapping.MapDocument(r'N:\Path') # this isn't a mxd

PolyShapes = [] # an empty list
for layer in arcpy.mapping.ListLayers(mxd):
    if layer.valid(): # layer is not broken
        if layer.isFeatureLayer: # is a feature layer not a group or raster layer
            if '.shp' in layer.dataSource.lower():
                d=arcpy.Describe(layer.dataSource)
                if d.shapeType=='Polygon': 
                    if layer.dataSource not in PolyShapes:
                        PolyShapes.append(layer.dataSource)

arcpy.Merge_management(PolyShapes,os.path.join(output,'All_Boundaries.shp'))

Start with an empty list then iterate the layers, check the layer is valid (points to a dataset) and is a feature layer, then ensure it's a polygon shapefile using the describe object then add to the list (if not there already) then finally merge using the list.

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