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.

3 Answers 3


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...


Please use the following script, which should work... Please change the path as per the location (Either in Geodatabase or Folders). In this example 'congrd' is the raster dataset that I used.

import arcpy

from arcpy.sa import *

elevRaster = Raster('C:/arcgis/ArcTutor/3DAnalyst/Exercise2/workspace2/congrd')

myExtent = elevRaster.extent

print myExtent

I hope this helps.

  • 3
    -1 This is effectively the same answer as the one posted by @Aragon.
    – Fezter
    Nov 22, 2012 at 3:26
  • 3
    I tried yours and it failed...That is why I had posted the tweaked one...I guess "import arcpy" alone cannot do the trick. Sometimes we need a little push.
    – Jegan Somu
    Nov 23, 2012 at 9:04
  • @JeganSomu You can always edit existing answer instead of creating barely different one. If you don't have enough points, your edits will be reviewed first.
    – mlt
    Jan 16, 2014 at 17:00

You can use Describe:

import arcpy
rasterfile = r"C:\folder\photo.tif"
d = arcpy.Describe(rasterfile)
ext = d.extent

<Extent object at 0x1fc6aea9708[0x1fc302a0f30]>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.