ThinkGeo.com    |     Documentation    |     Premium Support

Xamarin Forms - Rendering Tiff files

Hello,

I am using a GeoTiffRasterLayer to show a tiff image, but it is very slow, and I want to know if there is something else I can do to improve its performance.

GeoTiffRasterLayer geoTiffRasterLayer = new GeoTiffRasterLayer(targetDirectory);
geoTiffRasterLayer.UpperThreshold = double.MaxValue;
geoTiffRasterLayer.LowerThreshold = 0;
geoTiffRasterLayer.IsGrayscale = false;
geoTiffRasterLayer.DrawingQuality = DrawingQuality.HighSpeed;
geoTiffRasterLayer.LibraryType = GeoTiffLibraryType.ManagedLibTiff;
_layerOverlay.Layers.Add(fileName, geoTiffRasterLayer);

Thanks. :smile:

Hi Carlos,

You can use tile cache to improve GeoTiffRasterLayer performance. Please refer to the following source code:

LayerOverlay layerOverlay = new LayerOverlay();
GeoTiffRasterLayer geoTiffRasterLayer = new GeoTiffRasterLayer(targetDirectory);
geoTiffRasterLayer.UpperThreshold = double.MaxValue;
geoTiffRasterLayer.LowerThreshold = 0;
geoTiffRasterLayer.IsGrayscale = false;
geoTiffRasterLayer.DrawingQuality = DrawingQuality.HighSpeed;
geoTiffRasterLayer.LibraryType = GeoTiffLibraryType.ManagedLibTiff;
layerOverlay.Layers.Add(fileName, geoTiffRasterLayer);
layerOverlay.TileCache = new FileBitmapTileCache(“mnt/sdcard/MapSuiteSampleData/GeoTiffTileCache”, “GeoTiff”);

Wish that’s helpful.

Thanks,

Hi Don,

now it works much better when have the view cached, but it still going slowly if move or zoom to an uncached area, is there any way to force it to cache all areas?

Thanks for your help.

Hi Carlos,

You can use our CacheGenerator tool (http://wiki.thinkgeo.com/wiki/_media/file/ServicesEditionSample_CacheGenerator_CS_150204.zip) to cache all tiles for GeoTiff layer, then copy the caches to the cache folder of android device.

Please change the code of CacheGenerator tool as following before using it:
In LayerProvider Class:

public static Collection GetLayersToCache()
{
Collection layersToCache = new Collection();

   // You can insert your layer to "layersToCache" in this function, they will be used for cache.
   GeoTiffRasterLayer layer = new GeoTiffRasterLayer(“Your GeoTiff file path”);
   layersToCache.Add(layer);

   return layersToCache;

}

Besides, you need to set TileSnappingMode values for LayerOverlay as following:

LayerOverlay layerOverlay = new LayerOverlay();
GeoTiffRasterLayer geoTiffRasterLayer = new GeoTiffRasterLayer(targetDirectory);
geoTiffRasterLayer.UpperThreshold = double.MaxValue;
geoTiffRasterLayer.LowerThreshold = 0;
geoTiffRasterLayer.IsGrayscale = false;
geoTiffRasterLayer.DrawingQuality = DrawingQuality.HighSpeed;
geoTiffRasterLayer.LibraryType = GeoTiffLibraryType.ManagedLibTiff;
layerOverlay.Layers.Add(fileName, geoTiffRasterLayer);
layerOverlay.TileCache = new FileBitmapTileCache(“mnt/sdcard/MapSuiteSampleData/GeoTiffTileCache”, “GeoTiff”);
layerOverlay.TileSnappingMode = TileSnappingMode.Snapping;

Thanks,