Select to view content in your preferred language

Using Element and ElementLayer to georeference an image

1540
2
05-09-2011 08:57 PM
MichaelDillon
New Contributor
I have an un-projected image that I need to georeference.  I know the spatial coordinates for the corners of the image, and I need to apply an affine transform to properly place it on the map.  I'm trying to do something like this:

Image img = new Image();
img.Source = new BitmapImage(_sampleImageUri);
img.Stretch = System.Windows.Media.Stretch.None;
img.SetValue(ESRI.ArcGIS.Client.ElementLayer.EnvelopeProperty, poly.Extent); // Where 'poly' is the image footprint
img.RenderTransform = new System.Windows.Media.MatrixTransform()
{
  Matrix = // Parameters calculated based on the MapToScreen() coordinates of the image footprint
    new System.Windows.Media.Matrix(xCellsize, yRotation, xRotation, yCellsize, 0, 0); 
};
_elementLayer.Children.Add(img);


This almost works.  If I apply the transform to an image that's not in the map, the size, rotation, and skew appear to match the footprint.

But, the element displayed in the map seems scaled in a way I don't understand. 

What am I missing?

Is there a better way?

Thanks,

Mike
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
If you are using an element layer, you don't have to take care of the map scale and of the current extent. This is done by the framework.
You only have to place your image to the right coordinates (in map coordinates).

What you are doing would probaly work well if you were adding the image on top of the map without using an element layer.
0 Kudos
dotMorten_esri
Esri Notable Contributor
Did you try this sample?
http://www.arcgis.com/home/item.html?id=2ef4c343494647cc82b64a2d421d5716
Live version: http://serverapps.esri.com/SilverlightDemos/GeoReference/


It allows you to calculate the parameters needed to correctly place an image, including rotation.

However, your image must be using the correct projection, or you WILL get very poor results. A skew and/or planar transform added to it will render very poor results.
0 Kudos