Convert pixel coordinate into map coordinate

Last Published: April 25, 2020


Many user-interactive MapObjects Java applications need to get the location of mouse-click in the map. The location of a mouse-click can be returned from the MouseEvent object in terms of the Map object's pixel coordinate value. To perform various spatial functions, we need to convert this pixel coordinate into a map coordinate. This article outlines the steps to convert a pixel coordinate into a map coordinate.


  1. Get the x and y location from the MouseEvent e:

    int x1=e.getX();
    int y1=e.getY();

  2. Convert the integer values into double type:

    double doubleX1=new Integer(x1).doubleValue();
    double doubleY1=new Integer(y1).doubleValue();

  3. Create a point object in pixel units:

    Code: pixelPoint= new,doubleY1);

  4. Get the Transform object from the Map and call the transform function:

    Code: trans = map1.getPixelToWorldTransform(); mapPoint= trans.transform(pixelPoint, null);

  5. Get the x and y location in map coordinates from the transformed point:

    double mapX=mapPoint.x;
    double mapY=mapPoint.Y

    Call getWorldToPixelTransform function on map object to transform Map Coordinate to Pixel Coordinate.

Article ID:000005390

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic