5

I want to transform map coords into page coords in ArcObjects in Python. So I do, say:

>>> pApp = NewObj(esriFrame.AppROT, esriFrame.IAppROT).Item(0)
>>> pDoc = pApp.Document
>>> pMxDoc = CType(pDoc, esriMapUI.IMxDocument)
>>> pDisplay = pMxDoc.ActiveView.ScreenDisplay # something wrong here?
>>> pDisTrans = pDisplay.DisplayTransformation
>>> pageX, pageY = pDisTrans.FromMapPoint(ptInRealCoords) # coords are ~389700,~316671m
>>> pageX
6523059 # which should be ~4.73 in cm

Any clues whats wrong?

asked Apr 2, 2013 at 14:03

1 Answer 1

3

IScreenDisplay's IDisplayTransformation.FromMapPoint transforms active view's coordinates into device coordinates (i.e. pixels). Moreover, you are accessing pMxDoc.ActiveView which will vary depending on whether you are in data view or page view. This means that the source unit space will be either map units or page units.

If you want to transform a coordinates in a certain map into page coordinates on the page layout you need:

  1. Transform the map's coordinates to the device space (i.e. cast the particular map as IActiveView and use its screen display's transformation, FromMapPoint).
  2. Transform the obtained device coordinates into page coordinates (i.e. cast the document's page layout as IActiveView and use its screen display transformation, ToMapPoint). Note that the name ToMapPoint here is slightly misleading as the "map point" here actually means page coordinates.
answered Apr 2, 2013 at 16:52
1
  • 1
    I was having trouble with this until I found this post forums.esri.com/Thread.asp?c=93&f=992&t=84984 that further visualized the need to transform from map(data frame) coordinates to screen(monitor pixels) coordinates to "map"(page layout) coordinates. Commented May 2, 2013 at 15:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.