<?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 Change linear unit of spatial reference for geometry in cursors? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451842#M35394</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I want to change the spatial reference linear unit for geometry calculations. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know you can pass the sr object in cursor, so I tried this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I read from the document that linearUnitName is both readable and writable. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sr = arcpy.Describe(inLine).spatialReference sr.linearUnitName = "Foot" cursor = arcpy.da.SearchCursor(fc, ["SHAPE@"], "", sr)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but it looks not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone help?:D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to find points along polylines based on distance, so I need the distance in another unit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What else could I do?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Dec 2013 22:21:55 GMT</pubDate>
    <dc:creator>ZachLiu1</dc:creator>
    <dc:date>2013-12-09T22:21:55Z</dc:date>
    <item>
      <title>Change linear unit of spatial reference for geometry in cursors?</title>
      <link>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451842#M35394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I want to change the spatial reference linear unit for geometry calculations. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know you can pass the sr object in cursor, so I tried this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I read from the document that linearUnitName is both readable and writable. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;sr = arcpy.Describe(inLine).spatialReference sr.linearUnitName = "Foot" cursor = arcpy.da.SearchCursor(fc, ["SHAPE@"], "", sr)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but it looks not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone help?:D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to find points along polylines based on distance, so I need the distance in another unit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What else could I do?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2013 22:21:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451842#M35394</guid>
      <dc:creator>ZachLiu1</dc:creator>
      <dc:date>2013-12-09T22:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change linear unit of spatial reference for geometry in cursors?</title>
      <link>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451843#M35395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
cursor = arcpy.da.SearchCursor(fc, ["SHAPE@"], "", sr)
&lt;/PRE&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are two separate SearchCursors, the top-level one, and the one within the data access module. The data access module one that you're using above is designed for performance, and in doing so loses some of the flexibility of the top-level one. Try changing the call to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
desc = arcpy.Describe(inLine)
sr = desc.spatialReference
sr.linearUnitName = "Foot"
shapefieldname = desc.ShapeFieldName

rows = arcpy.SearchCursor(fc, "", sr)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname) # this feature should be reprojected.
&amp;nbsp;&amp;nbsp;&amp;nbsp; # do further manipulations as needed with the feat
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should work, and the documentation for arcpy.SearchCursor states "spatial_reference: When specified, features will be projected on the fly using the spatial_reference provided.".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Shaun&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451843#M35395</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2021-12-11T20:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Change linear unit of spatial reference for geometry in cursors?</title>
      <link>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451844#M35396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for help. It is still not working for some reason. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to test if I can change the linearUnitName of the spatial reference by &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 sr = desc.spatialReference
 sr.linearUnitName = "Meter"
 print sr.linearUnitName
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but it is not changed at all.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:10:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451844#M35396</guid>
      <dc:creator>ZachLiu</dc:creator>
      <dc:date>2021-12-11T20:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Change linear unit of spatial reference for geometry in cursors?</title>
      <link>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451845#M35397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All right, thanks to the post on Arcpy Cafe, I figured this out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://arcpy.wordpress.com/tag/spatialreference/" rel="nofollow" target="_blank"&gt;http://arcpy.wordpress.com/tag/spatialreference/ &lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like changing sr.linearUnitName doesn't change the spatial unit, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but this solution works!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Dec 2013 13:36:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-linear-unit-of-spatial-reference-for/m-p/451845#M35397</guid>
      <dc:creator>ZachLiu1</dc:creator>
      <dc:date>2013-12-10T13:36:27Z</dc:date>
    </item>
  </channel>
</rss>

