<?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: Project layer with custom projection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500199#M39307</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What version of ArcGIS are you running? And the problem you are having is the code works in IDLE but not in ArcMap as a tool or through the python window?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, post your code using [CODE ][ /CODE] tags&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Aug 2012 14:36:01 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2012-08-29T14:36:01Z</dc:date>
    <item>
      <title>Project layer with custom projection</title>
      <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500198#M39306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My ultimate goal is to know UTM and UTM Northing and Easting. The data can be anywhere in North america. I calculated UTM using arcpy tool (arcpy.CalculateUTMZone_cartography) and I tried to truncate the value (e.g.'17') to Project_management as part of Output coordinate string but so far no luck. Please advise. I can run the code below in shell but whole MXD collapsed when I try to run in a model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateUTMZone_cartography(outPointSHP, "UTM")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; pointUTM= arcpy.SearchCursor(outPointSHP)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in pointUTM:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UTM_var= str(row.getValue('UTM'))[30:32]
&amp;nbsp;&amp;nbsp;&amp;nbsp; del pointUTM
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(ok)
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_coordinate_system = os.path.join(connectionPath+'/', r"projections/NAD1983/NAD 1983 UTM Zone "+UTM_var+"N.prj")

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(outPointSHP, projPointSHP, out_coordinate_system)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 14:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500198#M39306</guid>
      <dc:creator>DeeptiPuri</dc:creator>
      <dc:date>2012-08-29T14:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Project layer with custom projection</title>
      <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500199#M39307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What version of ArcGIS are you running? And the problem you are having is the code works in IDLE but not in ArcMap as a tool or through the python window?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, post your code using [CODE ][ /CODE] tags&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 14:36:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500199#M39307</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-08-29T14:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Project layer with custom projection</title>
      <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500200#M39308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mathew&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried both 10 and 10.1 and got the same results. Yes the code works fine in IDLE (I get projected layer) but if I run as a tool in MXD, MXD encounters problem and everything closes down. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 14:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500200#M39308</guid>
      <dc:creator>DeeptiPuri</dc:creator>
      <dc:date>2012-08-29T14:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Project layer with custom projection</title>
      <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500201#M39309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post the full code you are executing that works in IDLE?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 15:14:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500201#M39309</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-08-29T15:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Project layer with custom projection</title>
      <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500202#M39310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi Mathew&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It has to do with my cursor. The script was written by someone else where I am trying to add this. There is little done to capture exception and it is huge. I am not sure why my search cursor is failing here.&amp;nbsp; With ok= 17 it works fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;


arcpy.CreateFeatureclass_management(scratch, outPointFileName, "POINT", "", "DISABLED", "DISABLED", srGCS83)
outPointSHP = os.path.join(scratch, outPointFileName)

# Now all we need to do is insert the point into our new shapefile.

cur = arcpy.InsertCursor(outPointSHP)
row = cur.newRow()
# It's unclear to me why *both* of these lines are needed, but it fails without the two-steps...
# What I don't fully understand is why I need "Point" and "PointGeometry"...?

point = arcpy.Point(xCoord,yCoord)
pnt = arcpy.PointGeometry(point)
#Insert the point... 
row.shape = pnt
cur.insertRow(row)
del cur

##new code
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddXY_management(outPointSHP)

&amp;nbsp;&amp;nbsp;&amp;nbsp; ###New Work - Steps to know UTM zone
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Add Field (7)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(outPointSHP, "UTM", "TEXT", "", "", "1500", "", "NULLABLE", "NON_REQUIRED", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Calculate UTM Zone
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateUTMZone_cartography(outPointSHP, "UTM")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Add Field 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(outPointSHP, "Lon_X", "DOUBLE", "12", "6", "", "", "NULLABLE", "NON_REQUIRED", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Add Field 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(outPointSHP, "Lat_Y", "DOUBLE", "12", "6", "", "", "NULLABLE", "NON_REQUIRED", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Calculate Field 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(outPointSHP, "Lon_X", "[POINT_X]", "VB", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Calculate Field 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(outPointSHP, "Lat_Y", "[POINT_Y]", "VB", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get the UTM value to calculate X and Y 
&amp;nbsp;&amp;nbsp;&amp;nbsp; pointUTM= arcpy.SearchCursor(outPointSHP, "", "", "UTM;Lat_Y;Lon_X")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in pointUTM:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UTM_var= str(row.getValue('UTM'))[30:32]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lat_y = row.getValue('POINT_Y')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lon_X = row.getValue('POINT_X')
&amp;nbsp;&amp;nbsp;&amp;nbsp; del pointUTM
&amp;nbsp;&amp;nbsp;&amp;nbsp; ###To generate fields with UTM Northing and Easting 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Project
&amp;nbsp;&amp;nbsp;&amp;nbsp; ok= '17'
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_coordinate_system = os.path.join(connectionPath+'/', r"projections/NAD1983/NAD 1983 UTM Zone %sN.prj"%ok)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(outPointSHP, scratch+'/'+outPointPR, out_coordinate_system)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500202#M39310</guid>
      <dc:creator>DeeptiPuri</dc:creator>
      <dc:date>2021-12-11T21:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Project layer with custom projection</title>
      <link>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500203#M39311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All you are doing is taking the last UTM value and projecting that. I'm not really clear on what this code is doing. It will only ever project one file, are you trying to loop through multiple?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 21:04:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/project-layer-with-custom-projection/m-p/500203#M39311</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-08-29T21:04:30Z</dc:date>
    </item>
  </channel>
</rss>

