0

I wish to read and show some tile package file using ArcObject C# 10.x.

However, I failed to find how to read an tile package file on My Application using ArcObject C#.

Can you tell me how to do this?

  • I've never tried to "read" a tile package, I always thought they were a way of delivering data in a compressed format, so you need to uncompress them or "un-pack" them, probably easiest calling the geoprocessor tool? – Hornbydd May 2 '16 at 19:25
  • Thank you for your comment. I thought that ArcObject SDK can read the tile package in some document(for example, link). According to this document, does it mean that I should use a data of un-packed the tile package? – Sangjin Sim May 3 '16 at 5:31
1

I have done something similar with the IPackageFile object. The unpack method should do what you want.

0

From the answer of @Dowlers, I found solution to use .tpk file on ArcObjects.

public static ESRI.ArcGIS.Carto.ILayer GetLayerFromTilePackage(string path)
{
  if (System.IO.File.Exists(path) == false)
    return null;

  //var layer = new ESRI.ArcGIS.Carto.RasterLayerClass();
  //layer.CreateFromFilePath(path);
  string unpackPath = "";

  IPackageFile pkFile = new PackageFileClass();
  pkFile.Unpack(path, ref unpackPath);

  // Create a new GxLayer
  ESRI.ArcGIS.Catalog.IGxLayer gxLayer = new ESRI.ArcGIS.Catalog.GxLayerClass();

  ESRI.ArcGIS.Catalog.IGxFile gxFile = (ESRI.ArcGIS.Catalog.IGxFile)gxLayer; //Explicit Cast

  // Set the path for where the layerfile is located on disk
  gxFile.Path = unpackPath + "\\Layers.lyr";
  if (gxLayer.Layer == null)
  {
    gxFile.Path = unpackPath + "\\" + System.IO.Path.GetFileNameWithoutExtension(path) + ".lyr";
  }

  return gxLayer.Layer;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.