Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a clipped raster dataset with polylines (from the contour tool) overlayed (see attached). I am trying to clip the polylines to the extent of the raster dataset, which seems simple enough, but I've tried multiple things and can't seem to get it to work. I will eventually need to code this using arcpy but I think for now, just a nudge in the right direction as to which tool will accomplish this will help me for now.


P.S. I am using ArcInfo 10.0


share|improve this question
up vote 10 down vote accepted

You can use the dataset extent as a polygon geometry with the clip tool, as in the Using geometries in geoprocessing tools example.

import arcpy

pnt_array = arcpy.Array()
extent = arcpy.Raster(in_raster).extent

poly = arcpy.Polygon(pnt_array)

arcpy.Clip_analysis(in_lines, poly, "out_dataset")
share|improve this answer
Thank you!! Before I saw this post, I was able to at least manually do it within Arc, but it sure seems like my way is slightly convoluted. I created a dummy shapefile and then constructed a polygon with the editor tools which outlined the boundary of the raster data. Then I ran the clip tool on the polylines using this dummy shapefile as what it should clip them too. I got an error, but then I used feature to polygon and used the result of this as the shapefile for the polylines to be clipped to and it worked!! I will need arcpy so thanks for that!! :-) – niklas24 Mar 25 '12 at 2:08

There is a simple way to do this.

First get the extent of the raster image.

set it as environment extent property

Then use the copy feature instead of clip analysis , for example

arcpy.env.extent = arcpy.Extent(-107.0, 38.0, -104.0, 40.0)
...some code here to ...
share|improve this answer

Your Answer


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.