# VEImagery Service Pixel to LatLong calculations

The VEImagery service gives us the ability to render static versions of Virtual Earth Maps. As handy as this is it would also be handy to be able to georeference the image that is returned. The article found here:

explains how to convert from LatLong to Pixel so that custom icons could be added to the map, however the conversion from Pixel to LatLong was not needed at that time. Building on top of the code that was provided in that article the following method can be used to calculate a LatLong value based on the pixel coordinate of a static image. The following formula can be used to perform this calculation.

 ///         /// Convert Pixel coordinates to LatLong coordinates        /// Based on code found here: http://msdn.microsoft.com/en-us/library/cc161076.aspx        ///         ///         ///         public LatLong PixelToLatLong(Point offset)        {            int x = TopLeftCorner.X + offset.X;            int y = TopLeftCorner.Y + offset.Y;             double Longitude = (((double)x * 360) / (256 * Math.Pow(2, view.zoom))) – 180;             double efactor = Math.Exp((0.5 – (double)y / 256 / Math.Pow(2, view.zoom)) * 4 * Math.PI);             double Latitude = Math.Asin((efactor – 1) / (efactor + 1)) * 180 / Math.PI;             LatLong latlong = new LatLong();            latlong.Latitude = Latitude;            latlong.Longitude = Longitude;             return latlong;        }