<?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 Calc Latitude, Longitude Field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474030#M37067</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After getting a lot of requests to get latitude and longitude coordinates for features, I created a generic script that creates two new fields in the existing feature feature class and and calcs the latitude and longitude of the feature's "true centroid." The only problem is that you would have to run this script any time a feature's geometry was changed. I did some searching for something that already existed and didn't find anything that was simple and generic enough, so please let me know if you can do it better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

fc = r"C:\temp\working.gdb\temp_fc"

# Define and create longitude/latitude fields
## Longitude is X, Latitude is Y
fieldsNew = ["GCS_WGS_1984_X", "GCS_WGS_1984_Y"]
fieldsExisting = {f.name: f.type for f in arcpy.ListFields(fc)}
for fNew in fieldsNew:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add field if it doens't already exist
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fNew not in fieldsExisting.keys():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc,&amp;nbsp; ## in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fNew,&amp;nbsp; ## field_name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "DOUBLE",&amp;nbsp; ## field_type
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; # If data type of existing field is not a Double, throw Exception
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif fieldsExisting[fNew] != "Double":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise Exception(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Existing {} field is type {}. Must be 'Double'".format(
&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; fNew, fieldsExisting[fNew]
&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; )
# Update fields with GCS_WGS_1984 lat/long
print("Updating Field values")
fieldsNew.append("SHAPE@")
GCS_WGS_1984 = arcpy.SpatialReference(4326)
with arcpy.da.UpdateCursor(fc, fieldsNew, "", GCS_WGS_1984) as u_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in u_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = row[2].trueCentroid
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = point.X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = point.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; u_cursor.updateRow(row)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/group/1519" target="_blank"&gt;python snippets&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:57:27 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-12-11T20:57:27Z</dc:date>
    <item>
      <title>Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474030#M37067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After getting a lot of requests to get latitude and longitude coordinates for features, I created a generic script that creates two new fields in the existing feature feature class and and calcs the latitude and longitude of the feature's "true centroid." The only problem is that you would have to run this script any time a feature's geometry was changed. I did some searching for something that already existed and didn't find anything that was simple and generic enough, so please let me know if you can do it better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

fc = r"C:\temp\working.gdb\temp_fc"

