<?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: Coordinate transformation in arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199476#M15334</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jai, thank you very much this is exactly what I wanted!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Is it possible to do this without saving to a file? I will be doing this on thousands of coordinates so this is undesirable as it will place increased load on the disk, and slow down the process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 May 2015 10:57:40 GMT</pubDate>
    <dc:creator>ChrisHills</dc:creator>
    <dc:date>2015-05-07T10:57:40Z</dc:date>
    <item>
      <title>Coordinate transformation in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199473#M15331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As part of a script I need to convert coordinates from one SRS to another. This is the code I have so far, but I am missing the bit in the middle. I have done some extensive googling but I was not able to find a solution so I would appreciate some assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

inputSRS = 'Projected Coordinate Systems/National Grids/Europe/British National Grid' # Projected
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;outputSRS = 'Geographic Coordinate Systems/World/WGS 1984' # Geographic&lt;/SPAN&gt;
trsOut = 'OSGB_1936_To_WGS_1984_Petroleum'

srIn = arcpy.SpatialReference(inputSRS)
srOut = arcpy.SpatialReference(outputSRS)

inX = 210000
inY = 310000

# Code goes here

print outX, outY # "-4.81042685256 52.6543521582"
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:56:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199473#M15331</guid>
      <dc:creator>ChrisHills</dc:creator>
      <dc:date>2021-12-11T09:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Coordinate transformation in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199474#M15332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; try the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;import arcpy&lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;inputSRS = 'Projected Coordinate Systems/National Grids/Europe/British National Grid' # Projected&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;outputSRS = 'Geographic Coordinate Systems/World/WGS 1984' # Geographic&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;trsOut = 'OSGB_1936_To_WGS_1984_Petroleum'&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;srIn = arcpy.SpatialReference(inputSRS)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;srOut = arcpy.SpatialReference(outputSRS)&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;pt = arcpy.Point()&lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;ptGeoms = []&lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;pt.X = 210000&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;pt.Y = 310000&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;ptGeoms.append(arcpy.PointGeometry(pt,srIn ))&lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;arcpy.CopyFeatures_management(ptGeoms, 'base')&lt;/SPAN&gt;
&lt;SPAN style="color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;arcpy.Project_management('base',trsOut, srOut)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12pt; font-family: georgia, palatino;"&gt;It will first create a Feature named 'base' with input SRS and then creates your output feature with output SRS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino; font-size: 12pt;"&gt;You can set the environment to save the output in a specific location.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199474#M15332</guid>
      <dc:creator>JaiSiva1</dc:creator>
      <dc:date>2021-12-11T09:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Coordinate transformation in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199475#M15333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;additionally you can cross check by :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;with arcpy.da.SearchCursor("SR2",['SHAPE@X','SHAPE@Y']) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row[1]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will print :&lt;/P&gt;&lt;P&gt;&amp;nbsp; -4.810426852&lt;/P&gt;&lt;P&gt;&amp;nbsp; 52.654352152&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:56:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199475#M15333</guid>
      <dc:creator>JaiSiva1</dc:creator>
      <dc:date>2021-12-11T09:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Coordinate transformation in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199476#M15334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jai, thank you very much this is exactly what I wanted!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Is it possible to do this without saving to a file? I will be doing this on thousands of coordinates so this is undesirable as it will place increased load on the disk, and slow down the process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 10:57:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199476#M15334</guid>
      <dc:creator>ChrisHills</dc:creator>
      <dc:date>2015-05-07T10:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Coordinate transformation in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199477#M15335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Is it possible to do this without saving to a file?&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, you can use the arcpy shape method &lt;STRONG&gt; .projectAs()&lt;/STRONG&gt;. This can be tricky but should work great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;projectAs (spatial_reference, {transformation_name})&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Projects a geometry and optionally applies a geotransformation. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;To project, the geometry needs to have a spatial reference, and not have an &lt;SPAN class="arcpyref"&gt;UnknownCoordinateSystem&lt;/SPAN&gt;. The new spatial reference system passed to the method defines the output coordinate system. If either spatial reference is unknown the coordinates will not be changed. The Z- and measure values are not changed by the &lt;SPAN class="arcpyref"&gt;ProjectAs&lt;/SPAN&gt; method.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/point.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/point.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Point—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/pointgeometry.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/pointgeometry.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;PointGeometry—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also highly recommend using WKID numbers instead of those long coordinate system names which are easy to misspell. A very easy place to look them up is &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://spatialreference.org/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://spatialreference.org&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Note this is untested code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy&amp;nbsp; 
inputSRS = arcpy.SpatialReference(7405)&amp;nbsp; # British National Grid
outputSRS = arcpy.SpatialReference(4326) # GCS WGS84
gt = 'OSGB_1936_To_WGS_1984_Petroleum'&amp;nbsp;&amp;nbsp;&amp;nbsp; 
pt = arcpy.Point()&amp;nbsp; 
pt.X = 210000&amp;nbsp;&amp;nbsp;&amp;nbsp; 
pt.Y = 310000&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Input XY: {} {}".format(pt.X, pt.Y)
ptgeo = arcpy.PointGeometry(pt, inputSRS)
ptgeo1 = ptgeo.projectAs(outputSRS, gt)
pt1 = ptgeo1.lastPoint
print "Output XY: {} {}".format(pt1.X, pt1.Y)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:56:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/coordinate-transformation-in-arcpy/m-p/199477#M15335</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T09:56:58Z</dc:date>
    </item>
  </channel>
</rss>

