WriteGeoKey Example for Visual Basic
' Displays a GeoKey
Private Sub DisplayKey(uTag As Integer, uType As Integer, uCount As Integer, data As LEADRasterVariant)
Dim buffer As String
If uType = TAG_ASCII Then
buffer = "ASCII"
Else
If uType = TAG_SHORT Then
buffer = "SHORT"
Else
buffer = "DOUBLE"
End If
End If
buffer = "Key = " + CStr(uTag) + Chr(13) + buffer + Chr(13) + "Count = " + CStr(uCount)
MsgBox buffer
If uType = TAG_SHORT Then
If uCount = 1 Then
buffer = "Key Value = " + CStr(data.ShortValue)
Else
buffer = "Key Value = " + CStr(data.ShortItemValue (0))
End If
Else
If uType = TAG_DOUBLE Then
If uCount = 1 Then
buffer = "Key Value = " + CStr(data.DoubleValue)
Else
buffer = "Key Value = " + CStr(data.DoubleItemValue (0))
End If
End If
End If
MsgBox buffer
End Sub
' This example sets the GTModelTypeGeoKey key (1024), writes it to an existing file and reads the key back
Public RasterIO As LEADRasterIO
Private Sub TestReadFileGeoKey()
Dim rasVar As New LEADRasterVariant
Dim nRet As Integer
rasVar.Type = VALUE_SHORT
rasVar.ShortValue = 1
RasterIO.GeoKeyType = TAG_SHORT
RasterIO.GeoKeyCount = 1
RasterIO.GeoKeyData = rasVar
' set the GTModelTypeGeoKey key
RasterIO.SetGeoKey 1024
' write the GeoKey to an existing file
nRet = RasterIO.WriteFileGeoKey ("GeoTIFF.tif", 0, SAVE_OVERWRITE)
If nRet = 0 Then
nRet = RasterIO.ReadFileGeoKey ("GeoTIFF.tif", 1024)
If nRet = 0 Then
DisplayKey 1024, RasterIO.GeoKeyType, RasterIO.GeoKeyCount, RasterIO.GeoKeyData
End If
End If
End Sub