<?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 Re: Converting to map coordinates in 10.1 in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266536#M6854</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can always create the spatial reference from a string (that is, the contents of a .prj file) using ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJ. By the way, at the end of your code sample there, couldn't you just call pPoint.Project(pMxApp.Display.DisplayTransformation.SpatialReference) and not be bothered about whether the map's got a geographic or projected CS?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Aug 2012 23:06:25 GMT</pubDate>
    <dc:creator>PeterYurkosky1</dc:creator>
    <dc:date>2012-08-29T23:06:25Z</dc:date>
    <item>
      <title>Converting to map coordinates in 10.1</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266535#M6853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have a bounding polygon in WGS 84 coordinates that we need to draw on the map.&amp;nbsp; The users map data could be anything.&amp;nbsp; The following code works in ArcMAP 10.0 (and prior) but does not work in 10.1 if the factory code is zero.&amp;nbsp; Unfortunately a lot of shape files our customers use seem to have valid projection files but no factory codes.&amp;nbsp; They show up in the dataframe properties a "custom" coordinate systems.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In 10.1 is there anyway to create a coordinate system if you have a spatial reference but no factory code?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Or be able to convert a WGS84 point to a "custom" coordinate?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I should ask the high level generic question as well.&amp;nbsp; How can I convert a WGS84 coordinate into the maps coordinate system which can be anything ArcMAP supports.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Mark&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; Public Function ConvertToMap(ByVal lat As Double, ByVal lon As Double, ByVal elev As Double, ByVal layer As ILayer) As IPoint &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Convert x and y to map units. m_pApp is set in ICommand_OnCreate. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMxApp As IMxApplication &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mapPoint As IPoint &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pPoint As Point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' = m_mapPoint &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim sMessage As String = "" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pMxApp = m_pApp&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapPoint = pMxApp.Display.DisplayTransformation.ToMapPoint(0, 0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pSpatialRefFactory As ISpatialReferenceFactory &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pSpatialRefFactory = New SpatialReferenceEnvironment &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pGeographicCoordinateSystem As IGeographicCoordinateSystem &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pGeographicCoordinateSystem = pSpatialRefFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pPoint = mapPoint&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Set the Spacial Ref. to WGS 84 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pPoint.Project(pGeographicCoordinateSystem) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pPoint.X = lon &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pPoint.Y = lat &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim code As Integer &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pProjectedCoordinateSystem As IProjectedCoordinateSystem &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; code = pMxApp.Display.DisplayTransformation.SpatialReference.FactoryCode()&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Dont' know if map is in Geographic or Projected coordinate system so try both. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Try &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pProjectedCoordinateSystem = pSpatialRefFactory.CreateProjectedCoordinateSystem(code) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pPoint.Project(pProjectedCoordinateSystem) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Catch ex As Exception &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pGeographicCoordinateSystem = pSpatialRefFactory.CreateGeographicCoordinateSystem(code) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pPoint.Project(pGeographicCoordinateSystem) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Try&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return pPoint &amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 19:06:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266535#M6853</guid>
      <dc:creator>MarkGolebiewski</dc:creator>
      <dc:date>2012-08-29T19:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to map coordinates in 10.1</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266536#M6854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can always create the spatial reference from a string (that is, the contents of a .prj file) using ISpatialReferenceFactory.CreateESRISpatialReferenceFromPRJ. By the way, at the end of your code sample there, couldn't you just call pPoint.Project(pMxApp.Display.DisplayTransformation.SpatialReference) and not be bothered about whether the map's got a geographic or projected CS?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 23:06:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266536#M6854</guid>
      <dc:creator>PeterYurkosky1</dc:creator>
      <dc:date>2012-08-29T23:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Converting to map coordinates in 10.1</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266537#M6855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; couldn't you just call pPoint.Project(pMxApp.Display.DisplayTransformation.SpatialReference) ?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&amp;nbsp; This turned out to by the answer I was looking for.&amp;nbsp; I can project the point to the maps spatial reference so I don't need a coordinate system so I don't need a factory code so I don't need a PRJ.&amp;nbsp;&amp;nbsp; Lots of thing I no longer need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So far so good in my limited testing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 16:34:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/converting-to-map-coordinates-in-10-1/m-p/266537#M6855</guid>
      <dc:creator>MarkGolebiewski</dc:creator>
      <dc:date>2012-08-30T16:34:03Z</dc:date>
    </item>
  </channel>
</rss>

