Environmental GIS Prepared by Dr. Zhi Wang, CSUF EES Department Lab 18c: Spatial Analysis III: Clip a raster file using a Polygon Shapefile These instructions enable you to clip a raster layer in ArcMap 9.x using Spatial Analyst. Basically, you need a sample raster (grid) file and a mask polygon shapefile. Download Lab18c.zip to your folder. Unzip it using WinZIP or Windows XP programs. 1. CREATING A MASK (polygon with correct projections - shapefile) 1.1. Drawing a Mask Polygon Shapefile and load into ArcMap: A) Start ArcCatalog. B) Right-click your project folder and select New > Shapefile. C) Name your shapefile Mask and specify: Feature Type = Polygon Spatial Reference is Optional D) Start ArcMap. E) Add the raster layer (dem-grid), CA-watersheds, and the Mask shapefile (click OK) into ArcMap. Double click on legend of CA-watersheds and choose hollow (red outline). Right-click on CA-watersheds, choose Label features. Double-click on dem-grid, choose a color ramp. Save the project as Lab18 (Lab16 was used before the year 2011). 1
F) Click on View > Toolbars > Editor, then click Editor > Start Editing. Click on a folder with Mask and start editing. Make sure Task = Create New Feature; Target = Mask. G) Click on the sketch tool (pencil) and start drawing a polygon to include the upper Merced River watersheds (several). Follow the line and click many points along the frame lines. Double-click on the very last point. A highlighted polygon (Mask shapefile) is created. H) Click on Editor > Stop editing and save your edits. Verify that the Mask file was saved properly by Right-clicking on Mask > Remove then adding it back into ArcMap. 2
2. CLIP RASTER (GRID) FILE USING A MASK POLYGON A). In ArcMap, choose TOOLS - EXTENSIONS and enable Spatial Analyst and 3D Analyst. B). Choose TOOLS - CUSTOMIZE and make the Spatial Analyst and 3D Analyst toolbars visible. C). Add the RASTER (dem-grid) and POLYGON.shp polygon (Mask) data, if not added yet. To clip a grid in ArcGIS, all you need to do is set the appropriate Analysis Options and then call on the Spatial Analyst Raster Calculator. D). Choose SPATIAL ANALYST > OPTIONS. Under the GENERAL tab, set working directory as your project folder (Lab18 here) and the Analysis Mask to Mask. Under the EXTENT tab, select Same as Layer Mask as the Analysis Extent. Clock OK. 3
Other choices: Under the EXTENT tab, you can select Same as Layer RASTER as the Snap to Raster layer. This ensures that the output raster cells line up with the input cells - you may opt to ignore this or use a different layer, which may involve resampling. Under the CELL SIZE tab, you can also select Same as Layer dem-grid as the Analysis Cell Size. Click OK. E). To Clip the raster file (dem-grid), choose SPATIALANALYST > RASTER CALCULATOR. Double click on the RASTER layer dem-grid to enter it in the expression box. Click EVALUATE. If this did not work, you may need to restart your computer, start a new ArcMap and reload all files again! Close other programs and browsers that may affect the calculations. F). A Calculation layer is added to the table of content (see below). Uncheck all other layers to see the clipped raster file. 4
G). Right click on the Calculation and MAKE PERMANENT by saving with a new name; e.g. Project-Area. H). Click Yes to add the Project-Area to ArcMap. Delete the temporary Calculation layer (right-click on it > Remove). Double-click on legend of Project-Area, choose a color ramp. 5
I). Create a Hillshed file: SPATIAL ANALYSIS > Surface Analysis > Hillshede. Save output as Lab18/Project-shade. Click OK J). A Project-Shade file is created and added to the map. In the table of content, drag the Project- Shade below Project-Area. Right-click on Project-Area > Properties > Display. Set transparent value as 50 %. Click OK. K). A 3-D landscape map is produced. Now, remove dem-grid file (right-click > Remove). 6
J). You can also produce other spatial analyses (e.g. slope, contour, aspect etc.) to provide spatial data for geological and engineering assessments. See a slope map below (50% transparent). K). Save your ArcMap, then close it. 7
3. Three-dimensional (3-D) analysis in ArcScne: A). Start > Programs > ArcGIS > ArcScene B). Add Project-Area C). Go to Tools > Extensions > 3D Analyst. Create TIN10 D). Use View > Toolbars > Tools and 3D effects to view TIN10 landscape in Yosemite Valley. Use Tools (Navigate, Zoom In/Out, Zoom to target, etc.). Save ArcScene file to Lab 8
4. How to clip a multi-band image: Basically, you add each color band of the image file into ArcMap, then clip each of them using the same methods described above. 9