<?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: Use arcpy to calculate areas in a different coordinate system in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364564#M28804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan, I never knew that toolset existed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to capture the area value and write it directly to a pre-existing field, rather than have it create a new field?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The other option would be create the new field, copy the new field to the existing field, and then delete the new field I suppose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Nov 2015 00:55:30 GMT</pubDate>
    <dc:creator>AnthonyCheesman1</dc:creator>
    <dc:date>2015-11-04T00:55:30Z</dc:date>
    <item>
      <title>Use arcpy to calculate areas in a different coordinate system</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364562#M28802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an arcpy process generates a summarised dataset for me from a source dataset. Due to the limitations of our corporate spatial library, the source data (and my summarised data) are geographic (GDA94).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My summarised dataset has an AREA_HA field (area, hectares) and I would like to automatically populate that field as part of the summary process. I would like this calculation to be performed in the GDA94 VG94 projected coordinate system (shape@hectares doesn't provide the accuracy I need).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a little at a loss as to how to do this programatically. I've had a look at spatial references (arcpy.SpatialReference) but it doesn't seem to do what I am looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone advise how I would go about this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 00:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364562#M28802</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2015-11-04T00:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to calculate areas in a different coordinate system</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364563#M28803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As long as you know what coordinate system you want the values in, you can use the existing tools in arcmap in the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/add-geometry-attributes.htm" title="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/add-geometry-attributes.htm"&gt;Add Geometry Attributes—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; tool, the code example will show that you can use an optional spatial reference rather than the coordinates of the existing data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 00:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364563#M28803</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-11-04T00:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to calculate areas in a different coordinate system</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364564#M28804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan, I never knew that toolset existed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to capture the area value and write it directly to a pre-existing field, rather than have it create a new field?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The other option would be create the new field, copy the new field to the existing field, and then delete the new field I suppose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 00:55:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364564#M28804</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2015-11-04T00:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to calculate areas in a different coordinate system</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364565#M28805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes...via code...my suggestions would be to leave fields that have calculated values intact, and produce the results of a new operation in a new field thereby preserving the legacy information.&amp;nbsp; Once could also string this tool with delete field in a small scriptlet should one really really be adverse to having both sets of data there.&amp;nbsp; It is a matter of preference and desired work expenditure.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 01:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364565#M28805</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-11-04T01:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to calculate areas in a different coordinate system</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364566#M28806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Dan mentioned, it's sometimes nice to keep track of the x/y from both coordinaste systems.&amp;nbsp; In the project I am working on right now, I need the x/y in my projected system, and in DD, DDM, and DMS, and I'm keeping two feature classes for the field.&amp;nbsp; Below I've included a simplified snippet of my script (which selects polygons, creates random points, grabs elevation, and added all the coordinates...more than is needed here).&amp;nbsp; This won't run as is, since I have some hardcoded variab les below that you will have to work with, but you should be able to see how you can go about adding the additional fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&amp;nbsp; (....EDIT: added code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import modules
import time
import arcpy
from arcpy import env

# Set the Geoprocessing environment...Hardcoded to NAD83....change if needed
geoSR = arcpy.SpatialReference(4269)

# Script arguments...
ProjDir = r"C:\_beartest"
studyPoly = r"C:\_beartest\Prep.gdb\Unit20A_edit"
stydGDB,stdyFile = os.path.split(studyPoly)
arcpy.env.workspace = stydGDB
arcpy.env.overwriteOutput = True 

# Local variables...
#&amp;nbsp;&amp;nbsp; grabs the Spatial Reference of the study area, so save to fiel, and for reproject
srDesc = arcpy.Describe(studyPoly).spatialReference
srName = "'{0}'".format(srDesc.name)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #format ends up being "'the_text_here'"&amp;nbsp; notice "' '"
srWkid = "'{}'".format(srDesc.PCSCode)
print("&amp;nbsp; -&amp;gt;Initial Projection of {0}: {1}; WKID: {2}".format(stdyFile, srName, srWkid))

#&amp;nbsp; prep.gdb is typically where this is written, with the project folder...
prepFGDB =&amp;nbsp;&amp;nbsp; ("{0}\prep.gdb".format(ProjDir))

#&amp;nbsp; there are many temp FCs that are created in this process
randomPtSet&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.os.path.join(prepFGDB, "Pts{0}b".format(TransSeriesNo))&amp;nbsp; # will add elevation value to this
finaltmp1X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.os.path.join(prepFGDB, "Pts{0}1X".format(TransSeriesNo))
finaltmp2X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.os.path.join(prepFGDB, "Pts{0}2X".format(TransSeriesNo))&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#
finalOutdd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.os.path.join(prepFGDB, "Pts{0}_dd".format(TransSeriesNo))
finalOutProj&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.os.path.join(prepFGDB, "Pts{0}_{1}".format(TransSeriesNo, srWkid.strip("'")))
#
Point_Count = "0"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # so point number for the series starts at Series number * 100

arcpy.AddXY_management(randomPtSet)&amp;nbsp; 

