Advanced Examples

Add function via TNTsdk: Finds a numeric text position inside a string using an SML function added via instr.c (TNTsdk). Parses text file and fills matrix. inputmat.sml
inputmat.zip
Calibrate Landsat: Automates the complex sequence of processing steps required to adjust a time-series of Landsat scenes to a common quantitative scale for use in monitoring change in surface conditions. LandsatCalibrationPilot.sml
TechGuideCalibrate Multitemporal Landsat Scenes via SML
Catchment Analysis: Copies the catchment polygons vector object and adds a table that records the summed areas and percentages of each geologic map unit for each catchment. Used to relate results of the SampleCatchments script to a geologic map vector object. GeolUnitArea.sml
TechGuideCatchment Analysis for Locating Ore Deposits
Catchments & Map Unit Areas: Relates the results of the Sample Catchments script to a geologic, soil, or other vector object containing map unit polygons. For each catchment the script tabulates the area and percent area of each intersecting map unit. These values are written to tables attached to copies of the original catchment polygon vector and sample point vector object. This generalized version of the GeolUnitArea script automatically compiles a list of unique map units from the selected vector object and tabulates areas for all units or optionally for a single target unit. MapUnitAreas.sml
TechGuideCompute Map Unit Areas for Catchments
DOQQ Assembly: Automated assembly of Digital Ortho photos. doqq7.sml
Export COLLADA: Automates the export of one or more manifold 3D cross-section objects to a KMZ file. This allows the section or sections to be viewed immediately in 3D in Google Earth in their correct geographic positions and orientations. The sample SML script creates a COLLADA file and corresponding PNG image file for each selected cross-section, creates the KML file that positions these models, and packages all of these products in a single KMZ file (ZIP file with a .kmz file extension) for easy use in Google Earth.

Two versions of the cross-section export script are available. They differ in the method used to animate the cross-sections and limit use of the exported KMZ file to specific Google Earth versions.
ExportMultiSectColladaKMZ.sml
ExportMultiSectColladaKMZtrack.sml
ExportMultiSectColladaKMZ.zip
TechGuideExport 3D Cross-Sections to Google Earth
Export COLLADA Terrain: Creates a custom terrain surface and matching image overlay that can be viewed in 3D in Google Earth. The inputs are a DEM (Digital Elevation Model) raster and an overlapping IMAGE raster. The extents of the DEM and IMAGE do not have to match exactly, as the script automatically crops them to their common extents if necessary. These inputs also can have different coordinate reference systems.

The surface and image texture are output as a COLLADA model packaged in a KMZ file (compressed KML). The COLLADA model is referenced as a placemark in the KML file stored within the KMZ. The placemark includes the WGS84 Geographic coordinates of the origin (center point) of the model, its height in meters above sea level, and its orientation (angle to north). This placemark information allows Google Earth to correctly locate and orient the terrain model in 3D space.

The COLLADA model specifies a triangular mesh defining the custom 3D terrain derived from the DEM and a mapping to corresponding normalized image coordinates to allow the image (exported as a JPEG, PNG, or TIFF file) to be overlaid as a texture onto the triangular mesh in Google Earth. The triangular mesh coordinates are read from a TIN created from the DEM. The COLLADA model has projected coordinates derived from the coordinate reference system of the IMAGE (unless it has a non-projected CRS, in which case a location-appropriate UTM CRS is created and used).

The custom script dialog provides interactive selection of the input DEM and IMAGE and the output KMZ file. The elevation units for the DEM (meters or feet) must be correctly specified to provide proper vertical scaling for the model. A vertical offset of the model above the Google Earth terrain surface can be set to avoid intersection of the model and the Google Earth terrain (portions of the model below the Google Earth terrain are not visible).

