Below is the code to display a raster as a basemap or an operational layer
string pathToRaster = @"C:\rasters\wsiearth.tif";
// create a raster from a path to a supported raster format
Raster myRaster = new Raster(pathToRaster);
// create a RasterLayer using the Raster
Esri.ArcGISRuntime.Mapping.RasterLayer newRasterLayer = new Esri.ArcGISRuntime.Mapping.RasterLayer(pathToRaster);
Map map = new Map();
map.Basemap.BaseLayers.Add(newRasterLayer); // as a Basemap
// map.OperationalLayers.Add(newRasterLayer); // as an operational layer
MyMapView.Map = map;
Hope that helps.
Thanks Yasmin, that's a great help. However it still does not work. The
window just shows all white.
However, I can swap in a WmtsLayer and THAT displays, so the rest of my
code should be okay.
Could you point me to a tif file for me to try? Maybe my tif file is
Thanks Nagma, it still does not work. All I'm getting is a white window.
Your tiff file set consists of the files with extensions .tfw, .tif,
.aux.xml and .tif.ovr
my tiff file set consts of files with the extensions .prj, .tfw, .tif,
.README.html and .VERSION.txt
seems like slightly different formats, but both does not work.
For the pathToRaster I just point to the .tif file itself right?
do I need to do anything else like set the SpatialReferences?
I noticed that in your code, there seems to be one line that does nothing
"Raster myRaster = new Raster(pathToRaster)':
i.e. myRaster is not used.. am I missing something?
I can do either new RasterLayer(myRaster) OR new
but it makes no difference either way.
You right, I haven't used the variable 'myRaster' anywhere in the code, sorry for the confusion. But I am not sure why you are seeing only the white screen using same raster I used.
I suspect it is stuck at loading the raster.
I have drawn some graphics in a graphics overlay, which does come out when
I switch over to wmtslayer.
Could I trouble you to provide a shortest complete source code that works?
Hi Nagma, thank you very much, it was a great help! I could get your
project to work.
I finally discovered what in my case was preventing the raster from
it was the
that was the culprit...
I added this to your project (together with my license string) and it
stopped working immediately.
I removed it from my project and it worked!
I'm puzzled why that would interfere with loading the raster.
The license has no effect on WmtsLayer and other kinds of basemaps..
According to the documentation, (License your app—ArcGIS Runtime SDK for .NET (WPF) | ArcGIS for Developers) to display the local raster layer, you need to have the minimum Standard license. I am guessing you might be using Basic or Lite license in your application that prevent displaying the raster image.