Sunday 26 February 2017

arcpy - How to get an extent for Raster using python


I have to get an extent of a given raster so that I can save it and use the same to clip another raster with that extracted extent. As of now I am stuck in the extent part.



import arcpy
from arcpy import env


desc= arcpy.env.extent("D:\GIS @ UTD\Sem 1\GISC 6317\Lab\Lab 10\temp\Tahoe\Tahoe\Emer\erelev.grid")

print desc

The following gives an output 0 0 0 0 NaN NaN NaN NaN.


Any suggestions.




Answer



Dont use env.extent you need to get raster extent.


import arcpy

elevRaster = arcpy.sa.Raster('C:/data/elevation')
myExtent = elevRaster.extent

print myExtent

i hope it helps you...



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...