Select to view content in your preferred language

Create a list and iterate with the tool arcpy.MinimumBoundingGeometry_management

950
3
01-01-2014 04:40 PM
PierreWeisse
Deactivated User
Hello and Happy New Year to all,

I work with a document .mxd. All my data from SDE.

I would like to put these data into a list and then iterate with each tool "arcpy.MinimumBoundingGeometry_management".

Thank you for your help
Tags (2)
0 Kudos
3 Replies
AndrewChapkowski
Esri Regular Contributor
Try the following:

import arcpy
from arcpy import mapping
mxd = mapping.MapDocument("CURRENT")
layers = mapping.ListLayers(mxd)
for lyr in layers:
   outMin = arcpy.CreateUniqueName("envelope", arcpy.env.scratchGDB)
   arcpy.MinimumBoundingGeometry_management(lyr,
                                                                  outMin,
                                                                  "RECTANGLE_BY_AREA", "NONE")

0 Kudos
PierreWeisse
Deactivated User
Hello Andrew,

I tried the code, it returns me error message

>>> import arcpy
>>> from arcpy import mapping
>>> mxd=mapping.MapDocument("CURRENT")
>>> layers=mapping.ListLayers(mxd)
>>> for lyr in layers:
...     outMin = arcpy.CreateUniqueName("enveloppe",arcpy.env.scratchGDB)
...     arcpy.MinimumBoundingGeometry_management(lyr,outMin,"CONVEX_HULL","NONE")
...    


Runtime error  Traceback (most recent call last):   File "<string>", line 3, in <module>   File "e:\program files\arcgis\desktop10.2\arcpy\arcpy\management.py", line 2576, in MinimumBoundingGeometry     raise e ExecuteError: ERROR 000622: L�??exécution a échoué (Emprise géométrique minimale). Paramètres incorrects. ERROR 000623: Type de valeur non valide pour le paramètre in_features.
0 Kudos
AndrewChapkowski
Esri Regular Contributor
For the layer object, lyr, try using the dataSource property instead of using the layer object.

arcpy.MinimumBoundingGeometry_management(lyr.dataSource,
                                                                       outMin,
                                                                       "RECTANGLE_BY_AREA", "NONE")


Hope this helps.
0 Kudos