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!



Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

6/3/2025

Rethinking the Reliability of Type 1a Supernovae   How do astronomers measure the universe? It all starts with distance. From gauging the size of a galaxy to calculating how fast the universe is expanding, measuring cosmic distances is essential to understanding everything in the sky. For nearby stars, astronomers use... Read More >

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

5/26/2025

Whether you’re new to remote sensing or a seasoned expert, there is no doubt that large language models (LLMs) like OpenAI’s ChatGPT or Google’s Gemini can be incredibly useful in many aspects of research. From exploring the electromagnetic spectrum to creating object detection models using the latest deep learning... Read More >

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

4/28/2025

When every second counts, the ability to process geospatial data rapidly and accurately isn’t just helpful, it’s critical. Geospatial Intelligence (GEOINT) has always played a pivotal role in defense, security, and disaster response. But in high-tempo operations, traditional workflows are no longer fast enough. Analysts are... Read More >

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 >

1345678910Last
23425 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.