# create list of fields to add..&amp;nbsp;&amp;nbsp;&amp;nbsp; 
lstAddFields = [["projtd_x", "DOUBLE", "13", "5", "", "x"], 
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["projtd_y", "DOUBLE", "13", "5", "", "y"], 
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["xyProj", "TEXT", "", "", "50", "xyProjection"],
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["xyProjID", "SHORT", "6", "", "", "xyWKID"],&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["ptdd_lat", "DOUBLE", "9", "7", "", "lat_dd"], 
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; ["ptdd_long", "DOUBLE", "11", "7", "", "long_dd"]] 

# Add fields from list above
print("-&amp;gt;Adding Fields....")
for addFld in lstAddFields:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("&amp;nbsp;&amp;nbsp; ...{}".format(addFld[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(randomPtSet, addFld[0], addFld[1], addFld[2], addFld[3], addFld[4], addFld[5], "#", "NON_REQUIRED")


# grabbing X/Y coordinates and the source study area projection name and wkid
arcpy.CalculateField_management(randomPtSet, "projtd_x", "!POINT_X!", "PYTHON_9.3", "")
arcpy.CalculateField_management(randomPtSet, "projtd_Y", "!POINT_Y!", "PYTHON_9.3", "")
arcpy.CalculateField_management(randomPtSet, "xyProj", srName, "PYTHON_9.3", "")
arcpy.CalculateField_management(randomPtSet, "xyProjID", srWkid, "PYTHON_9.3", "")

# adding POINT_X and POINT_Y geographic (long/lat) coords WITHOUT projecting...
#&amp;nbsp;&amp;nbsp;&amp;nbsp; and calculate these DD fields so Long has negative sign instead of W at end
arcpy.AddGeometryAttributes_management(randomPtSet, "POINT_X_Y_Z_M", "", "", geoSR) # "4269")
arcpy.CalculateField_management(randomPtSet, "ptdd_long", "!POINT_X!", "PYTHON_9.3", "")
arcpy.CalculateField_management(randomPtSet, "ptdd_lat", "!POINT_Y!", "PYTHON_9.3", "")

# NOTE: ConvertCoordinateNotation actually PROJECTs the source and outputs a new layer
&lt;SPAN&gt;#&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fdesktop.arcgis.com%2Fen%2Fdesktop%2Flatest%2Ftools%2Fdata-management-toolbox%2Fconvert-coordinate-notation.htm" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/convert-coordinate-notation.htm&lt;/A&gt;
# The tool projects the output to the spatial reference specified. If the input and output coordinate 
#&amp;nbsp; systems are in a different datum, then a default transformation is used based on the coordinate 
#&amp;nbsp; systems of the input and the output and the extent of the data.

# Converting the random points to the geoSR hardcoded around line 89
# NOTEL commented line would add in same format as the calc field above, but same default fieldnames as DD_2, so
#&amp;nbsp;&amp;nbsp; would be DDLat_1 and DDLong_1...I prefer to set to ptdd long and ptdd_lat rather than have the _1
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ConvertCoordinateNotation_management(finaltmp1X, finaltmp2X, "POINT_X", "POINT_Y", "DD_2", "DD_NUMERIC", "", geoSR )&amp;nbsp; 
# So calculate:
#&amp;nbsp;&amp;nbsp;&amp;nbsp; to decimal degrees with N/S/E/W designation at end (vs. ptdd_ versions above that have W/S as negative)
arcpy.ConvertCoordinateNotation_management(randomPtSet, finaltmp1X, "POINT_X", "POINT_Y", "DD_2", "DD_2", "", geoSR )&amp;nbsp; 
#&amp;nbsp;&amp;nbsp;&amp;nbsp; to degree-decimal minutes
arcpy.ConvertCoordinateNotation_management(finaltmp1X, finaltmp2X, "POINT_X", "POINT_Y", "DD_2", "DDM_2", "", geoSR )&amp;nbsp; 
#&amp;nbsp;&amp;nbsp;&amp;nbsp; to degree-minutes-seconds
arcpy.ConvertCoordinateNotation_management(finaltmp2X, finalOutdd, "POINT_X", "POINT_Y", "DD_2", "DMS_2", "", geoSR) 

# projecting back to initial, so have projects and DD versions
print("finalOutProj: {0}".format(finalOutProj))
arcpy.Project_management(finalOutdd, finalOutProj, srDesc) 

# Process: Delete temp files...
tempFiles = [randomPtSet, finaltmp1X, finaltmp2X]
for tmp in tempFiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(tmp):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(tmp)

print(' \n !!! Success !!!&amp;nbsp; ')
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:58:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364566#M28806</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T16:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to calculate areas in a different coordinate system</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364567#M28807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an addendum to my code above, I've moved on to my next step in which case I grab the coordinates and other fields.&amp;nbsp; In testing, I'm noticing &lt;EM&gt;the "SHAPE@XY" of both the projected and geographic point featureclass do not match up to the stored values.&lt;/EM&gt;&amp;nbsp; I'm looking into it, and my guess is it is a projection issue.&amp;nbsp; Not exactly sure why (using standard wkid) but will put in a tech support ticket.&amp;nbsp; just fyi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Nov 2015 19:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-calculate-areas-in-a-different/m-p/364567#M28807</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-11-30T19:39:42Z</dc:date>
    </item>
  </channel>
</rss>

