Loading raster images into accelerated layers.

5089
16
10-04-2012 11:27 AM
Labels (1)
AaronMorrisett
New Contributor II
I am having issues finding a suitable method of loading a rastered geotiff file into the accelerated layers collection.  My current method that works fine is to load the image into a ElementLayer as follows.

var image = new BitmapImage(new Uri(filePath));
 var newLayer = new ElementLayer();
 var rect = new Rectangle();
 rect.SetValue(ESRI.ArcGIS.Client.ElementLayer.EnvelopeProperty, convertedEnvelope);
 rect.Fill = new ImageBrush(image);
 newLayer.Children.Add(rect);
_esriMap.Layers.Add(newLayer);


This method works fine except I have a accelerated layer collection that is rendering points from GPS readings that needs to be plotted on top of the rastered image.  The only work around I can find is to change the opacity of the Element Layer in order to at least show the points behind the layer.  This is a prefered method, I would like to be able to add the georeferenced image to a layer within my acceleratedLayers collection so I could set the layer order.

If I have not explained my situation well enough let me know and I'll attempt to reword it.

Regards,
    Aaron
0 Kudos
16 Replies
AaronMorrisett
New Contributor II
I feel I might not have worded this question well enough to invoke a response. 🙂

I am looking for a suitable alternative to the element layer for loading a local geo-referenced image into wpf map.  We have a solution using a element layer however the z order cannot be set and we have no way of placing a element layer in the required order.

Regards.
0 Kudos
AaronHigh
New Contributor III
Does anyone have any insight into this issue?
0 Kudos
DavidMartin
Occasional Contributor II
I'm shooting from the hip (having never tried it), but would a dynamic layer not suit your purpose better??
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

To add raster datasets directly to the map, as David suggested, you will need to go via an ArcGISLocalDynamicMapServiceLayer. The class name indicates what's going on here... it's local and the rendering is done dynamically by a map service - i.e. the raster is rendered to an image by the RuntimeLocalServer on your machine and the image is combined with other tiles/images/graphics as layers in the Map.

These local dynamic map service layers need a seed Map Package (.MPK) created with ArcMap. If it's a predetermined raster that you will always add to your application then the best approach is to add the raster to an ArcMap document, and create a Map Package from that document which will include the raster in a nice, portable package.

However, if you need a more adhoc approach then you'll need to effectively create a seed Map Package into which you can stuff raster datasets at runtime. When creating the Map Document for the MPK, you need to add at least one layer to make it valid - this could be a simple feature class such as a polygon layer representing the geographic extent of the coordinate system of the Map (e.g. from -180,-90 to 180,90 if you're working in WGS84). Or the layer could just be an empty Group Layer. And you should also set the coordinate system of the Map Document. Then "share" it as a Map Package, making sure you check the box to enable support for the ArcGIS Runtime.

In code you then create a LocalMapService, add a dynamic workspace (the folder in which the raster resides), and create the ArcGISLocalDynamicMapServiceLayer, setting the EnableDynamicLayers property to true.

You can add any shapefiles, rasters of geodatabase layers to that ArcGISLocalDynamicMapServiceLayer via the DynamicLayerInfos property... here's an example: http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Add_Shapefiles_and_Rasters/02q20...

Cheers

Mike
0 Kudos
RyanNoble
New Contributor
Is it possible to pass a memory stream to ArcGISLocalDynamicMapServiceLayer instead of the raster filename? I'm trying to avoid having to write the raster to disk and reading it back in...
0 Kudos
RyanNoble
New Contributor
Can anyone answer my question?
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

I think you would need to implement your own DynamicLayer in order to achieve this. You could take a look at the HeatMapLayer in the Toolkit DataSources library (source code on codeplex - http://esrisilverlight.codeplex.com/).


Cheers

Mike
0 Kudos
mohscorpion
New Contributor

i have tried this solution , but i guess it doesn't work with non-geo-referenced images , is there a solution for these type of images like normal BMP and JPG files?

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

If the images are not georeferenced, do you have other information which tells you where in the world they should be positioned?

Cheers

Mike

0 Kudos