X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

4/24/2025

This blog was written by Eli Dwek, Emeritus, NASA Goddard Space flight Center, Greenbelt, MD and Research Fellow, Center for Astrophysics, Harvard & Smithsonian, Cambridge, MA. It is the fifth blog in a series showcasing our IDL® Fellows program which supports passionate retired IDL users who may need support to continue their work... Read More >

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

2/25/2025

This blog was written in collaboration with Adam O’Connor from Wyvern.   As hyperspectral imaging (HSI) continues to grow in importance, access to high-quality satellite data is key to unlocking new insights in environmental monitoring, agriculture, forestry, mining, security, energy infrastructure management, and more.... Read More >

Ensure Mission Success With the Deployable Tactical Analytics Kit (DTAK)

Ensure Mission Success With the Deployable Tactical Analytics Kit (DTAK)

2/11/2025

In today’s fast-evolving world, operational success hinges on real-time geospatial intelligence and data-driven decisions. Whether it’s responding to natural disasters, securing borders, or executing military operations, having the right tools to integrate and analyze data can mean the difference between success and failure.... Read More >

How the COVID-19 Lockdown Improved Air Quality in Ecuador: A Deep Dive Using Satellite Data and ENVI® Software

How the COVID-19 Lockdown Improved Air Quality in Ecuador: A Deep Dive Using Satellite Data and ENVI® Software

1/21/2025

The COVID-19 pandemic drastically altered daily life, leading to unexpected environmental changes, particularly in air quality. Ecuador, like many other countries, experienced significant shifts in pollutant concentrations due to lockdown measures. In collaboration with Geospace Solutions and Universidad de las Fuerzas Armadas ESPE,... Read More >

Rapid Wildfire Mapping in Los Angeles County

Rapid Wildfire Mapping in Los Angeles County

1/14/2025

On January 8, WorldView-3 shortwave infrared (SWIR) imagery captured the ongoing devastation of the wildfires in Los Angeles County. The data revealed the extent of the burned areas at the time of the capture, offering critical insights for rapid response and recovery. To analyze the affected region, we utilized a random forest... Read More >

1345678910Last
«May 2025»
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
23209 Rate this article:
4.3

Can I Subset an Image Using a Shapefile?

Anonym

In this article I will show how to subset an image from a polygon shapefile that has been converted to a region of interest (ROI). A typical use case is to process only the pixels that are within a geographic boundary, as the following image shows. This is not a “clip” operation but rather a masking procedure whereby the pixels outside of the shapefile boundary are set to values of NoData.

This example uses a Landsat 5 TM image and a polygon shapefile of the Lake Maurepas watershed boundary in the Mississippi River coastal delta region of Louisiana.

First, you need to create an ROI from the polygon shapefile. Follow these steps:

  1. From the ENVI menu bar, select File > New Region of Interest.
  2. In the ROI Tool menu bar, select File > Import from Vector.
  3. Select the polygon shapefile when prompted.
  4. In the Convert Vector to ROI dialog, choose All Records to a single ROI or Each record to a separate ROI, depending on how you want to export the shapefile records.
  5. From the ROI Tool menu bar, select File > Save As and save the ROI to an XML file.

 

Now you are ready to subset the image. In addition to manually defining the spatial extents of the subset, ENVI® offers other options for spatial subsetting such as Subset by Raster, Subset by Vector, and Subset by ROI. The latter two options produce a rectangular subset that is based on the geographic extents of the shapefile or ROI. The subset includes pixels that are outside of the shapefile or ROI, for example:

To create a subset that contains only data pixels inside the ROI boundary (see the example at the beginning of this article), you need to create a mask from the ROI. Follow these steps to create a mask and to subset the image by ROI:

  1. From the ENVI menu bar, select File > Save As > Save As (ENVI, NITF, TIFF, DTED).
  2. Select the image file, then click the Spatial Subset button.
  3. Click the Subset by ROI button.


     
  4. Select the ROI when prompted.
  5. In the File Selection dialog, click the Mask button.
  6. In the Mask Selection dialog, select the ROI file and click OK.


     
  7. Click OK in the File Selection dialog.
  8. Save the masked raster to a file on disk.

 

The result will look similar to the image at the beginning of this article. The white pixels are filled with NoData values. Also note that the coordinate systems differ between the Landsat image and the ROI; however, we did not need to take extra steps to reproject one dataset to the other. ENVI automatically reprojected the ROI to match the coordinate system of the Landsat image.

For more information on subsetting options and creating masks, please refer to the ENVI Help.

Acknowledgements

Landsat imagery was provided by the U.S. Geological Survey.

The Lake Maurepas shapfile was provided as part of the U.S. Watershed Boundary Dataset (WBD). The WBD is a coordinated effort between the United States Department of Agriculture-Natural Resources Conservation Service (USDA-NRCS), the United States Geological Survey (USGS), and the Environmental Protection Agency (EPA). The WBD was created from a variety of sources from each state and aggregated into a standard national layer for use in strategic planning and accountability. The WBD data for Louisiana is available from http://datagateway.nrcs.usda.gov [Accessed 02/29/2016].

1 comments on article "Can I Subset an Image Using a Shapefile?"

Avatar image

Mobit Solutions

It's amazing and looking so elegant. Tools are always there but the way to use them always differs creators. Use our seo services to promote your work.

Please login or register to post comments.