It looks like you are only inputting 4 points to create your polygon, you need 5 points to create a closed rectangle.
Coordinate systems are the same.... still generated an empty output. There is only one data frame.... it seems as if my data isn't in the same area as the clipper...which isn't the case but that's the error I'm getting using both syntax from above:"000117 Warning empty output generated:A common occurrence of this warning occurs when the Extent (or XYDomain) environment has been set previously for a geographically distinct area. Since the Extent environment is used to limit the features used, an inappropriately set Extent environment could exclude all features."
Hi Devon,You could create a polygon object based on the MXD's data frame extent, and then use the object to clip the feature class. Here is an example:import arcpy from arcpy import env from arcpy import mapping env.workspace = r"C:\temp\python\test.gdb" mxd = mapping.MapDocument(r"C:\temp\python\County.mxd") df = mapping.ListDataFrames(mxd)[0] xmin = df.extent.XMin ymin = df.extent.YMin xmax = df.extent.XMax ymax = df.extent.YMax pnt1 = arcpy.Point(xmin, ymin) pnt2 = arcpy.Point(xmin, ymax) pnt3 = arcpy.Point(xmax, ymax) pnt4 = arcpy.Point(xmax, ymin) array = arcpy.Array() array.add(pnt1) array.add(pnt2) array.add(pnt3) array.add(pnt4) array.add(pnt1) poly = arcpy.Polygon(array) arcpy.Clip_analysis("Hospitals", poly, "Hospitals_clip") del mxd
import arcpy from arcpy import env from arcpy import mapping env.workspace = r"C:\temp\python\test.gdb" mxd = mapping.MapDocument(r"C:\temp\python\County.mxd") df = mapping.ListDataFrames(mxd)[0] xmin = df.extent.XMin ymin = df.extent.YMin xmax = df.extent.XMax ymax = df.extent.YMax pnt1 = arcpy.Point(xmin, ymin) pnt2 = arcpy.Point(xmin, ymax) pnt3 = arcpy.Point(xmax, ymax) pnt4 = arcpy.Point(xmax, ymin) array = arcpy.Array() array.add(pnt1) array.add(pnt2) array.add(pnt3) array.add(pnt4) array.add(pnt1) poly = arcpy.Polygon(array) arcpy.Clip_analysis("Hospitals", poly, "Hospitals_clip") del mxd
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0] extent = df.extent array = arcpy.Array() array.add(extent.lowerLeft) array.add(extent.lowerRight) array.add(extent.upperRight) array.add(extent.upperLeft) array.add(extent.lowerLeft) polygon = arcpy.Polygon(array) ...
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.