LEADTOOLS (Leadtools assembly)

GeoKeys_WinRT Property

Show in webframe
Example 







The collection of GeoKeys used when reading and writing Geo TIFF files.
Syntax
public IVector<RasterTagMetadata> GeoKeys_WinRT {get;}
'Declaration
 
Public ReadOnly Property GeoKeys_WinRT As IVector(Of RasterTagMetadata)
'Usage
 
Dim instance As RasterImage
Dim value As IVector(Of RasterTagMetadata)
 
value = instance.GeoKeys_WinRT
public IVector<RasterTagMetadata> GeoKeys_WinRT {get;}

            

            
 get_GeoKeys_WinRT(); 
public:
property IVector<RasterTagMetadata^>^ GeoKeys_WinRT {
   IVector<RasterTagMetadata^>^ get();
}

Property Value

A collection of RasterTagMetadata GeoKeys used when reading and writing Geo TIFF files.
Remarks

GeoTIFF files are TIFF files containing a few extra TIFF tags describing the image location, scale at which the picture was taken and many other information useful for topographic applications.

Any GeoTIFF file that you save will include the GeoKey data set until you clear the GeoKey data. To save this data to a file, save RasterImageFormat.GeoTiff files.

For more information, refer to Implementing GeoKeys (GeoTIFF tags).

To write the GeoKey data directly to an existing file, call RasterCodecs.WriteGeoKey. Note that LEADTOOLS does not verify the validity of the GeoKeys that you set. It is your responsibility to make sure you write correct values according to the GeoTIFF specification.

You can manipulate the GeoKeys of an image by adding/removing RasterTagMetadata objects to this collection.

By setting the CodecsSaveOptions.GeoKeys property to true before calling RasterCodecs.Save, you can save the GeoKeys in this collection when the image is saved into a file.

By setting the CodecsLoadOptions.Markers property to true before calling RasterCodecs.Load, you can load all the markers (if any) into this collection when an image is loaded from a file.

You can use the RasterCodecs.WriteGeoKeys method to save GeoKeys tags directly to an existing file and the RasterCodecs.EnumGeoKeys to load the GeoKeys stored in an existing file.

For more information on GeoKeys, refer to Implementing GeoKeys (GeoTIFF tags).

For more information, refer to Non Image Data.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.WinForms
Imports Leadtools.Dicom
Imports Leadtools.Drawing

Private Sub DisplayGeoKey(ByVal key As RasterTagMetadata)
   Select Case key.DataType
      Case RasterTagMetadataDataType.Ascii
         MessageBox.Show("Key " & key.Id.ToString() & " = " & key.ToAscii())
      Case RasterTagMetadataDataType.Byte
         MessageBox.Show("Key " & key.Id.ToString() & " = " & key.ToByte()(0).ToString())
   End Select
End Sub
Public Sub GeoKeysExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))

   ' Ascii
   Dim keyDataAscii As RasterTagMetadata = New RasterTagMetadata()
   ' set the GTCitationGeoKey key, for more info, refer to the Geo TIFF spec.
   keyDataAscii.Id = 1026
   keyDataAscii.DataType = RasterTagMetadataDataType.Ascii
   keyDataAscii.FromAscii("Test String")
   image.GeoKeys.Add(keyDataAscii)

   codecs.Options.Save.GeoKeys = True
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_GEOKEY.TIF"), RasterImageFormat.GeoTiff, 0)

   ' load the GeoKeys together with the image
   Dim key As RasterTagMetadata = codecs.ReadGeoKey(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_GEOKEY.TIF"), 1, keyDataAscii.Id)
   DisplayGeoKey(key)

   codecs.Dispose()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.WinForms;
using Leadtools.Dicom;
using Leadtools.Drawing;

private void DisplayGeoKey(RasterTagMetadata key)
{
   switch(key.DataType)
   {
      case RasterTagMetadataDataType.Ascii:
         MessageBox.Show("Key " + key.Id.ToString() + " = " + key.ToAscii());
         break;
      case RasterTagMetadataDataType.Byte:
         MessageBox.Show("Key " + key.Id.ToString() + " = " + key.ToByte()[0].ToString());
         break;
   }
}
      
public void GeoKeysExample()
{
   RasterCodecs codecs = new RasterCodecs();
   RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE1.CMP"));
   // Ascii
   RasterTagMetadata keyDataAscii = new RasterTagMetadata();
   // set the GTCitationGeoKey key, for more info, refer to the Geo TIFF spec.
   keyDataAscii.Id = 1026;
   keyDataAscii.DataType = RasterTagMetadataDataType.Ascii;
   keyDataAscii.FromAscii("Test String");
   image.GeoKeys.Add(keyDataAscii);

   codecs.Options.Save.GeoKeys = true;
   codecs.Save(image, Path.Combine(ImagesPath.Path, "IMAGE1_GEOKEY.TIF"), RasterImageFormat.GeoTiff, 0);

   // load the GeoKeys together with the image
   RasterTagMetadata key = codecs.ReadGeoKey(Path.Combine(ImagesPath.Path, "IMAGE1_GEOKEY.TIF"), 1, keyDataAscii.Id);
   DisplayGeoKey(key);

   codecs.Dispose();
}
function DisplayGeoKey(key)
{
   switch (key.dataType)
   {
      case Leadtools.RasterTagMetadataDataType.ascii:
         console.info("Key " + key.id.toString() + " = " + key.toAscii());
         break;
         
      case Leadtools.RasterTagMetadataDataType.byte:
         console.info("Key " + key.id.toString() + " = " + key.toByte()[0].toString());
         break;
   }
}


RasterImageExamples.prototype.GeoKeysExample = function () {
   Tools.SetLicense();
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var codecs = new RasterCodecs();
         var srcFileName = "Assets\\Image1.cmp";
         var image;
         var keyDataAscii;
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
            return codecs.loadAsync(LeadStreamFactory.create(loadFile))
         })
               .then(function (img) {
                  image = img;

                  // Ascii
                  keyDataAscii = new RasterTagMetadata();
                  // set the GTCitationGeoKey key, for more info, refer to the Geo TIFF spec.
                  keyDataAscii.id = 1026;
                  keyDataAscii.dataType = RasterTagMetadataDataType.ascii;
                  keyDataAscii.fromAscii("Test String");
                  image.geoKeys.append(keyDataAscii);

                  codecs.options.save.geoKeys = true;
                  return Tools.AppLocalFolder().createFileAsync("IMAGE1_GEOKEY.TIF")
               })
               .then(function (saveFile) {
                  var saveStream = LeadStreamFactory.create(saveFile);
                  return codecs.saveAsync(image, saveStream, RasterImageFormat.geoTiff, 0)
               })
               .then(function () {

                  // load the GeoKeys together with the image
                  return Tools.AppLocalFolder().getFileAsync("IMAGE1_GEOKEY.TIF")
               })
               .then(function (loadFile) {
                  return codecs.readGeoKeyAsync(LeadStreamFactory.create(loadFile), 1, keyDataAscii.id)
               })
               .then(function (key) {
                  DisplayGeoKey(key);
                  image.close();
                  codecs.close();
               });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;