# Define and create longitude/latitude fields
## Longitude is X, Latitude is Y
fieldsNew = ["GCS_WGS_1984_X", "GCS_WGS_1984_Y"]
fieldsExisting = {f.name: f.type for f in arcpy.ListFields(fc)}
for fNew in fieldsNew:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add field if it doens't already exist
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fNew not in fieldsExisting.keys():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc,&amp;nbsp; ## in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fNew,&amp;nbsp; ## field_name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "DOUBLE",&amp;nbsp; ## field_type
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; # If data type of existing field is not a Double, throw Exception
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif fieldsExisting[fNew] != "Double":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise Exception(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Existing {} field is type {}. Must be 'Double'".format(
&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; fNew, fieldsExisting[fNew]
&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; )
# Update fields with GCS_WGS_1984 lat/long
print("Updating Field values")
fieldsNew.append("SHAPE@")
GCS_WGS_1984 = arcpy.SpatialReference(4326)
with arcpy.da.UpdateCursor(fc, fieldsNew, "", GCS_WGS_1984) as u_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in u_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = row[2].trueCentroid
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = point.X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = point.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; u_cursor.updateRow(row)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/group/1519" target="_blank"&gt;python snippets&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:57:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474030#M37067</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T20:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474031#M37068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you look at: &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000191000000"&gt;Add Geometry Attributes (Data Management)&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question: what if your input featureclass does not have a sr WGS 1984 and it needs a specific transformation? Will the output coordinates be correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For polylines I prefer to use the midpoint of the line (&lt;EM&gt;positionAlongLine (0.5, True)&lt;/EM&gt;) over the center of gravity...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jun 2015 23:02:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474031#M37068</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-06-08T23:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474032#M37069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great points, Xander. I don't think I saw AddGeometryAttributes_management(). Or maybe I did but didn't see that you could specify the coordinate system. I'll do some testing with that!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have not needed to use a a specific transformation so have not tested it. What is a scenario I could use to test this? I don't understand what you mean when you say it "does not have a sr WGS 1984."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the lines, I agree, a midpoint would be better. I just didn't want to write extra code to check the geometry type and do different things. Point features are obviously preferred so anything else requires some compromise. That would be a good enhancement though, to do different calculations of feature to point conversion based on the geometry type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also thought maybe instead of hard-coding the field name, I could just make a new field using the current date/time in the name. That would let me get rid of the field name and data type check and it would also hint that the field's values were calculated in a batch process separately from editing the geometry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jun 2015 23:39:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474032#M37069</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-08T23:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474033#M37070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the datum (underlying GCS of the coordinate system) of the input is not WGS84, then a transformation is required if you want WGS84 based coordinates to come out.&lt;/P&gt;&lt;P&gt;I have never actually used the spatial reference option when opening an Update cursor. Generally, the feature exists and it knows what coordinate system it is in.... The help files here are unclear as to how this option affects the outcome.&lt;/P&gt;&lt;P&gt;I have in the past used the .projectAs(SR2) method on the geometry object to re-project geometries on the fly inside python. Specifying a transform is a little trickier and you have to set this via environment setting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 08:34:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474033#M37070</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-06-09T08:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474034#M37071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/5327"&gt;Neil Ayres&lt;/A&gt; is right that you can project a geometry using you code and apply the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//003r00000011000000"&gt;transformation&lt;/A&gt; to it. However, it is not necessary to do this in the environment settings as you can use the the second (optional) parameter of the &lt;EM&gt;arcpy.Geometry::projectAs (spatial_reference, {transformation_name})&lt;/EM&gt; function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example of requiring a transformation is projecting data in Colombia from GSC_Bogota to MAGNA_Colombia_Bogota. This would require multiple steps (projections) and when going from GCS_MAGNA to GCS_Bogota, the transformation Bogota_To_MAGNA_Region_5_MB should be applied (according to specifications here). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the transformation is not specified another transformation could be applied resulting in an inaccurate on-the-fly projection of the geometry and yielding inaccurate output coordinates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case these types of problems do not affect you, there is no problem. However, specifying a different spatial reference (sr) then your input as parameter of a cursor may have unexpected side-effects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About the field names, you could use a very specific name that a normal user would unlikely create him/herself or create a tool and let the user define the names of the output fields. In case they exist verify it during validation or simply return an error. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 12:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474034#M37071</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-06-09T12:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474035#M37072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there an easier way to just convert state plane coordinates to decimal degrees without reprojecting? Our data is in NAD_1983_HARN_StatePlane_Arizona_Central_FIPS_0202.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;Looks like the accepted transformation from NAD_1983 to WGS_1984 in the contiguous 48 states of the US is &lt;A href="http://resources.arcgis.com/en/help/main/10.1/003r/003r00000010000000.htm"&gt;NAD_1983_To_WGS_1984_5&lt;/A&gt;. However, I don't see how to specify a transformation when using &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/0017/001700000191000000.htm"&gt;AddGeometryAttributes_management()&lt;/A&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 14:11:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474035#M37072</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-09T14:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474036#M37073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the tool itself does not provide it, you can use the environment settings:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001w00000005000000"&gt;Output Coordinate System (Environment setting)&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001w0000000v000000"&gt;Geographic Transformations (Environment setting)&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 17:02:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474036#M37073</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-06-09T17:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474037#M37074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did a test of &lt;SPAN style="font-family: 'courier new', courier;"&gt;AddGeometryAttributes_management()&lt;/SPAN&gt; for "POINT_X_Y_Z_M" and it can take 15 minutes to do an SDE feature class with about 80,000 points. I'm not even trying anything fancy with reprojecting, I'm just using the feature class's assigned coordinate system. The output is just Point_X and Point_Y fields. Is this typical performance?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 20:32:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474037#M37074</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-11T20:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474038#M37075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds slow... Will do a test on a local dataset that I have and see how it compares to using the da update cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 21:10:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474038#M37075</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-06-11T21:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474039#M37076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just tried to copy the data to in_memory workspace and do the AddGeometry there thinking it would be faster, but it looks like AddGeomerty won't work with in_memory data. I get an &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ERROR 000732: Input Features: Dataset does not exist or is not supported&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt; I don't see anything explicit in the documentation about this (unlike with &lt;A href="http://resources.arcgis.com/en/help/main/10.2/0017/00170000007m000000.htm"&gt;Project&lt;/A&gt;​, which clearly says in_memory is not a valid workspace).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 21:37:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474039#M37076</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-11T21:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474040#M37077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this tool not modify &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/environments/current-workspace.htm"&gt;a file in-place&lt;/A&gt;?&amp;nbsp; That could be the issue&lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/the-in-memory-workspace.htm"&gt;.&amp;nbsp; in memory&lt;/A&gt; appears to be used for outputs unless the inputs are there as there as well&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 21:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474040#M37077</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-06-11T21:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474041#M37078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;see my comment above&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 21:57:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474041#M37078</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-06-11T21:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474042#M37079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should clarify, My plan was to create a variable that has a path "in_memory"&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;MyInputFC = r"C:\MySDEConn.sde\MyInputFC"
inputFC_inmem = os.path.join("in_memory", "MyInputFC_inmem")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I copy rows from the source to the in_memory workspace&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.CopyRows_management(MyInputFC, inputFC_inmem)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I try to run AddGeometry on the data in memory. This is where it errors.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.AddGeometryAttributes_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputFC_inmem,&amp;nbsp; ## Input_Features
&amp;nbsp;&amp;nbsp;&amp;nbsp; "POINT_X_Y_Z_M",&amp;nbsp; ## Geometry_Properties
&amp;nbsp;&amp;nbsp;&amp;nbsp; "",&amp;nbsp; ## Length_Unit
&amp;nbsp;&amp;nbsp;&amp;nbsp; "",&amp;nbsp; ## Area_Unit
&amp;nbsp;&amp;nbsp;&amp;nbsp; GCS_WGS_1984&amp;nbsp; ## Coordinate_System
)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I would copy the rows back out of in_memory workspace.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:57:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474042#M37079</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T20:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474043#M37080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;​your syntax seems correct&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; import os&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; out = os.path.join("in_memory","myfile")&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; out&lt;/P&gt;&lt;P&gt;'in_memory/myfile'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so I don't know why it can't find it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 23:34:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474043#M37080</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-06-11T23:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474044#M37081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It takes a good 20 seconds for the copy rows to complete, so I'm sure it's actually creating the in_memory data. My guess is that AddGeometry just can't work its magic in an in_memory workspace.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 00:09:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474044#M37081</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-12T00:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474045#M37082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is what I started with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ngs.noaa.gov/PC_PROD/SPCS83/" title="http://www.ngs.noaa.gov/PC_PROD/SPCS83/"&gt;PC Software Download - SPCS83&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source code is in FORTRAN, but It is easily decipherable.&amp;nbsp; It took me a few days to translate it into Javascript and it works very fast (I put it in my mousemove event).&amp;nbsp; No ESRI or GIS - It stays in the program. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ngs.noaa.gov/PC_PROD/pc_prod.shtml#SPCS83" title="http://www.ngs.noaa.gov/PC_PROD/pc_prod.shtml#SPCS83"&gt;http://www.ngs.noaa.gov/PC_PROD/pc_prod.shtml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has a bunch of these conversion programs available for public consumption.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brent Hoskisson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jun 2015 14:44:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474045#M37082</guid>
      <dc:creator>BrentHoskisson</dc:creator>
      <dc:date>2015-06-16T14:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calc Latitude, Longitude Field</title>
      <link>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474046#M37083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just realized I was using copy rows instead of copy features so it was trying to add geometry attributes on a table instead of a feature class. DOH! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/blush.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using in_memory workspace to calculate X/Y is about twice as fast (compared to in a file geodatabase) on a point feature class with just over 80,000 rows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2015 22:05:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calc-latitude-longitude-field/m-p/474046#M37083</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-17T22:05:11Z</dc:date>
    </item>
  </channel>
</rss>

