vtdata library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vtElevationGrid Class Reference
Inheritance diagram for vtElevationGrid:
Inheritance graph
[legend]

Public Member Functions

 vtElevationGrid ()
 
 vtElevationGrid (const vtElevationGrid &rhs)
 
 vtElevationGrid (const DRECT &area, const IPoint2 &size, bool bFloat, const vtCRS &proj)
 
virtual ~vtElevationGrid ()
 
vtElevationGridoperator= (const vtElevationGrid &rhs)
 
bool CopyFrom (const vtElevationGrid &rhs)
 
bool CopyHeaderFrom (const vtElevationGrid &rhs)
 
bool CopyDataFrom (const vtElevationGrid &rhs)
 
bool Create (const DRECT &area, const IPoint2 &size, bool bFloat, const vtCRS &proj, vtElevError *err=NULL)
 
void FreeData ()
 
void Clear ()
 
void Invalidate ()
 
bool ConvertProjection (vtElevationGrid *pOld, const vtCRS &NewProj, float bUpgradeToFloat, bool progress_callback(int)=NULL, vtElevError *err=NULL)
 
bool ReprojectExtents (const vtCRS &proj_new)
 
void Scale (float fScale, bool bDirect, bool bRecomputeExtents=true)
 
void VertOffset (float fAmount)
 
void ComputeHeightExtents ()
 
void Offset (const DPoint2 &delta)
 
int ReplaceValue (float value1, float value2)
 
bool FillGaps (DRECT *area=NULL, bool progress_callback(int)=NULL)
 
bool FillGapsSmooth (DRECT *area=NULL, bool progress_callback(int)=NULL)
 
int FillGapsByRegionGrowing (int radius_start=2, int radius_stop=5, bool progress_callback(int)=NULL)
 
int FillGapsByRegionGrowing (int radius, bool progress_callback(int)=NULL)
 
bool LoadFromFile (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL)
 
