# Clipping raster using polyline or polygon using ArcGIS Spatial Analyst?

I have a large raster created from values that cover the whole United States and Alaska which are both polygon and polyline features, this raster was caluclated using Spatial Analyst IDW Interpolation. How can I get the raster to clip with the either the polyline of the United States border or the polygon shape of the United States?

I followed the advice of @DerekSwingley and set the cell size environment setting to match the original raster. It gives it a smooth border but instead of having smooth grades of differentiating colors now i have large blocks of differentiating colors.

Good

Any ideas on how I can fix this and get the Bad raster to look like the orignial (good) raster but keep the bad rasters border?

Extracts the cells of a raster that correspond to the areas defined by a mask.

and specify your polygon feature class of the US as the mask.

• Tried this but it severely killed the resolution of the raster, any way to keep the original res? – Furlong Dec 21 '10 at 0:03
• What's the cell size of the raster being clipped? You could also try setting the cell size environment setting for ArcGIS: help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… – Derek Swingley Dec 21 '10 at 1:25
• You are absolutely correct. In some cases the result will be sensitive to the grid origin, too, so a better approach is to set the origin and cellsize to the same as the interpolated grid. Actually, in retrospect it's best to establish the desired projection, specify an explicit raster environment at the outset, create the mask first, and then do the interpolation with the mask in place: that would be easier for both the analyst and the computer. – whuber Dec 21 '10 at 14:48

With GRASS GIS you could rasterize your polygone of the USA (v.to.rast) and then use a mask.

You can also use the GDAL utility program GDALWarp - http://www.gdal.org/gdalwarp.html

Passing in a -cutline parameter (a feature from any OGR datasource) clips the original raster.

E.g.

C:\gdal\apps\gdalwarp C:\myraster.tif C:\output.tif -cutline C:\inputfeat.json -dstnodata -9999


In GDAL 1.8 there is a new -crop_to_cutline paramter that may also be useful.

• only problem with this -cutline parameter is that the resulting raster comes with a mislocation of ~1 pixel... – vascobnunes Jul 14 '11 at 14:05