Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 10 down vote accepted

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

share|improve this answer
add comment

Senthil Saar,

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.

share|improve this answer
1  
-1 This is effectively the same answer as the one posted by @Aragon. –  Fezter Nov 22 '12 at 3:26
1  
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 '12 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 at 17:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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