Transforming between image coordinates and world coordinates

SharpMap has built-in functions to help you transform between image and world coordinates.

When the user clicks the map at a given pixel (x, y), you can translate this world coordinates using the ImageToWorld method:
GeoAPI.Geometries.Coordinate p = myMap.ImageToWorld(new System.Drawing.PointF(x, y)); 

Please note that the value is calculated based on the current zoom and center-values of the myMap Map object.

If you want to do the opposite transformation, use WorldToImage:
System.Drawing.PointF p = myMap.WorldToImage(
    new GeoAPI.Geometries.Coordinate(34.225, 175.432));

Last edited Aug 31, 2012 at 11:40 AM by FObermaier, version 8