I would like to create a shape file containing the extents of each of the rasters in a directory. Is it possible to capture the extent of a raster using Python?
I have tried
extent1=arcgisscripting.Raster.extent('stg1_05.jpg') Runtime error <type 'exceptions.TypeError'>: 'getset_descriptor' object is not callable
and I can't seem to find any help on the module.
I also tried
arcpy.RasterToPolygon_conversion(inRaster, outPolygons, "SIMPLIFY", field) Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 010247: The size of the output shapefile exceeds the 2 GB limit. ERROR 010067: Error in executing grid expression. Failed to execute (RasterToPolygon).
Anyway this will be a polygon of the whole raster file and not just the extents -even if this is generated, I guess we could then run a merge/dissolve but the files created are to big.
Another option I was thinking of was to convert the raster to layer
myMXD=arcpy.mapping.MapDocument("CURRENT") lstDataFrames=arcpy.mapping.ListDataFrames(myMXD) dataframe=lstDataFrames[0] arcpy.MakeRasterLayer_management(inRaster, outPolygons) addLayer=arcpy.mapping.Layer('1.lyr') arcpy.mapping.AddLayer(dataframe,addLayer)
and then get the extents of the layer but this seems to be a very convoluted process...which I can't get to work anyway.
arcpy.mapping.Layer.getExtent(lyr1) Runtime error <type 'exceptions.TypeError'>: unbound method getExtent() must be called with Layer instance as first argument (got str instance instead) lyr1.arcpy.mapping.Layer.getExtent() Runtime error <type 'exceptions.AttributeError'>: 'str' object has no attribute 'arcpy'
PLEASE ADVISE