<?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 Reproject a point with arcpy? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/reproject-a-point-with-arcpy/m-p/165800#M12744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would like to use arcPy to reproject XY point fields in a table to a different coordinate system.&amp;nbsp; Essentially do the same as the Calculate Geometry option but from a Python script.&amp;nbsp; Is it possible?&amp;nbsp; I can't find any functions in arcPy that provides reprojection of the point values derived from the 'shape' field or from XY values stored as attributes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DG&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 05 Mar 2011 22:58:24 GMT</pubDate>
    <dc:creator>DennisGeasan</dc:creator>
    <dc:date>2011-03-05T22:58:24Z</dc:date>
    <item>
      <title>Reproject a point with arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/reproject-a-point-with-arcpy/m-p/165800#M12744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would like to use arcPy to reproject XY point fields in a table to a different coordinate system.&amp;nbsp; Essentially do the same as the Calculate Geometry option but from a Python script.&amp;nbsp; Is it possible?&amp;nbsp; I can't find any functions in arcPy that provides reprojection of the point values derived from the 'shape' field or from XY values stored as attributes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DG&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Mar 2011 22:58:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reproject-a-point-with-arcpy/m-p/165800#M12744</guid>
      <dc:creator>DennisGeasan</dc:creator>
      <dc:date>2011-03-05T22:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reproject a point with arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/reproject-a-point-with-arcpy/m-p/165801#M12745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a projection parameter option on the cursor objects that will reproject to new coordinates as you read the records. Getting a transform to work as well is a bit tricky, but basically set that as well as a string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# extent_xy.py
# add extents of parcels in NZMG to a NZTM dataset for backward compatibility
# update to use on the fly projection directly from NZTM layers
# see Werner Flacke's book and script example
# updated for 9.2
# Kim Ollivier 13 April 2007
# input NZTM coverage library, parcel and plabel coverages
# output csv files to load and join back to coverages using AML
# issues solved:
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add spatial reference to SearchCursor
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; define a Geographic Transformation that works with a coverage
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; because coverages cannot define NZGD2000 use WGS84 definition
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or the transform is ignored

import os,sys,glob,arcgisscripting

gp = arcgisscripting.create()

def parcel(tile) :
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Parcel",tile
&amp;nbsp;&amp;nbsp;&amp;nbsp; ws = "e:/lib/nztm/tile/t"+str(tile)+"/data"
&amp;nbsp;&amp;nbsp;&amp;nbsp; outfolder = "e:/lib/nztm/tile/t"+str(tile)+"/data"
&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = ws + "/parcel"
&amp;nbsp;&amp;nbsp;&amp;nbsp; f1 = open(outfolder+"/e_parcel.txt","w")
&amp;nbsp;&amp;nbsp;&amp;nbsp; f1.write("par_id,eminx_nzmg,eminy_nzmg,emaxx_nzmg,emaxy_nzmg\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Workspace = ds
&amp;nbsp;&amp;nbsp;&amp;nbsp; print ds
&amp;nbsp;&amp;nbsp;&amp;nbsp; # this is a good on-the-fly switch for the searchcursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; # srOut must be a com object, not a file ref or a factory code
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = gp.SearchCursor(ds+"/polygon",'"PAR_ID" &amp;gt; 0',srOut) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; n = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.Reset()
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()
&amp;nbsp;&amp;nbsp;&amp;nbsp; while row&amp;nbsp; :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;gt;&amp;gt; f1,"%d,%s" % (row.par_id,row.shape.Extent.replace(" ",","))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; print n,"Polygons"
&amp;nbsp;&amp;nbsp;&amp;nbsp; f1.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return

def plabel(tile) :
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Plabel",tile
&amp;nbsp;&amp;nbsp;&amp;nbsp; ws = "e:/lib/nztm/tile/t"+str(tile)+"/data"
&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = ws + "/plabel"
&amp;nbsp;&amp;nbsp;&amp;nbsp; outfolder = "e:/lib/nztm/tile/t"+str(tile)+"/data"
&amp;nbsp;&amp;nbsp;&amp;nbsp; f2 = open(outfolder+"/e_plabel.txt","w")
&amp;nbsp;&amp;nbsp;&amp;nbsp; f2.write("par_id,eminx_nzmg,eminy_nzmg\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Workspace = ds
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = gp.SearchCursor(ds+"/point",'"PAR_ID" &amp;gt; 0',srOut)
&amp;nbsp;&amp;nbsp;&amp;nbsp; n = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.Reset()
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()
&amp;nbsp;&amp;nbsp;&amp;nbsp; while row&amp;nbsp; :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;gt;&amp;gt;f2,"%d,%s,%s" % (row.par_id,row.shape.Extent.split()[0],row.shape.Extent.split()[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.Next()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; print n,"plabels"
&amp;nbsp;&amp;nbsp;&amp;nbsp; f2.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return

# ------ main ----
#
srOut = gp.CreateObject("SpatialReference")
srOut.CreateFromFile("c:/arcgis/nzmg.prj")
# WGS_1984 works for coverages defined with an equivalent custom Transverse projection definition
gp.GeographicTransformations = 'NZGD_1949_To_WGS_1984_3_NTv2' # ;New_Zealand_1949_To_NZGD_2000_3_NTv2'
# but is this being used?
inFC = "e:/lib/nztm/tile/t1009/data/plabel/point"
# not at 9.3?? outFC = "in_memory/dummy1.shp"
outFC = "c:/tmp/dummy1.shp"
outPrj = "c:/arcgis/nzmg.prj" # cannot be a COM object or factory id 43040
geoTrans = "NZGD_1949_To_WGS_1984_3_NTv2" # ;New_Zealand_1949_To_NZGD_2000_3_NTv2"
if gp.Exists("c:/tmp/dummy1.shp") :
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Delete("c:/tmp/dummy1.shp")
#
gp.OverwriteOutput = 1
gp.MakeFeatureLayer_management(inFC,"tlayer","PLABEL# &amp;lt; 3")
gp.Project_management("tlayer",outFC,outPrj,geoTrans)

try :
&amp;nbsp;&amp;nbsp;&amp;nbsp; if sys.argv[1].upper() == 'ALL' :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstTile = range(1001,1013)
&amp;nbsp;&amp;nbsp;&amp;nbsp; else :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstTile = [ tile for t in sys.argv[1].split(",")]
except :
&amp;nbsp;&amp;nbsp;&amp;nbsp; lstTile = range(1001,1013)
print "begin extent_xy"&amp;nbsp;&amp;nbsp;&amp;nbsp; 
for t in lstTile :
&amp;nbsp;&amp;nbsp;&amp;nbsp; print t
&amp;nbsp;&amp;nbsp;&amp;nbsp; parcel(t)
&amp;nbsp;&amp;nbsp;&amp;nbsp; plabel(t)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reproject-a-point-with-arcpy/m-p/165801#M12745</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T08:38:49Z</dc:date>
    </item>
  </channel>
</rss>

