Filling and clipping a raster

By Aileen Buckley, Mapping Center Lead


Sometimes you want to use raster data, like a digital elevation model (DEM), but it doesn’t have the same exact extent as the area you are mapping. For example, if I use gtopo30 and “countries” data (available on the Esri Data and Maps CD) to create map of the Pacific Northwest, the coastline boundaries do not coincide. In some places the elevation values are missing for inland areas, and in other places, there are elevation values outside the extent of the land area. So we need a way to clean up the data and make them coincide. Just clipping won’t work as this won’t add the missing elevation values.

I can fix all this if I have some other elevation data to fill in the missing interior elevation values. For example, I can use etopo2 data (also on the Data and Maps CD) to get the elevation values for the pixels that need them.

Etopo2 Data

Although the etopo2 data are coarser resolution, this will be difficult to see at the scale I am mapping, especially when I further modify the data by creating a hillshade. So I can go ahead and use these data.

Note that before you decide which dataset to use to “fill in the gaps”, be sure you check out the z units – in some datasets elevation is in meters and in others it is in feet. Both gtopo30 and etopo3 use meters so there is no problem using these two datasets as they are. (The fix would be to create a new raster elevation dataset by converting one DEM to the units of the other DEM by multiplying by the appropriate conversion factor.)

Once you have the two raster elevation datasets and a polygon feature class for the area you are mapping, these are the steps to filling in the missing elevation values and clip to the land extent:

  1. Convert the polygon feature class for the land area to a raster dataset. We’ll call it “land_grid”.
  2. From the raster dataset that has the missing elevation values (in this example, we’ll call it “gtopo30”), create an IsNull raster. (Use the Is Null Tool in the ArcToolbox, Spatial Analyst Toobox, Math Toolset, Logical Toolset.) We’ll call the resulting raster dataset “gtopo_isnull”.
  3. Use a conditional statement to create a new raster dataset that adds the elevation values from the other raster dataset (we’ll call it “etopo2”) to the one with the missing values. (Essentially, this is the conditional statement: if there is an elevation value in the data set with missing values, use it; if not, use the elevation value from the other raster dataset.) We’ll call this raster dataset “gtopo30_fill”.
    con(gtopo_isnull = 1, etopo2, gtopo30)
  4. Use a conditional statement to set the extent of the resulting elevation raster dataset to the same extent as your land area. (Essentially, this is the conditional statement: if the raster dataset that you created from the polygon feature class is >= 1, then use the elevation value from the step above, otherwise, do nothing – which results in a NoData value.)
    con(land_grid >=1, gtopo30_fill)

At this point, the resulting raster dataset should 1) have all the elevation values, and 2) exactly coincide with your land extent.

Final Result

About the author

Dr. Aileen Buckley has been making maps since she was an undergraduate student. She has a Bachelors in Geography and Spanish from Valparaiso University, a Masters in Geography from Indiana University, and a Ph.D. in Geography from Oregon State University. She is a senior product engineer on the Living Atlas team, and her work focuses on determining and sharing best practices for mapping and analysis with modern GIS. She publishes and presents world-wide on many aspects of mapping and GIS. She is a co-author of Map Use: Reading, Analysis, Interpretation, and she is a co-editor for the Atlas of Oregon. Aileen is a former president of CaGIS (the U.S. cartographic association) and is actively involved with the International Cartographic Association in which she is the lead delegate for the United States.

Inline Feedbacks
View all comments

Next Article

When are expert sources right for your story?

Read this article