home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


reclassify.sml


clear();
#
# reclassify.sml
#
# This script is written to reclassify cell values in the user-entered input raster.
# Reclassification is based on meeting certain criteria for class (value) and area.
# For modification purposes, the variables used for this purpose are "threshold",
# "oldValue", "and newValue".
# Currently it is set to reclassify all areas of <5 acres in class '128' to class '0'.
#

class RASTER Rin;
class RASTER Result;
class STATUSDIALOG statusdialog;
class STATUSCONTEXT statuscontext;

# create the 5 acre threshold
numeric thresholdAcres = 5;

numeric oldValue = 128, newValue = 0;

# Get the input and output rasters.
GetInputRaster(Rin);
IgnoreNull(Rin);
GetOutputRaster(Result, NumLins(Rin), NumCols(Rin), RastType(Rin));
IgnoreNull(Result);

# Copy all cell values
printf("Copying source raster\n");
Result = Rin;

# Get the georeference info
CopySubobjects(Rin, Result);	# get colormap, contrast, georef, etc.

# Convert the threshold from Acres to cells
numeric threshold = thresholdAcres * 4046.85642 / (LinScale(Rin) * ColScale(Rin));

printf("Eliminating solid features less than or equal to %g acres (%d cells)\n", thresholdAcres, threshold);

numeric lin, col, r, up, left, count;

foreach Result[lin, col] {
	r = Result[lin,col];
	if (r == oldValue) {
		up = -1;
		left = -1;
		if (col > 1) left = Result[lin, col-1];
		if (lin > 1) up = Result[lin-1, col];

		#printf("R[%d,%d] = %d,  Cell to the left = %d, Cell above = %d\n", lin, col, r, left, up);

		if (left != oldValue && up != oldValue) {
			#printf("Checking at %d,%d\n", lin, col);
			count = RasterGetSolidAreaSize(Result, lin, col, threshold+1);
			if (count <= threshold) {
				#printf("Filling at %d,%d - count = %d\n", lin, col, count);
				RasterFloodFill(Result, lin, col, newValue);
				}
			}
		}
	}

CreateHistogram(Result);
CreatePyramid(Result);




Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11