bool LoadFrom3TX (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromASC (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromDEM (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL)
 
bool LoadFromTerragen (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromDTED (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromGTOPO30 (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromGLOBE (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromGRD (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromDSAA (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromPGM (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromRAW (const char *szFileName, int width, int height, int bytes_per_element, float vertical_units, bool bBigEndian, bool progress_callback(int))
 
bool LoadFromMicroDEM (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromXYZ (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromXYZ (FILE *fp, const char *format, bool progress_callback(int)=NULL)
 
bool LoadFromHGT (const char *szFileName, bool progress_callback(int)=NULL)
 
bool LoadFromBT (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL)
 
bool LoadBTHeader (const char *szFileName, vtElevError *err=NULL)
 
bool LoadBTData (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL)
 
bool LoadWithGDAL (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL)
 
bool LoadFromNTF5 (const char *szFileName, bool progress_callback(int)=NULL)
 
bool SaveTo3TX (const char *szFileName, bool progress_callback(int)=NULL) const
 
bool SaveToGeoTIFF (const char *szFileName) const
 
bool SaveToTerragen (const char *szFileName) const
 
bool SaveToBT (const char *szFileName, bool progress_callback(int)=NULL, bool bGZip=false)
 
bool SaveToSTM (const char *szFileName, bool progress_callback(int)=NULL)
 
bool SaveToPlanet (const char *szDirName, bool progress_callback(int)=NULL)
 
bool SaveToASC (const char *szFileName, bool progress_callback(int)=NULL) const
 
bool SaveToVRML (const char *szFileName, bool progress_callback(int)=NULL) const
 
bool SaveToXYZ (const char *szFileName, bool progress_callback(int)=NULL) const
 
bool SaveToRAWINF (const char *szFileName, bool progress_callback(int)=NULL) const
 
bool SaveToRAW_Unity (const char *szFileName, bool progress_callback(int)=NULL) const
 
bool SaveToPNG16 (const char *fname)
 
void SetFValue (int i, int j, float value)
 
void SetValue (int i, int j, short value)
 
short GetShortValue (int i, int j) const
 
float GetFValue (int i, int j) const
 
float GetFValueSafe (int i, int j) const
 
float GetClosestValue (const DPoint2 &p) const
 
float GetFilteredValue (const DPoint2 &p) const
 
const char * GetDEMName ()
 
DRECT GetAreaExtents () const
 
bool IsFloatMode () const
 
void FillWithSingleValue (float fValue)
 
void GetEarthPoint (int i, int j, DPoint2 &p) const
 
void GetEarthLocation (int i, int j, DPoint3 &loc) const
 
vtCRSGetCRS ()
 
const vtCRSGetProjection () const
 
void SetProjection (const vtCRS &proj)
 
bool GetCorners (DLine2 &line, bool bGeo) const
 
void SetCorners (const DLine2 &line)
 
short * GetData ()
 
float * GetFloatData ()
 
const short * GetData () const
 
const float * GetFloatData () const
 
void SetScale (float sc)
 
float GetScale () const
 
bool HasData () const
 
int MemoryNeededToLoad () const
 
int MemoryUsed () const
 
bool FindAltitudeOnEarth (const DPoint2 &p, float &fAltitude, bool bTrue=false) const
 
virtual float GetElevation (int iX, int iZ, bool bTrue=false) const
 
virtual void GetWorldLocation (int i, int j, FPoint3 &loc, bool bTrue=false) const
 
void SetupLocalCS (float fVerticalExag=1.0f)
 
float GetWorldValue (int i, int j, bool bTrue=false) const
 
bool FindAltitudeAtPoint (const FPoint3 &p3, float &fAltitude, bool bTrue=false, int iCultureFlags=0, FPoint3 *vNormal=NULL) const
 
- Public Member Functions inherited from vtHeightFieldGrid3d
void Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight, int cols, int rows)
 
virtual void SetEarthExtents (const DRECT &ext)
 
bool CastRayToSurface (const FPoint3 &point, const FPoint3 &dir, FPoint3 &result) const
 
bool LineOfSight (const FPoint3 &point1, const FPoint3 &point2) const
 
const DPoint2GetSpacing () const
 
const FPoint2GetWorldSpacing () const
 
void GetDimensions (int &nColumns, int &nRows) const
 
const IPoint2GetDimensions () const
 
int NumColumns () const
 
int NumRows () const
 
void EarthToGrid (const DPoint2 &epos, IPoint2 &ipos)
 
void WorldToGrid (const FPoint3 &pos, IPoint2 &ipos)
 
float GetInterpolatedElevation (double findex_x, double findex_y, bool bTrue=false) const
 
int FindNumUnknown ()
 
bool ColorDibFromElevation (vtBitmapBase *pBM, ColorMap *cmap, int iGranularity, const RGBAi &nodata, bool progress_callback(int)=NULL) const
 
bool ColorDibFromTable (vtBitmapBase *pBM, const ColorMap *color_map, const RGBAi &nodata, bool progress_callback(int)=NULL) const
 
void ShadeDibFromElevation (vtBitmapBase *pBM, const FPoint3 &light_dir, float fLightFactor, float fAmbient=0.1f, float fGamma=1.0f, bool bTrue=false, bool progress_callback(int)=NULL) const
 
void ShadeQuick (vtBitmapBase *pBM, float light_factor, bool bTrue=false, bool progress_callback(int)=NULL)
 
void ShadowCastDib (vtBitmapBase *pBM, const FPoint3 &ight_dir, float fLightFactor, float fAmbient, bool progress_callback(int)=NULL) const
 
- Public Member Functions inherited from vtHeightField3d
void Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight)
 
int PointIsAboveTerrain (const FPoint3 &p) const
 
bool ConvertEarthToSurfacePoint (const DPoint2 &epos, FPoint3 &p3, int iCultureFlags=0, bool bTrue=false) const
 
bool ContainsWorldPoint (float x, float z) const
 
void GetCenter (FPoint3 &center) const
 
void SetCulture (CultureExtension *ext)
 
float LineOnSurface (const DLine2 &line, float fSpacing, float fOffset, bool bInterp, bool bCurve, bool bTrue, FLine3 &output)
 
- Public Member Functions inherited from vtHeightField
void Initialize (const DRECT &extents, float fMinHeight, float fMaxHeight)
 
bool ContainsEarthPoint (const DPoint2 &p, bool bInclusive=false) const
 
DRECTGetEarthExtents ()
 
const DRECTGetEarthExtents () const
 
void GetHeightExtents (float &fMinHeight, float &fMaxHeight) const
 

Protected Member Functions

void SetupMembers ()
 
void ComputeExtentsFromCorners ()
 
void ComputeCornersFromExtents ()
 
bool ParseNTF5 (GDALDataset *pDatasource, vtString &msg, bool progress_callback(int))
 
bool GetXYZLine (const char *buf, const char *pattern, const char *format, int components, double *x, double *y, double *z)
 
void SetError (vtElevError *err, vtElevError::ErrorType type, const char *szFormat,...)
 
bool AllocateGrid (vtElevError *err=NULL)
 
- Protected Member Functions inherited from vtHeightField3d
void UpdateWorldExtents ()
 

Protected Attributes

bool m_bFloatMode
 
short * m_pData
 
float * m_pFData
 
float m_fVMeters
 
float m_fVerticalScale
 
DPoint2 m_Corners [4]
 
vtCRS m_proj
 
vtString m_strOriginalDEMName
 
- Protected Attributes inherited from vtHeightFieldGrid3d
IPoint2 m_iSize
 
FPoint2 m_fStep
 
DPoint2 m_dStep
 
- Protected Attributes inherited from vtHeightField3d
float m_fDiagonalLength
 
CultureExtension * m_pCulture
 
- Protected Attributes inherited from vtHeightField
float m_fMinHeight
 
float m_fMaxHeight
 
DRECT m_EarthExtents
 

Additional Inherited Members

- Public Attributes inherited from vtHeightField3d
FRECT m_WorldExtents
 
LocalCS m_LocalCS
 

Detailed Description

The vtElevationGrid class represents a generic grid of elevation data. It supports reading and writing the data from many file formats, testing the height at any given point, reprojecting the grid between coordinate systems, and many other operations.

Height elements ("heixels") can be either integer (2 bytes) or floating point (4 bytes). Heixel values are always in meters. Areas of unknown elevation are represented by the value INVALID_ELEVATION.

To load a grid from a file, first create an empty grid, then call the appropriated Load method.

Constructor & Destructor Documentation

vtElevationGrid::vtElevationGrid ( )

Constructor: Creates an empty grid.

vtElevationGrid::vtElevationGrid ( const vtElevationGrid rhs)

Copy constructor.

vtElevationGrid::vtElevationGrid ( const DRECT area,
const IPoint2 size,
bool  bFloat,
const vtCRS proj 
)

Constructor: Creates a grid of given size.

Parameters
areathe coordinate extents of the grid (rectangular area)
sizeNumber of columns and rows in the grid
bFloatdata size: true to use floating-point, false for shorts.
projthe geographical projection to use.

The grid will initially have no data in it (all values are INVALID_ELEVATION).

vtElevationGrid::~vtElevationGrid ( )
virtual

Destructor

Member Function Documentation

void vtElevationGrid::Clear ( )

Set all the values in the grid to zero.

void vtElevationGrid::ComputeCornersFromExtents ( )
protected

For a grid whose absolute extents are known, use those extents to imply the 4 corners coordinates.

void vtElevationGrid::ComputeExtentsFromCorners ( )
protected

For a grid whose 4 corners coordinates are known, use those corners to imply absolute extents.

void vtElevationGrid::ComputeHeightExtents ( )

Scans the grid to compute the minimum and maximum height values.

See also
GetHeightExtents
bool vtElevationGrid::ConvertProjection ( vtElevationGrid pOld,
const vtCRS NewProj,
float  bUpgradeToFloat,
bool   progress_callbackint = NULL,
vtElevError err = NULL 
)

Initializes an elevation grid by converting the contents of an another grid to a new projection.

Parameters
pOldAn existing elevation grid to convert from.
NewProjThe new projection to convert to.
bUpgradeToFloatIf true, the resulting grid will always use floating-point values. Otherwise, it matches the input grid.
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
errIf supplied, will be set to a description of any error that occurs.
Returns
True if successful.
bool vtElevationGrid::Create ( const DRECT area,
const IPoint2 size,
bool  bFloat,
const vtCRS proj,
vtElevError err = NULL 
)

Create a grid of given size.

Parameters
areathe coordinate extents of the grid (rectangular area)
sizeNumber of columns and rows in the grid.
bFloatdata size: true to use floating-point, false for shorts.
projthe geographical projection to use.
errIf supplied, will be set to a description of any error that occurs.

The grid will initially have no data in it (all values are INVALID_ELEVATION).

bool vtElevationGrid::FillGaps ( DRECT area = NULL,
bool   progress_callbackint = NULL 
)

Fill the gaps (heixels of value INVALID_ELVATION) in this grid, by interpolating from the valid values.

This method uses a simple, unoptimized algorithm to move across the grid, one column at a time, averaging the surrounding pixels to fill each gap.

Parameters
areaOptionally, restrict the operation to a given area.
progress_callbackProvide if you want a callback on progress.
Returns
true if successful, false if cancelled.
int vtElevationGrid::FillGapsByRegionGrowing ( int  radius_start = 2,
int  radius_stop = 5,
bool   progress_callbackint = NULL 
)

Fill-in algorithm. Replaces no-data values by repeated region growing. Smoothly extrapolates the filled-in value via partial derivatives. Restricts the fill-in operation to concavities with a diameter of less than radius^2+1 pixels.

Returns
The number of no-data heixels that were filled. Returns -1 on error, for example if there was not enought memory to create the temporary buffers.
int vtElevationGrid::FillGapsByRegionGrowing ( int  radius,
bool   progress_callbackint = NULL 
)

Fill-in algorithm. Replaces no-data values by repeated region growing. Smoothly extrapolates the filled-in value via partial derivatives. Restricts the fill-in operation to concavities with a diameter of less than radius^2+1 pixels.

Adapted subset from original code by: Stefan Roettger.

Returns
The number of no-data heixels that were filled. Returns -1 on error, for example if there was not enought memory to create the temporary buffers.
bool vtElevationGrid::FillGapsSmooth ( DRECT area = NULL,
bool   progress_callbackint = NULL 
)

Fill the gaps (heixels of value INVALID_ELVATION) in this grid, by interpolating from the valid values.

This method attempts to be a little better than FillGaps(), by keeping an entire second grid for the interpolated results on each pass, to avoid some cases of the results getting "smeared" left to right. However, this makes it much slower on most data.

Parameters
areaOptionally, restrict the operation to a given area.
progress_callbackProvide if you want a callback on progress.
Returns
true if successful, false if cancelled.
bool vtElevationGrid::FindAltitudeAtPoint ( const FPoint3 p,
float &  fAltitude,
bool  bTrue = false,
int  iCultureFlags = 0,
FPoint3 vNormal = NULL 
) const
virtual

Simple elevation test for perfectly regular grid terrain. Find altitude (y) and (optionally) surface normal, given (x,z) world coordinates.

This approach is very straightforward, so it could be significantly sped up if needed.

Parameters
pA 3D point in world coordinates. Only the X and Z values are used.
fAltitudeIf the test succeeds, this contains the result by reference.
bTruePass true to the use the true elevation, false to consider the vertical exaggeration in effect.
iCultureFlagsPass 0 to test only the heightfield itself, non-zero to test any culture objects which may be sitting on the heightfield. Values include:
  • CE_STRUCTURES Test structures on the ground.
  • CE_ROADS Test roads on the ground.
  • CE_ALL Test everything on the ground.
vNormalIf you pass a pointer to a vector, it will be filled in with the upwards-pointing surface normal at the given point.
Returns
true if the point was inside the elevation grid, false if outside.

Implements vtHeightField3d.

bool vtElevationGrid::FindAltitudeOnEarth ( const DPoint2 p,
float &  fAltitude,
bool  bTrue = false 
) const
virtual

Return the elevation value at a given point in earth coordinates.

Parameters
pA 2D point in earth coordinates.
fAltitudeIf the test succeeds, this contains the result by reference.
bTruePass true to the use the true elevation, false to consider the vertical exaggeration in effect.
Returns
true if the point was inside the elevation grid, false if outside.

Implements vtHeightField.

void vtElevationGrid::FreeData ( )

Free any memory being used by this class for elevation data.

DRECT vtElevationGrid::GetAreaExtents ( ) const

Returns the geographic extents of the area covered by grid.

The standard extents of an elevation grid are the min and max of its data points. However, because each point in the grid is a spot elevation that implies the elevation of the ground around itself, the area over which the elevation could be understood to describe is actually half a heixel larger in each direction. This method returns that larger area.

float vtElevationGrid::GetClosestValue ( const DPoint2 p) const

Get the height of the grid at a specific world coordinate (nearest neighbor)

The value of the gridpoint closest to the specified location is returned. If the location is not within the extents of the grid, INVALID_ELEVATION is returned.

Parameters
pThe point to query.
const char* vtElevationGrid::GetDEMName ( )
inline

Return the embedded name of the DEM is it has one

float vtElevationGrid::GetFilteredValue ( const DPoint2 p) const

Get the interpolated height of the grid at a specific world coordinate.

The value is linearly interpolated between the surrounding gridpoints. If the location is not within the extents of the grid, INVALID_ELEVATION is returned. The height field has a 0.5 pixel safety boundary to catch all samples on the edges.

Parameters
pThe point to query.
float vtElevationGrid::GetFValue ( int  i,
int  j 
) const

Get an elevation value from the grid.

Parameters
i,jColumn and row location in the grid.
Returns
The value in (float) meters.
short vtElevationGrid::GetShortValue ( int  i,
int  j 
) const

Get a value direct from the grid, in the special case where the grid is composed of short integers with no scaling.

Parameters
i,jColumn and row location in the grid.
Returns
The value of the grid.
void vtElevationGrid::Invalidate ( )

Set all the values in the grid to INVALID_ELEVATION.

bool vtElevationGrid::IsFloatMode ( ) const
inline

Get the data size of the grid heixels (height elements): true if floating point (4-byte), false if integer (2-byte).

bool vtElevationGrid::LoadBTHeader ( const char *  szFileName,
vtElevError err = NULL 
)

Loads just the header information from a BT (Binary Terrain) file.

This can be useful if you want to check the information such as the size of the data, without reading the entire file. This method works whether it is given a normal BT file, or one which has been compressed with gzip.
Returns
true if the header was successfully parsed.
bool vtElevationGrid::LoadFrom3TX ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a 3TX ascii grid file. Projection is Geo WGS84, extents are always 1 degree in size.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromASC ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a Arc/Info compatible ASCII grid file. Projection is read from a corresponding .prj file.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromBT ( const char *  szFileName,
bool   progress_callbackint = NULL,
vtElevError err = NULL 
)

Loads from a BT (Binary Terrain) file.

Both the current version (1.1) and older BT versions are supported. This method works whether it is given a normal BT file, or one which has been compressed with gzip.
Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromDEM ( const char *  szFileName,
bool   progress_callbackint = NULL,
vtElevError err = NULL 
)

Loads elevation from a USGS DEM file.

Some non-standard variations of the DEM format are supported.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromDSAA ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Helper function for LoadFromGRD, loads from a Surfer ascii grid file (GRD)

Projection is always geographic and elevation is floating-point.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromDTED ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a DTED file.

Should support DTED0, DTED1 and DTED2 files, although it has only been tested on DTED0. Projection is assumed to be geographic and elevation is integer meters.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromFile ( const char *  szFileName,
bool   progress_callbackint = NULL,
vtElevError err = NULL 
)

Load from a file whose type is not known a priori. This will end up calling one of the Load* member functions.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if successful.
bool vtElevationGrid::LoadFromGLOBE ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a NOAA GlOBE file.

In fact, there is no "GLOBE format", GLOBE files are delivered as raw data, which can be intepreted using a variety of separate header files. Using the GLOBE server "Select Your Own Area" feature results in 2 files, a header with a .hdr extension and data with a .bin extension. This method reads those file. Pass the filename of the .hdr file to this function, and it will automatically look for a corresponding .bin file in the same location.

Projection is always geographic and elevation is integer meters.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromGRD ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a Surfer binary grid file (GRD)

GRD does not contain any information about CRS, so the following assumption is made: UTM zone 1.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromGTOPO30 ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a GTOPO30 (or SRTM30) file.

GTOPO30 files are actually composed of at least 2 files, a header with a .hdr extension and data with a .dem extension. Pass the filename of the .hdr file to this function, and it will automatically look for a corresponding .dem file in the same location.

Projection is always geographic and elevation is integer meters.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromHGT ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from an "HGT" file, which is the format used by the USGS SRTM FTP site for their 1-degree blocks of SRTM data. It is simply a raw block of signed 2-byte data, in WGS84 geographic coords.

The file will either be: 2,884,802 bytes (for 3 arcsec, 1201*1201) or 25,934,402 bytes (for 1 arcsec, 3601*3601)

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromMicroDEM ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a MicroDEM format file.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromNTF5 ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads an elevation grid from an UK Ordnance Survey NTF level 5 file using the OGR library.

Parameters
szFileNameThe file name to read from.
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
True if the file was successfully opened and read.
bool vtElevationGrid::LoadFromPGM ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a PGM (Portable Gray Map) file. Both PGM Binary and ASCII varieties are supported.

PGM does not contain any information about geographic location, so the following assumptions are made: UTM coordinates, 1-meter spacing, origin at (0,0).

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromRAW ( const char *  szFileName,
int  width,
int  height,
int  bytes_per_element,
float  vertical_units,
bool  bBigEndian,
bool   progress_callbackint 
)

Loads from a RAW file (a naked array of elevation values). The file will not contain any information about at all about data size, data type, or projection, so this information must be passed in as arguments.

Parameters
szFileNameThe file name to read from.
widthThe width of the expected array.
heightThe height of the expected array.
bytes_per_elementThe number of bytes for each elevation value. If this is 1 or 2, the data is assumed to be integer. If 4, then the data is assumed to be floating-point values.
vertical_unitsIndicates what scale factor to apply to the elevation values to convert them to meters. E.g. if the file is in meters, pass 1.0, if in feet, pass 0.3048.
bBigEndianTrue for Big-endian byte order, false for Little-endian (Intel byte order).
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromTerragen ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from a Terragen Terrain file.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadFromXYZ ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Loads from an "XYZ file", which is a simple text file containing a set of grid points in the form X,Y,Z - where X and Y are ground coordinates, and Z is elevation. The values may be separated either by commas (X, Y, Z) or by whitespace (X Y Z).

Returns
true if the file was successfully opened and read.
bool vtElevationGrid::LoadWithGDAL ( const char *  szFileName,
bool   progress_callbackint = NULL,
vtElevError err = NULL 
)

Loads an elevation grid using the GDAL library. The GDAL library supports a very large number of formats, including SDTS-DEM. See http://www.remotesensing.org/gdal/formats_list.html for the complete list of GDAL-supported formats.

Parameters
szFileNameThe file name to read from.
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
errIf supplied, will be set to a description of any error that occurs.

You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.

Returns
True if the file was successfully opened and read.
void vtElevationGrid::Offset ( const DPoint2 delta)

Offset the entire elevation grid horizontally.

Parameters
deltaThe X,Y amount to shift the location of the grid.
vtElevationGrid & vtElevationGrid::operator= ( const vtElevationGrid rhs)

Assignment operator.

Returns
*this with new values
int vtElevationGrid::ReplaceValue ( float  value1,
float  value2 
)

Replace one value with another. For example, replace all heixels of value INVALID_ELEVATION with 0.0.

Parameters
value1The heixel value to replace.
value2The value to replace it with.
Returns
The number of heixels that were modified.
bool vtElevationGrid::ReprojectExtents ( const vtCRS proj_new)

Reprojects an elevation grid by converting just the extents to a new projection.

This is much faster than creating a new grid and reprojecting every heixel, but it only produces correct results when the difference between the projections is only a horizontal shift. For example, this occurs when the only difference between the old and new projection is choice of Datum.

Parameters
proj_newThe new projection to convert to.
Returns
True if successful.
bool vtElevationGrid::SaveToASC ( const char *  szFileName,
bool   progress_callbackint = NULL 
) const

Writes an Arc/Info compatible ASCII grid file. Projection is written to a corresponding .prj file.

Returns
true if the file was successfully opened and written.
bool vtElevationGrid::SaveToBT ( const char *  szFileName,
bool   progress_callbackint = NULL,
bool  bGZip = false 
)

Writes the grid to a BT (Binary Terrain) file. The current BT format version (1.3) is written.

Parameters
szFileNameThe file name to write to.
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
bGZipIf true, the data will be compressed with gzip. If true, you should Use a filename ending with ".gz".
bool vtElevationGrid::SaveToGeoTIFF ( const char *  szFileName) const

Write the elevation grid to a 16-bit greyscale GeoTIFF.

bool vtElevationGrid::SaveToPlanet ( const char *  szDirName,
bool   progress_callbackint = NULL 
)

Write elevation to the MSI Planet (Marconi) format.

Returns
true if the file was successfully opened and written.
bool vtElevationGrid::SaveToPNG16 ( const char *  fname)

Write elevation a 16-bit greyscale PNG file.

bool vtElevationGrid::SaveToRAW_Unity ( const char *  szFileName,
bool   progress_callbackint = NULL 
) const

Write elevation to a .raw file, the way Unity import expects it: Scaled to 8 bits (0-255).

bool vtElevationGrid::SaveToRAWINF ( const char *  szFileName,
bool   progress_callbackint = NULL 
) const

Write elevation to a .raw file along with an .inf file which describes the data for the purpose of exporting to MS Flight Simulator 2004 via their MSFS SDK 'resample' utility.

Parameters
szFileNameShould end in ".raw"
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
Returns
true if the file was successfully written.
bool vtElevationGrid::SaveToSTM ( const char *  szFileName,
bool   progress_callbackint = NULL 
)

Write elevation to the STM (Simple Terrain Model) format created by Michael Garland for his 'Scape' Terrain Simplification software.

Returns
true if the file was successfully opened and written.
bool vtElevationGrid::SaveToTerragen ( const char *  szFileName) const

Writes the grid to a TerraGen Terrain file.

Parameters
szFileNameThe filename to write to.
bool vtElevationGrid::SaveToVRML ( const char *  szFileName,
bool   progress_callbackint = NULL 
) const

Write elevation to a VRML file which contains a single ElevationGrid node.

Returns
true if the file was successfully opened and written.
bool vtElevationGrid::SaveToXYZ ( const char *  szFileName,
bool   progress_callbackint = NULL 
) const

Write elevation to a text file which contains an XYZ for each point.

Returns
true if the file was successfully opened and written.
void vtElevationGrid::Scale ( float  fScale,
bool  bDirect,
bool  bRecomputeExtents = true 
)

Scale all the valid elevation values in the grid by a given factor.

Parameters
fScaleThe desired scale, e.g. 1.0 produces no change in scale.
bDirectIf true, scale the stored height values directly. Otherwise, only the height scale (vertical meters per unit) is scaled.
bRecomputeExtentsIf true, recompute the height extents. Default is true.
void vtElevationGrid::SetFValue ( int  i,
int  j,
float  value 
)

Set an elevation value to the grid.

Parameters
i,jColumn and row location in the grid.
valueThe value in (float) meters.
void vtElevationGrid::SetupLocalCS ( float  fVerticalExag = 1.0f)

Set up the terrain's coordinate systems, including the conversion from Earth coordinates to the World coordinates of the terrain itself. You should call this method after loading or creating a vtElevationGrid, before using methods on it such as FindAltitudeOnEarth or GetSpacing.

For explanation of vtlib/vtdata world coordinates, please see http://vterrain.org/Doc/coords.html

Parameters
fVerticalExagThe vertical exaggeration of the terrain, which is how many times higher it should appear than it really is. Pass 1.0 for no exaggeration.
void vtElevationGrid::SetValue ( int  i,
int  j,
short  value 
)

Set an elevation value to the grid.

Parameters
i,jColumn and row location in the grid.
valueThe value in (integer) meters.
void vtElevationGrid::VertOffset ( float  fAmount)

Vertically offset the valid elevation values in the grid by a given amount.

Parameters
fAmountThe amount to be added to every elevation value.