arcpy.CheckOutExtension("3D") env.workspace = "C:/data" arcpy.RasterDomain_3d("dtm_grd", "raster_domain.shp", "POLYGON")
#Script to loop through rasters in an mxd, and print a shape file of their extent (exact boundary, not rectangle). import arcpy from arcpy import env #disable M and Z values in output arcpy.env.outputZflag = "Disabled" arcpy.env.outputMflag = "Disabled" arcpy.CheckOutExtension("3D") mxd = arcpy.mapping.MapDocument(<insert path to mxd here>) env.workspace = <insert path to workspace here>(mxd, "_*") for raster in rasters: #Generate a unique name for each polygon/ shapefile. Have given them the prefix "del" so I can find them and delete them later outPoly = "del" + str(raster) + ".shp" #Execute Raster Domain Tool arcpy.RasterDomain_3d(raster, outPoly, "POLYGON") #get the feature classes from this folder fcList = arcpy.ListFeatureClasses() for fc in fcList: #Generate a unique name for each simplified polygon simpPoly = fc.lstrip("del_")+ "simp_" + fc.rstrip(".shp") #Execute Simplify Polygon tool arcpy.SimplifyPolygon_cartography(fc, simpPoly, "POINT_REMOVE", 1, "", "", "NO_KEEP") #get feature classes for deletion from same folder deleteBigPolys = arcpy.ListFeatureClasses("del*") #delete these features classes (too large) for deleteBigPoly in deleteBigPolys: arcpy.Delete_management(deleteBigPoly)
#disable M and Z values in output arcpy.env.outputZflag = "Disabled" arcpy.env.outputMflag = "Disabled"
#Script to loop through rasters in an mxd, and print a shape file of their extent (exact boundary, not just polygon). import arcpy from arcpy import env arcpy.CheckOutExtension("3D") mxd = arcpy.mapping.MapDocument(r"J:\gisprojects\Project\330\80000_89999\3308480_SS_GIS\0051_LiDAR_Index\mxd\ras_to_polygon_test.mxd") env.workspace = r"J:\gisprojects\Project\330\80000_89999\3308480_SS_GIS\0051_LiDAR_Index\data\shpfile_ras_boundaries" rasters = arcpy.mapping.ListLayers(mxd) for raster in rasters: #Generate a unique name for each polygon outPoly = "domain_" + str(raster) + ".shp" #Execute Raster Domain Tool arcpy.RasterDomain_3d(raster, outPoly, "POLYGON") print "finished"
gp.AddField_management(GridName, fields[0], 'TEXT', '', '', IMAGEfldLen)
>>> fields = ['IMAGE', 'XMIN', 'XMAX', 'YMIN', 'YMAX'] >>> for i in range(0, 5): # or for i in range(5): print fields IMAGE XMIN XMAX YMIN YMAX
>>> for field in fields: print field IMAGE XMIN XMAX YMIN YMAX
#Script to loop through rasters in an mxd, and print a shape file of their extent. # Based on script at the following forum link: http://forums.arcgis.com/threads/74002-Create-index-outline-of-rasters?p=258761#post258761 mxd = arcpy.mapping.MapDocument("CURRENT") GridName = "boundaries" IMAGEfldLen = 50 arcpy.CreateFeatureclass_management("<file path for directory which will contain shapefile>", "<insert name of shapefile>", "POLYGON") fields = ['IMAGE', 'XMIN', 'XMAX', 'YMIN', 'YMAX'] arcpy.AddField_management("<insert name of shapefile>", fields[0], "TEXT", '', '', IMAGEfldLen) for i in range(1,5): arcpy.AddField_management(GridName, fields, "DOUBLE", 18, 17) print "added field: " + fields rasters = arcpy.mapping.ListLayers(mxd) arrayObj = arcpy.CreateObject('Array') outRows = arcpy.InsertCursor(GridName) for raster in rasters: extent = arcpy.Describe(raster).extent arrayObj.add(extent.lowerleft) arrayObj.add(extent.lowerright) arrayObj.add(extent.upperright) arrayObj.add(extent.upperleft) arrayObj.add(extent.lowerleft) feat = outRows.newRow() feat.Shape = arrayObj image = '.\\' + str(raster) feat.setValue('IMAGE', image) feat.setValue('XMIN', extent.xmin) feat.setValue('YMIN', extent.ymin) feat.setValue('XMAX', extent.xmax) feat.setValue('YMAX', extent.ymax) outRows.insertRow(feat) arrayObj.removeAll() del outRows
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.