Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy, glob, os, sys
- from arcpy import env, mapping
- path = os.getcwd()
- env.workspace = path
- RasterType = 'TIF'
- FileList = glob.glob(path + "*." + RasterType)
- print 'Reading files from ' + path
- os.chdir(path)
- #print FileList
- x=0
- z=1005
- File=FileList[x]
- LayerWorking=arcpy.mapping.Layer(File)
- print File
- LayerExtent=LayerWorking.getExtent()
- XMAX = LayerExtent.XMax
- XMIN = LayerExtent.XMin
- YMAX = LayerExtent.YMax
- YMIN = LayerExtent.YMin
- 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)
- polygon = arcpy.Polygon(array)
- ShapeFile = path + "Polygon_Extent" + "_" + str(z) + ".shp"
- print ShapeFile
- print arcpy.GetMessages()
- arcpy.CreateFeatureclass_management(path, ShapeFile, "POLYGON")
- print arcpy.GetMessages()
- arcpy.CopyFeatures_management(polygon, ShapeFile)
- import arcpy, glob, os, sys, arcgisscripting
- from arcpy import env, mapping
- path = os.getcwd()
- env.workspace = path
- env.overwriteOutput = True
- RasterType = 'TIF'
- FileList = glob.glob(path + "*." + RasterType)
- print 'Reading files from ' + path
- os.chdir(path)
- #print FileList
- geometry_type = "POLYGON"
- template = "C:\Python26\GDA_1994_MGA_Zone_55.shp"
- has_m = "DISABLED"
- has_z = "DISABLED"
- # Creating a spatial reference object
- spatial_reference = arcpy.SpatialReference("C:\Python26\GDA_1994_MGA_Zone_55.prj")
- x=0
- z=x+1
- for File in FileList:
- #File=FileList[x]
- RasterFile = arcgisscripting.Raster(File)
- RasterExtent = RasterFile.extent
- print File
- XMAX = RasterExtent.XMax
- XMIN = RasterExtent.XMin
- YMAX = RasterExtent.YMax
- YMIN = RasterExtent.YMin
- 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)
- polygon = arcpy.Polygon(array)
- arcpy.CreateFeatureclass_management(path, "Temp_Polygon_Extent" + "_" + str(z), geometry_type, template, has_m, has_z, spatial_reference)
- arcpy.CopyFeatures_management(polygon, "Temp_Polygon_Extent" + "_" + str(z))
- ShapeFile = "Temp_Polygon_Extent" + "_" + str(z) + ".shp"
- print "Created: " + ShapeFile
- arcpy.AddField_management(ShapeFile,'FileName','TEXT')
- desc = arcpy.Describe(ShapeFile)
- print desc, ShapeFile
- #rows = arcpy.InsertCursor(ShapeFile, desc)
- rows = arcpy.UpdateCursor(ShapeFile)
- #row = rows.newRow()
- #row.FileName = str(File)
- #row.FileName = File
- print 'Filled in: ', str(File)
- #rows.insertRow(row)
- for row in rows:
- row.FileName = str(ShapeFile)
- rows.updateRow(row)
- x=x+1
- z=z+1
- #cleaning up
- arcpy.CreateFeatureclass_management(path, "Extent.shp", geometry_type, template, has_m, has_z, spatial_reference)
- list =[]
- lstFCs = arcpy.ListFeatureClasses("Temp_Polygon_Extent*")
- print 'Merging Polygon_Extents* to Extent.shp'
- for fc in lstFCs:
- print fc
- list.append(fc)
- arcpy.Merge_management(list, "Extent.shp")
- #print 'Deleting identical entries and temp files'
- #arcpy.DeleteIdentical_management("Extent.shp", ["SHAPE"])
- print 'Created Extent.shp and exiting'
- for item in list:
- arcpy.Delete_management(item)
- del row, rows
- import os, gdal
- gdaltindex Extent.shp *.tif
- extent1 = arcgisscripting.Raster('stg1_05.jpg').extent
- raster1 = arcgisscripting.Raster('stg1_05.jpg')
- extent1 = raster1.extent
- gdaltindex Extent.shp *.jpg
Add Comment
Please, Sign In to add comment