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


rcelltovpointgeoref.sml


# SML created 10 Jan 2003 by Dan Glasser and Toshi Waza
# For each raster cell in the input raster,
# it creates a point in the output (3D) vector.
# The raster cell value is stored as the z-value
# The vector is then georeferenced to match the raster.

# Updated 25 October 2006 by Dave Breitwisch

class RASTER R;
GetInputRaster(R);

class GEOREF geoOrg = GetLastUsedGeorefObject(R);
if (!geoOrg) {
	PopupMessage("This raster does not have a default georeference");
	Exit();
}

class REGION2D extents = GetObjectExtentsRegion(R, geoOrg);

# Get the 3D output vector that we will add the points to
class VECTOR V;
GetOutputVector(V, "VectorToolkit, 3DVector", extents.Extents);

# Loop through each cell in the raster, 
# getting the cell value and adding points.
numeric row, col;
foreach R[row, col]
{
	# Get the cell value
	numeric cellVal = R[row, col];
	VectorAddPoint(V, col, -row, cellVal);
}

numeric cols=NumCols(R);
numeric lins=NumLins(R);

numeric xUL, yUL, xUR, yUR, xLL, yLL, xLR, yLR;
ObjectToMap(R, 1.5, 1.5, geoOrg, xUL, yUL);
ObjectToMap(R, cols+0.5, 1.5, geoOrg, xUR, yUR);
ObjectToMap(R, 1.5, lins+0.5, geoOrg, xLL, yLL);
ObjectToMap(R, cols+0.5, lins+0.5, geoOrg, xLR, yLR);

# Set number of control points
numeric numpoints = 4;
array numeric xsrc[numpoints], ysrc[numpoints], zsrc[numpoints];
array numeric xdest[numpoints], ydest[numpoints], zdest[numpoints];

# Control point 1 - upper left corner
xsrc[1] = 1;
ysrc[1] = -1;
zsrc[1] = 0;
xdest[1] = xUL;
ydest[1] = yUL;
zdest[1] = 0;

# Control point 2 - lower right corner
xsrc[2] = cols;
ysrc[2] = -lins;
zsrc[2] = 0;
xdest[2] = xLR;
ydest[2] = yLR;
zdest[2] = 0;

# Control point 3 - upper right corner
xsrc[3] = cols;
ysrc[3] = -1;
zsrc[3] = 0;
xdest[3] = xUR;
ydest[3] = yUR;
zdest[3] = 0;

# Control point 4 - lower left corner
xsrc[4] = 1;
ysrc[4] = -lins;
zsrc[4] = 0;
xdest[4] = xLL;
ydest[4] = yLL;
zdest[4] = 0;

# Now create the georef without dialog
class GEOREF geoNew = CreateControlPointGeorefFromGeoref(V, geoOrg, numpoints, xsrc, ysrc, zsrc, xdest, ydest, zdest);

GeorefFree(geoOrg);
GeorefFree(geoNew);
CloseVector(V);
CloseRaster(R);


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