Showing results for 
Search instead for 
Do you mean 

Generate Footprint for Ortho-image (2016)

by Technical Evangelist on ‎08-15-2016 01:53 PM - edited on ‎02-24-2020 02:44 AM by Community Manager (4,072 Views)

Download model




This model takes an input image file and derives a polygon encompassing all pixels which are not "Background", effectively building a footprint for the real image data. The footprint is created as a Shapefile in the same directory as the input imagery and with the same root name, but with a user definable suffix appended to the root name. An attribute is also written into the Shapefile capturing the original filename (including path) of the input image.


 Left View shows the input ortho-rectified image, the right View shows the derived footprint polygon


The model acts as an example of using the Convert to Features operator, introduced with ERDAS IMAGINE 2016, which provides the equivalent of "Raster to Vector" functionality. The vast majority of processing and analysis which is applied in Spatial Modeler (currently) occurs in the raster domain. But you often want the "features you've identified" in that processing to be used in a vector-based GIS system and so you need them to be converted into feature-based geometries. In the past this "Raster to Vector" conversion would have to be applied outside of the Spatial Modeler environment. However with the introduction of the Convert to Features operator this can now be incorporated into your Spatial Models, including further processing of the data in the features environment (such as buffering, measurement of attributes, etc.)




The upper "branch" is the main path for generating the footprint geometry. It takes the input image, checks to see at each pixel if all of the input bands contain DN 0 and if they do treats that pixel as Background. This does assume that the input image does not have NoData set. If NoData has been set, then a pixel where any band is NoData will also be treated as Background. All non-Background pixels are then converted to DN 1. Class 1 is then converted to a polygonal feature, an attribute field called Filename is appended and populated with the full pathname of the input image, and the feature written out as a Shapefile.


Note that since this model considers Background the resulting footprint is not necessarily a rectangle - it can be an irregular shape and can contain holes.


The lower branch is what analyses the input pathname to automatically derive the output Shapefile name and location. The full input pathname is deconstructed in order to strip off the extension (and "dot"), the user-specified Suffix is appended, as is ".shp", and this full, reconstructed pathname is passed onto the Features Output operator FilenameIn port. This provides a good example to follow for models where the output file name needs to be automatically generated based on the input filename,


An alternative would have been to use the Get Containing Directory operator for part of the reconstruction process, but this way provides an interesting example of how to go about manipulating strings.



Input parameters: (indent content below)


Input Image: Name of the image from which to derive a non-background footprint polygon

Suffix: The suffix to append to the input file root name to create the name of the output Shapefile. For example, if the Input Image filename is "C:\Demo Data\Hickory_Flats\Landsat\Landsat 8\lc80190362014046lgn00-msi.img" and the Suffix is defined as _fpt, the output shapefile will be automatically generated as "C:\Demo Data\Hickory_Flats\Landsat\Landsat 8\lc80190362014046lgn00-msi_fpt.shp".



 Auto-generated dialog for Generate_Footprint-v16-0-4.gmdx



‎06-20-2017 03:52 AM - edited ‎06-20-2017 05:38 AM

Works nicely - however one challenge. Model leaves small holes inside data if there are some zeros inside true data - I did not figure out any other means than running clump-eliminate/sieve in raster base before Convert to Features function and thats pretty slow process. Any ideas on that I - did not get it by using the true/false flag in Convert to Features function though it was mentioned in documentation for this need. This should be much lighter and straighforward if done in vector base and I know in Objective Erdas Imagine has such tools.


Otherwise edits I made which was mainly flexible background value works perfectly. Also works via batch which is nice.

by Technical Evangelist
‎06-20-2017 05:28 AM - edited ‎06-20-2017 05:31 AM

Hi Timo,


Yes, that's the correct basic approach. If your image has holes in it then you want to include those in the polygon defining the "extent" of your actual image data. 


But it is absolutely the case that not everyone wants that - they just want the "outline", without holes. I.e. you want to remove island polygons. The basic way to do that right now (i.e. in ERDAS IMAGINE 2016 v16.1) is as you describe - use clump and eliminate to remove small clumps and then convert the "big clump" to a feature. If Eliminate is too slow for you then you should be able to perform a recoding of the island clumps to that of the main clump. But whether that would be succseful/possible is going to depend on the shape of the image and where it contacts the edges of the rectangular data extent.


In ERDAS IMAGINE 2018 there will be a dedicated "Remove Islands" operator for Features, which will be the better approach.


As an aside - there is no option on Convert to Features to remove islands. The only boolean port on that operator is the one where you can tell the function whether the input thematic raster stream is already clumped or not. If the input raster can already be considered to be clumped then you can speed up the Convert to Feature process by telling it that it does not need to perform that step.




on ‎06-20-2017 05:43 AM

"In ERDAS IMAGINE 2018 there will be a dedicated "Remove Islands" operator for Features, which will be the better approach."


I will be waiting for this - meanwhile this is decent solution as end users data has actually no background values inside true data and problem lies just in my development environment.


As commented flexible background value and batching works nicely after my tiny edits. In nutshell I do it in a way that I run filter that changes all defined pixel values to zeros and then continue with your original model.


Brilliant simple model and good example of possibilities you gain with new Spatial Modeller. Getting more vector functionality in future releases is a thing really needed.

by Technical Evangelist
on ‎07-07-2017 11:12 AM - last edited on ‎02-24-2020 02:46 AM by Community Manager

Hello everyone,


One of the reasons for producing these Spatial Recipes posts is so that everyone can take the models and tailor them to their specific needs (learning how to use Spatial Modeler while doing so). One of our partner companies, T-Kartor Geospatial in Finland, has done exactly that with the Generate Footprint model. They have kindly provided their modified model and some commentary on the approach. Two main things they wanted to add was support for the potential for a single image file having more than a single "footprint" polygon (are they then toe-prints?) and differing background values (such as the use of 255 as the background in aerial imagery). Here's a quick screenshot of the model:




And the commentary (slightly modified by me):


"Here is an improved version. I moved clump parameter from true to false, which then allows multiple polygons to be created [but note that it will increase the processing time]. Then to make it work I dropped out your automatic file ending thing and now I simply feed input and output.


Another difference to your original model is that I am feeding MIN & MAX for the true data range. So I feed in a range that is allowed for real data and everything else is converted to background zero. This was needed because client used 255 as a background value while your model assumed background to be always zero.


Use as you like but I think is now bit more capable in basic things compared original. What it does in nutshell is that it takes in raster and outputs its outline as a shapefile following the image edges. So sort of active area calculation. It fails if there are no data pixels inside true data and that generates a hole in polygon. That is waiting 2018 release and island filter function there. Running Island filter with some fairly small size would work that out. As well as some generalization could be added in function. Now the shapes are fairly big – to be as a shapefile."


The modified model can be downloaded here.


Thanks T-Kartor!



by Technical Evangelist
on ‎07-17-2018 05:48 AM

The  "Remove Islands" operator for Features mentioned above is actually called Eliminate Unwanted Areas (available in ERDAS IMAGINE 2018 or later), but has all the necessary capabilities to remove "holes" in the footprint polygon.