Hexagon Geospatial
MENU

Spatial Modeler Tutorials

Learn more about our products, find answers, get the latest updates, and connect with other Hexagon Geospatial product users, or get support from our professional service team.
Showing results for 
Search instead for 
Do you mean 

NoData-Minimizing Automatic Subset

by Technical Evangelist on ‎02-19-2019 10:56 AM - edited 2 weeks ago (341 Views)

Download model

Description:

Sometimes the data which occupies a raster you produce may be sparse. For example, if performing anomaly detection or feature extraction, the class pixels may only occupy a very limited set of locations in the image, but the extent of the image is still set to that of the original image being analysed. The remainder of the image may be filled with NoData (or a DN value, such as 0, representing "background"). If lossless compression is being used these superfluous pixels may not cause additional diskspace to be consumed, but the larger than necessary extent may cause issues when further processing combines this data with other data layers.

 

So it's useful to calculate a new boundary extent which minimizes the extent of the NoData. To phrase it differently. the minimum bounding box of the "real" data extent is calculated and used to clip the data to the most efficient extent that preserves the information present in the image. 

 

Consider this image:

 

MinimizeNoData.png

 

The outer blue rectangle represents the extent of the image. The black pixels are NoData. So we really only want an image whose extent is the yellow rectangle. The NoData pixels beyond the yellow extent can be discarded.

 

For a single input image it would be relatively easy to manually draw a box to subset the data to the desired extent. However if we have numerous input images to be clipped in this manner we want an automated way to calculate the necessary boundary.

 

Hence the following Spatial Model

 

nodata_minimizing_subset_v16_5_1.gmdx
MinimizeNoData_Model.PNG

  

Data Requirements and Assumptions

  • Input image should be a single band Thematic dataset. If you want to do something similar for multispectral imagery I'd suggest using a Stack Sum operator to build the NoData mask if your input data doesn't already have one. 
  • The Input image is assumed to not have NoData set in it, so there is a Port Input to define the value to consider as NoData locations. The default is 0.
  • The same value will be used to define Value-based NoData in the output trimmed image (if supported by the output file format).

Results

The screenshot below shows the input image on the left having a large collar of superfluous background around the valid class values. The image on the right shows the automatically generated and clipped data extent of the output of the provided spatial model. Note that for both images NoData was replaced with a valid DN value of 0 (and an opaque color of Black) so that the data extent was visible against a View background that was set to Red. 

 
MinimizeNoData_Result.png

 

 

 

Courses
Contributors