Load Raster World File in .Net Runtime SDK

03-02-2017 01:03 PM
New Contributor

Is there a way to load raster images with world files in the .Net Runtime SDK 100.0.0?  I have a .tif image and a .tfw file with transformation information.  The following code block works with GeoTiff files, but not with generic .tif images:

var raster = new Raster(System.IO.Path.Combine(GetStorageDirectory(), "redickville.tif"));
await raster.LoadAsync();
var rasterLayer = new RasterLayer(raster);

await rasterLayer.LoadAsync();


There are no runtime errors, but the raster does not appear.  Is there a way to include the .tfw file in this process?  Or the projection information?

If I use a 3rd party tool to create a GeoTiff file using the same files, that raster image can be loaded and displayed correctly using the above code.  I attached the files I used.


0 Kudos
4 Replies
Esri Regular Contributor

The generic .tif lacks SpatialReference information. You can subscribe to LayerViewStateChanged event to find out errors related to loading/rendering of the layer. You can also see Supported Raster Formats.

        public MainWindow()
            MyMapView.LayerViewStateChanged += MyMapView_LayerViewStateChanged;
            MyMapView.Map = new Map(Basemap.CreateImagery());
            var path = @"C:\Temp\redickville.tif"; // fails on load, Layer.SpatialReference is not set
            // var path = @"C:\Temp\redickville_GeoTiff.tif"; // renders fine
            MyMapView.Map.OperationalLayers.Add(new RasterLayer(new Raster(path)));

        private void MyMapView_LayerViewStateChanged(object sender, LayerViewStateChangedEventArgs e)
            Dispatcher.Invoke(() =>
                if (e.Layer is RasterLayer)
                    if (e.Layer.FullExtent != null)
                        MyMapView.SetViewpoint(new Viewpoint(e.Layer.FullExtent));
                    if (e.LayerViewState.Error != null)
0 Kudos
New Contributor

Then what is the way to use those kind of raster images

0 Kudos
Esri Frequent Contributor


Currently the TIF file must be a GeoTIFF which includes the georeferencing information embedded within the TIFF file. You can use ArcGIS Pro to export as a TIFF with the GeoTIFF information.



0 Kudos
New Contributor III

I haven't tried it yet, but it looks like this is doable now (in SceneView only). If you look here:

Add image overlays—ArcGIS Runtime SDK for .NET | ArcGIS for Developers 

You can see that in 100.8.0 there's now ImageFrame, which takes a RuntimeImage and either an Envelope or a Polygon. So you can load your regular image into a RuntimeImage and then put that in an ImageFrame with whatever corners you want, either as an Envelope rectangle or even a 4-point polygon. Then you can put that in an ImageOverlay and you should be all set.

I think you'd have to write your own translator from world file to Envelope or set of points, but I think that's a fairly standard conversion. But you should now be able to load your image with world file.

I want to do it too, and I haven't tried it yet, so let me know if it works.

0 Kudos