private void DisplayGeoKey(RasterTagMetadata key)
{
   switch (key.DataType)
   {
      case RasterTagMetadataDataType.Ascii:
         Debug.WriteLine("Key " + key.Id.ToString() + " = " + key.ToAscii());
         break;
      case RasterTagMetadataDataType.Byte:
         Debug.WriteLine("Key " + key.Id.ToString() + " = " + key.ToByte()[0].ToString());
         break;
   }
}
      
public async Task GeoKeysExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = @"Assets\Image1.cmp";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
   // Ascii
   RasterTagMetadata keyDataAscii = new RasterTagMetadata();
   // set the GTCitationGeoKey key, for more info, refer to the Geo TIFF spec.
   keyDataAscii.Id = 1026;
   keyDataAscii.DataType = RasterTagMetadataDataType.Ascii;
   keyDataAscii.FromAscii("Test String");
   image.GeoKeys.Add(keyDataAscii);

   codecs.Options.Save.GeoKeys = true;
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("IMAGE1_GEOKEY.TIF");
   ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
   await codecs.SaveAsync(image, saveStream, RasterImageFormat.GeoTiff, 0);

   // load the GeoKeys together with the image
   loadFile = await Tools.AppLocalFolder.GetFileAsync("IMAGE1_GEOKEY.TIF");
   RasterTagMetadata key = await codecs.ReadGeoKeyAsync(LeadStreamFactory.Create(loadFile), 1, keyDataAscii.Id);
   DisplayGeoKey(key);

   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Dicom;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Examples;
using Leadtools.Windows.Media;

private void DisplayGeoKey(RasterTagMetadata key)
{
   switch (key.DataType)
   {
      case RasterTagMetadataDataType.Ascii:
         Debug.WriteLine("Key " + key.Id.ToString() + " = " + key.ToAscii());
         break;
      case RasterTagMetadataDataType.Byte:
         Debug.WriteLine("Key " + key.Id.ToString() + " = " + key.ToByte()[0].ToString());
         break;
   }
}
public void GeoKeysExample(RasterImage image, Stream destStream)
{
   // Ascii
   RasterTagMetadata keyDataAscii = new RasterTagMetadata();
   // set the GTCitationGeoKey key, for more info, refer to the Geo TIFF spec.
   keyDataAscii.Id = 1026;
   keyDataAscii.DataType = RasterTagMetadataDataType.Ascii;
   keyDataAscii.FromAscii("Test String");
   image.GeoKeys.Add(keyDataAscii);
   RasterCodecs codecs = new RasterCodecs();
   codecs.Options.Save.GeoKeys = true;
   codecs.Save(image, destStream, RasterImageFormat.GeoTiff, 0);

   // load the GeoKeys together with the image
   RasterTagMetadata key = codecs.ReadGeoKey(destStream, 1, keyDataAscii.Id);
   DisplayGeoKey(key);
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Dicom
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Private Sub DisplayGeoKey(ByVal key As RasterTagMetadata)
   Select Case key.DataType
      Case RasterTagMetadataDataType.Ascii
         Debug.WriteLine("Key " & key.Id.ToString() & " = " & key.ToAscii())
      Case RasterTagMetadataDataType.Byte
         Debug.WriteLine("Key " & key.Id.ToString() & " = " & key.ToByte()(0).ToString())
   End Select
End Sub
Public Sub GeoKeysExample(ByVal image As RasterImage, ByVal destStream As Stream)
   ' Ascii
   Dim keyDataAscii As RasterTagMetadata = New RasterTagMetadata()
   ' set the GTCitationGeoKey key, for more info, refer to the Geo TIFF spec.
   keyDataAscii.Id = 1026
   keyDataAscii.DataType = RasterTagMetadataDataType.Ascii
   keyDataAscii.FromAscii("Test String")
   image.GeoKeys.Add(keyDataAscii)
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Options.Save.GeoKeys = True
   codecs.Save(image, destStream, RasterImageFormat.GeoTiff, 0)

   ' load the GeoKeys together with the image
   Dim key As RasterTagMetadata = codecs.ReadGeoKey(destStream, 1, keyDataAscii.Id)
   DisplayGeoKey(key)
End Sub
Requirements

Target Platforms

See Also

Reference

RasterImage Class
RasterImage Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.