<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to convert map coordinates to page coordinates? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-map-coordinates-to-page-coordinates/m-p/242909#M6299</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a map inside a page layout in ArcMap. Currently, I use this code to convert geographic coordinates to page coordinates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;IMap map = ...
IPageLayout pageLayout = ...

IDisplayTransformation mapTransformation = ((IActiveView)map).getScreenDisplay().getDisplayTransformation();
IDisplayTransformation pageTransformation = ((IActiveView)pageLayout).getScreenDisplay().getDisplayTransformation();

IPoint mapPoint = ...

int x[] = {0};
int y[] = {0};
mapTransformation.fromMapPoint(mapPoint, x, y);
IPoint pagePoint = pageTransformation.toMapPoint(x[0], y[0]);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem of this method is that x[0] and y[0] are device coordinates (integers).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, if mapPoint = 913767.624037, 6458100.4284 (in meters)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I get: x[0], y[0] = 18, -2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then: pagePoint = 18.0, 2.0 (in centimeters)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These values are corrects but they are rounded. I would expect for this example a pagePoint = 18.42 cm, 2.19 cm&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there another way to get directly map to page coordinates conversion without going through device coordinates?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Or what's wrong in my conversion method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any help on this problem. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Apr 2014 08:56:29 GMT</pubDate>
    <dc:creator>KevinLECOCQ</dc:creator>
    <dc:date>2014-04-07T08:56:29Z</dc:date>
    <item>
      <title>How to convert map coordinates to page coordinates?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-map-coordinates-to-page-coordinates/m-p/242909#M6299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a map inside a page layout in ArcMap. Currently, I use this code to convert geographic coordinates to page coordinates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;IMap map = ...
IPageLayout pageLayout = ...

IDisplayTransformation mapTransformation = ((IActiveView)map).getScreenDisplay().getDisplayTransformation();
IDisplayTransformation pageTransformation = ((IActiveView)pageLayout).getScreenDisplay().getDisplayTransformation();

IPoint mapPoint = ...

int x[] = {0};
int y[] = {0};
mapTransformation.fromMapPoint(mapPoint, x, y);
IPoint pagePoint = pageTransformation.toMapPoint(x[0], y[0]);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem of this method is that x[0] and y[0] are device coordinates (integers).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, if mapPoint = 913767.624037, 6458100.4284 (in meters)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I get: x[0], y[0] = 18, -2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then: pagePoint = 18.0, 2.0 (in centimeters)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These values are corrects but they are rounded. I would expect for this example a pagePoint = 18.42 cm, 2.19 cm&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there another way to get directly map to page coordinates conversion without going through device coordinates?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Or what's wrong in my conversion method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any help on this problem. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 08:56:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-map-coordinates-to-page-coordinates/m-p/242909#M6299</guid>
      <dc:creator>KevinLECOCQ</dc:creator>
      <dc:date>2014-04-07T08:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert map coordinates to page coordinates?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-map-coordinates-to-page-coordinates/m-p/242910#M6300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I already have the problem, up?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 11:57:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-map-coordinates-to-page-coordinates/m-p/242910#M6300</guid>
      <dc:creator>KevinLECOCQ</dc:creator>
      <dc:date>2014-04-15T11:57:48Z</dc:date>
    </item>
  </channel>
</rss>

