GeoKeys Property (original) (raw)
Summary
The collection of GeoKeys used when reading and writing Geo TIFF files.
Syntax
C#
Objective-C
C++/CLI
Java
Python
@property (nonatomic, assign, readonly, nullable) NSMutableArray<LTRasterTagMetadata *> *geoKeys;
Property Value
A collection of RasterTagMetadata GeoKeys used when reading and writing Geo TIFF files.
Example
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using Leadtools.Svg;
private void DisplayGeoKey(RasterTagMetadata key)
{
switch (key.DataType)
{
case RasterTagMetadataDataType.Ascii:
Console.WriteLine("Key " + key.Id.ToString() + " = " + key.ToAscii());
break;
case RasterTagMetadataDataType.Byte:
Console.WriteLine("Key " + key.Id.ToString() + " = " + key.ToByte()[0].ToString());
break;
}
}
public void GeoKeysExample()
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "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(LEAD_VARS.ImagesDir, "IMAGE1_GEOKEY.TIF"), RasterImageFormat.GeoTiff, 0);
// load the GeoKeys together with the image
RasterTagMetadata key = codecs.ReadGeoKey(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_GEOKEY.TIF"), 1, keyDataAscii.Id);
DisplayGeoKey(key);
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools Assembly