Note that models with image overlays larger than about 1024 by 1024 cells may load very slowly in Google Earth and degrade its performance.
ExportTerrainCollada.sml
ExportTerrainCollada.zip
File Extract: Get JPEG Image's EXIF header and output to text file of same name in same directory. GetEXIF.sml
Fill Nulls: Fills the no-data cells in the DEMs produced from the Radar data acquired by the Shuttle Radar Topography Mission (SRTM). SRTMfill.sml
TechGuidePatch Holes in SRTM DEMs
Focal Mean: Write result of focal mean operation for a raster cell chosen from a vector point. focalmean.sml
Focal Mean: Calculates focal mean around a point in a raster layer corresponding to a point in a vector layer. For example, extract maximum points from an elevation raster then use the resulting vector points and the original raster. vecfocal.sml
vecfocal.zip
GeoMashup: Automated, regularly-scheduled geomashup application that downloads updated geospatial data from the Internet, processes and combines the data with other geospatial data, and posts the result on a web page for viewing in the Google Earth browser plug-in. The source geospatial data for this demonstration are global earthquake epicenter locations and associated attributes posted and continuously updated by the U.S. Geological Survey. The key component of the application is a custom SML script that is run hourly by the TNTmips Pro Job Processing System. This script downloads the earthquake data, extracts the data for the desired area, sets up styles and DataTips, and renders the result to a KML file that is referenced by a web page that loads this file in the Google Earth browser plug-in. This sample script, associated reference data, and the sample web page are available for download in a Zip archive. canvquakes.sml
canvquakes.zip
TechGuideAutomatically Update Geomashup using SML and Job Processing
TechGuideBuilding Dynamic Web Geomashups
Geotag Image Database: Gets the date and time each picture was taken from the EXIF header and compares them with the GPS log to assign geographic coordinates for the image. User chooses whether to interpolate coordinates based on image time or use closest GPS coordinates. Each image location is added as a point to the user-selected vector object. A table with Date, Time, Lat, Lon, Elev and Path fields is stored in Point Database for the vector, with each record attached to a vector point.

The vector may be displayed in a Layout group for hyperlinking the images by selecting File by Attribute and choosing the image path in the table.
GPSphoto2.sml
GPSphoto.sml
GPS Data Logging: For use in the field with TNTatlas to document sources of potential environmental problems along stream channels. For use with or without a GPS. Data and script are combined in the same file. datalogExtract.sml
datalog.sml
datalogExtract.zip
Line Profile: This script takes file input in the format of given by the Geotoolbox's Measurement recording feature. From this file it uses the 'measurement ID' (a line number) and Start and End point coordinates. The two points define a line along which DEM sample values will be taken. The sample rate is defined according to the Lin/Col Scale of the raster.

The results including the Cross-Section Name, Easting, Northing, Cumulative Distance, and DEM Z-Value are written to a user-selected file. Additional results (for other lines) are concatenated to the end of the file.
measurementProfile.sml
measurementProfile.zip
Network Analysis: Uses network analysis on a road network (lines in vector Roads) to find short route between farm gates (points in vector Farms) and processing plants (points in vector Plants). Farm gate and plant points do not fall exactly on road lines. Input vectors for Roads and Farms are copied to a selected output file for modification.

For each farm gate point, the script adds a node at the closest point on the closest road line and keeps track of these nodes in an array that associates them with the correct farm. A new table for nodes in the Road vector also records the farm number for each added nodes Nodes are similarly added and attributed for each of the processing plants. The shortest distance between each farm and processing plant is then calculated using network analysis functions. The script adds two new tables to the point database of the Farms vector: one with records attached to each point that list the distance to each of the processing plants and another that provides the geographic coordinates of each processing plant in the same coordinate system used by the Farms object.
NETWORK1.sml
network.sml
NETWORK1.zip
TechGuideFarm to Market Routing
Profile & Curvature: Creates profile and plan curvature rasters from an input DEM using local best-fit mathematical surfaces. surfcurv.sml
TechGuideTerrain Curvature
Raster Intervals: Categorize a grayscale raster into a specified number of grayscale-value intervals. The number of intervals and the distribution type (equal count or equal interval) can be specified. Separate dialogs are provided to set input parameters, view and edit the range values, and to preview the result. Script makes a categorical raster with a single value for each interval and a color palette. RasterIntervals.sml
TechGuideTheme Mapping a Raster
RGB Cells to White: Process scanned topographic maps (24-bit color composite rasters in RVC format) to set near-white cells to white (255,255,255) ThresholdNearWhite.sml
Run External Program — FRAGSTATS: Takes an input raster and a mask raster, and uses the mask to create a raster usable by fragstats. It writes the output raster to a text file and calls fragstats using a set of default parameters after querying the user for the edge distance value.

The input raster must be an an integer-value, single raster with square cells. Later versions may support more formats. The mask raster must have exterior background areas marked -1, interior background areas marked 1, and landscape areas marked 0.

