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


2 Answers 2


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")
  • 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, 2012 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 ...
  • Note that whilst this is generally faster than using Clip_analysis, any features that intersect the extent bounding box will be selected "in full" and won't actually be clipped back to the bounding box edge. Mar 3, 2021 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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