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

Thanks.

P.S. I am using ArcInfo 10.0

clipPolylinesToRasterExtent

share|improve this question
add comment

2 Answers 2

up vote 7 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
pnt_array.add(extent.lowerLeft)
pnt_array.add(extent.lowerRight)
pnt_array.add(extent.upperRight)
pnt_array.add(extent.upperLeft)

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
add comment

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 ...
arcpy.CopyFeatures_management(shapefile,outFeatureClass)
share|improve this answer
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.