This script requires the fragstats executable which is installed in the TNT mips win32 directory and that the temporary folder path specified by mips have folder names no greater than 8 characters long or have spaces in them.
fragstat.sml
Stream Catchments: Process multiple vector points representing stream or stream sediment samples to compute the upstream catchment (basin) area that drains to each point. SampleCatchments.sml
TechGuideMapping Catchment Areas for Sample Points
Suppressing Vegetation: Suppress the expression of vegetation in multispectral images for geological and soil mapping applications. deveg68.sml
TechGuideNested SML Dialogs using XML
TechGuideSuppressing Vegetation in Multispectral Images
Surface Fitting: Surface-fitting process of contour lines using morphological functions as described in the paper An Image Space Algorithm for Morphological Contour Interpolation by Barrett, Mortensen and Taylor. MorphContour.sml
TechGuideContours to DEM via Morphological Interpolation
Surface Fitting: Surface fitting on a set of attribute values attached to vector points that represent an array of soil sample locations. Values are read from a attached database table. SOILTEST.sml
SOILTEST.zip
TIGER Attributes: For vector object containing Voting Districts extracted from1990 Census TIGER / Line files (which lack polygon attributes). Checks line attributes in the Geo_Area_Codes tableto find and verify voting district codes (string) for each polygon and writes the result into the polygon Districts table. votdist.sml
votdist.zip
TIGER Cities: Extract TIGER city polygons tiger.sml
TIGER1.sml
Viewshed: Computes binary viewshed raster from elevation raster input and vector object containing lines. Computes viewshed for all vertices on all lines of a corresponding Vector object Could use to get viewshed for all points on one or more roads. VIEWSHED.sml
VIEWSHED.zip

Movies

movie.sml: Make movie. movie.sml
open_avi.sml: Play movie. open_avi.sml
ORBITSP.sml: Demonstration of movie generation from 3D display using spiral orbit path. Both 2D and 3D views are copied into each movie frame. ORBITSP.sml
orbitsp.avi
orbitsp.zip
PAN1.sml: Demonstration of movie generation from 3D display with viewer position fixed and view point (view center) rotating around the viewer to produce a panning view. Both 2D and 3D views are copied into each movie frame. Current viewer position and view center positions are shown by symbols in each 2D frame. PAN1.sml
pan.mpg
PAN1.zip
PATHcALT.sml: Demonstration of movie generation from 3D display using 2D vector objects to derive viewer position (flight) path and path of view center. PATHcALT.sml
pathcalt.avi
PATHcALT.zip
PATHcHT1.sml PATHcHT1.sml
pathcht1.avi
PATHcHT1.zip
TechGuideMovie Generation Scripts
PATHcHT2.sml PATHcHT2.sml
pathcht2.avi
PATHcHT2.zip
VSHEDMOV.sml VSHEDMOV.sml
vshedmov.avi
VSHEDMOV.zip

Precision Farming    Download File:  PrecisionFarming.zip

Biomass: Interactive script to map biomass for a field selected in a large image. User navigates to an agricultural field and draw its boundaries and gives a 3D viewing option. biomass2Extract.sml
biomass.sml
biomass2.sml
biomass2Extract.zip
COM Port: Open the COM port with the planter control unit on it and write planting rate to it. planter2.sml
planter.sml

Visual Basic    Download File:  VB.zip

Import an OLE class, creating an SML class for a Crystal Report form: Creates a Crystal Report from TNTmips internal database records. cb_report.sml
TechGuideCreate Crystal Reports with SML
Import OLE class to an SML class for a Visual Basic form: Allows user to select and highlight a vector polygon representing a parcel. Script opens a Visual Basic form showing the parcel ID from the selected polygon. User enters Last Name and First Name in the Visual Basic form and the database is updated. ParcelToolModal.sml
ParcelToolModeless.sml
VBDEMO.zip
Visual Basic Dialog: Custom dialog window constructed using Visual Basic and registered as a Windows ActiveX component class ParcelToolVB.sml
TechGuideCommunicate with Visual Basic Programs using SML
Windows ActiveX component class written in Visual Basic: Creates a pan-sharpened color-composite image from input Red, Green, Blue, and Panchromatic raster objects. In order to run the script, download and unzip the VB_PanSharp.zip file and run the Setup program in the Package subdirectory. This installs and registers the ActiveX component in your Windows OS. The SML script imports the Vbform class defined by this ActiveX program.

This script is derived from the PanSharpComp SML script that is distributed as a sample with the Building Dialogs in SML tutorial.
VB_PanSharp.sml
VB_PanSharp.zip
TechGuideBuild SML Dialogs Using Visual Basic

Writing Scripts with SML

DEBUG Mode: Use preprocessor commands to define a DEBUG mode for use during script development. This script computes a binary viewshed raster from elevation Raster input. DEBUG.sml