Cropping Georeferences Raster Data

 

Since the iPAQs arenÕt the quickest machines on the planet, it is sometimes desirable to clip out certain portions of large raster datasets for MrSID compression before loading the raster data on the iPAQs.  At the moment, there does not appear to be any way to clip raster datasets using ArcGIS, so these instructions are for ArcInfo Workstation 8.2.  ArcInfo Workstation is not compatible with MrSID files, so if you have a previously compressed file that you wish to clip, you will either have to accept that it isnÕt going to happen, or go back to the original dataset, clip it, and then recompress.  Sorry.

 

p.s.  This set of instructions assumes that the image you wish to clip is georeferenced. (If it is a .tif image, there is an accompanying .tfw file).  If this is not the case, it may be easier to crop the image first using a graphics program such as Photoshop, then georeference the image. See georeferencing raster data for information on georeferencing.

 

 

ArcInfo Workstation and raster data

 

ArcInfo Workstation works only with raster data in the ESRI proprietary GRID format.  Fortunately, ArcInfo can import most types of image data into GRID format.  Go to Start > Programs > ArcGIS > ArcInfo Workstation > Arc.  A command line dialog box will appear.  At the Arc: prompt type Ôimage gridÕ (typing any command explains the usage of that command).  You will see Ð

 

Arc: imagegrid

Usage: IMAGEGRID <in_image> <out_grid | out_stack> {out_colormap_file} {in_band}{NEAREST | BILINEAR | CUBIC} {DEFAULT | SQUARE}

 

Where IMAGEGRID is the command, variables contained in <> are required, and those contained in {} are optional.  To skip certain optional variables while filling in later ones, each unspecified variable must be held with a Ô#Õ.  For example, if I want to import the image example.tif to the GRID examplegrd, without specifying out_color_map or in_band, but specifying BILINEAR interpolation, I would type:

 

Arc: imagegrid example.tif examplegrd # # bilinear #

 

Now there is a GRID called examplegrd that is a representation of the original example.tif image. (Note, bilinear interpolation is very time consuming.  In general, nearest (neighbor) is fine).  The path taken from here to clip images depends on whether the image is either a) grayscale or indexed, or b) multi-band.  To learn more about these types of raster data, look here.

 

Grayscale and Indexed Color Images

 

Grayscale and indexed color images are the easiest types of images to crop.  Once the image is imported into grid format, display the image in Grid.  WeÕll continue to assume that the imported grayscale or indexed color image is called examplegrd, and, for the indexed color example, that the image has an associated color look-up table called examplegrd.lut.

 

Arc: display 9999 1

Arc: grid

Grid: mape examplegrd

 

Now we can ask Arc to draw the grid.  For a grayscale image:

 

Grid: image examplegrd

 

For an indexed color image:

 

Grid: gridpaint examplegrd value identity nowrap examplegrd.lut

 

This will draw the image in the graphics window.  Using the Pan and Zoom tools at the upper left corner of the graphics window, you can zoom in to the area of the image that you wish to crop.  Each pan or zoom will create a new window, and each time a new window is created, you will need to issue the appropriate draw command again, as above.  In Arc, Ô^<letter>Õ issues the last command that begins with a specific letter, so Ô^gÕ would reissue the entire gridpaint command without retyping it, saving some work and effort.

 

When you have zoomed to the area you wish to clip, you can enter an interactive clipping mode:

 

Grid: gridclip examplegrd clippedgrd *

 

Where the Ô*Õ indicates that you will interactively define the clip region.  Now a new cursor will appear when you place the mouse over the graphics window.  Click the upper left and lower right corners of the clip region, and a new grid, clippedgrd, will be created.

 

To export the clippedgrd back to a tiff image, do the following:

 

Grid: q

Arc: gridimage clippedgrd # clippedgrd.tif tiff #

 

Although this clipped grid will have a .tfw world file, it will not contain all necessary projection information.  Run the ProjectDefine Wizard for grids and coverages in the ArcToolbox to update the coordinate system for this new image.  Then it is clipped and ready to be added to the ArcGIS map.

 

 

Multi-band Color Images

 

Actually, there are three GRIDs, one for each color in the RGB TIFF file, examplegrdc1 (red), examplegrdc2 (blue) and examplegrdc3 (green).  These three GRIDs can be collectively called using a stack, which is a collection of GRIDs.  The imagegrid automatically creates a stack called examplegrd to refer to all three pieces.

 

Now we must create a clip region to clip the grids.

 

Arc: create exampleclip examplegrdc1

 

This creates a vector coverage called exampleclip with the same projection and tics and examplegrdc1.

 

Arc: build exampleclip poly

 

This add polygons attributes to the coverage exampleclip.  Now we will run a series of commands in ArcEdit to prepare to draw the clip region.  If you are interested in the details of these commands, see the Arc manuals or ArcDoc for help.

 

Arc: display 9999 1

Arc: ae

Arcedit: mape exampleclip

Arcedit: image examplegrd composite 1 2 3

Arcedit: ec exampleclip

Arcedit: ef poly

Arcedit: de poly

Arcedit: draw

 

Now you should see a display window containing the GRID image that you imported.  You can use the controls at the upper left of the display window to Pan and Zoom to the region that you would like to clip.

 

Arcedit: add

 

A cursor will appear when you highlight the display window.  Click the 4 corners of the box you wish to clip (or draw an irregular polygon).  After clicking all of the corners, with the mouse still in the display window, hit the Ô2Õ key on the keyboard, then the Ô9Õ key.  Return to the command line window.  It should say that one polygon has been added.

 

Arcedit: save

Arcedit: q

Arc: build exampleclip poly

 

Now we will use the polygon that was just created to clip the GRID.

 

Arc: grid

Grid: gridclip examplegrdc1 clipc1 cover exampleclip

Grid: gridclip examplegrdc2 clipc2 cover exampleclip

Grid: gridclip examplegrdc3 clipc3 cover exampleclip

Grid makestack clip list clipc1 clipc2 clipc3

 

Now we have three new clipped grids, referred to collectively as clip.  We can export these clipped GRIDs back to a tif file.

 

Grid: q

Arc: gridimage clip # clip.tif tiff #

 

Although this clipped grid will have a .tfw world file, it will not contain all necessary projection information.  Run the ProjectDefine Wizard for grids and coverages in the ArcToolbox to update the coordinate system for this new image.  Then it is clipped and ready to be added to the ArcGIS map.