<?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: Python - how to select certain shapfiles in folder for projection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214434#M16525</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bad Joke Friday:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;"You're extra Spatial!"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Apr 2015 23:47:32 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2015-04-10T23:47:32Z</dc:date>
    <item>
      <title>Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214426#M16517</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 am trying to create a python script with 3 parameters;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) &lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;EM&gt;Dataset Folder which contains the shapefile datasets to be reprojected&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;EM&gt;2) &lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;EM&gt;Target Projection Dataset whose spatial reference will be used as specified projection in the reprojection&lt;/EM&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;EM&gt;&lt;EM&gt;3) &lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;EM&gt;Projected Dataset Folder containing projected datasets&lt;/EM&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 00:29:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214426#M16517</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-10T00:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214427#M16518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check the two formats in the help topic for &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018z0000000v000000"&gt;spatial reference&amp;nbsp; &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="n"&gt;dataset&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s" style="color: #a31515;"&gt;"c:/data/landbase.gdb/Wetlands"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;spatial_ref&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Describe&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;dataset&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;spatialReference&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Using a projection file (.prj)&lt;P class="highlight" style="margin: 0 0 0.3em;"&gt;&lt;CODE&gt;&lt;SPAN class="n"&gt;sr&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SpatialReference&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s" style="color: #a31515;"&gt;"c:/coordsystems/NAD 1983.prj"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class="p"&gt;do note the subtle but difference in implementation and case&amp;nbsp; in your case you are mixing the two.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 00:43:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214427#M16518</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-04-10T00:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214428#M16519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This bit is not going to work -&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #1f497d;"&gt;for fc in fcList:&lt;/SPAN&gt;
&lt;SPAN style="color: #1f497d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc != spatialRef:&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;Consider what you are doing here.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;fc is an text item from your list of features.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;But spatialRef from the template describe object is a spatial reference object.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;So they will never be equal.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;Inside the loop you need to do another Describe of each fc, get the SR of that, then compare.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214428#M16519</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-11T10:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214429#M16520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have updated the script with the above suggestion, but it still doesn't work. I even tried template = filepathname, but that didn't work either. is there any other suggestion/comments? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;# Set Workspace&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;#Access shapefiles&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;fcList = arcpy.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;# Projection template&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; template = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;# Output folder&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; outFolder = arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;# Get the spatial reference&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; spatialRef = arcpy.Describe(template).SpatialReference &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;#Loop through shapfiles in folder and reproject&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; for fc in fcList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcspatialRef = arcpy.Describe(fc).SpatialReference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fcspatialRef != spatialRef:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(fc, outFolder + "\\" + fc, spatialRef)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;# Return any errors&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages ())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;# Print shapefile list&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;for fc in fcList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 13:01:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214429#M16520</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-10T13:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214430#M16521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The block after try: should also be indented as well. How about telling us what errors you are getting instead saying "it doesn't work".&lt;/P&gt;&lt;P&gt;Not many clues there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 14:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214430#M16521</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2015-04-10T14:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214431#M16522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Case matters in Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14286884502071016 jive_text_macro" data-renderedposition="71_8_912_16" jivemacro_uid="_14286884502071016"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;spatialRef = arcpy.Describe(template).spatialReference&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Not:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14286884571902605" data-renderedposition="129_8_912_16" jivemacro_uid="_14286884571902605"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;spatialRef = arcpy.Describe(template).SpatialReference&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 17:54:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214431#M16522</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-04-10T17:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214432#M16523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh Sorry Neil. The code in the script is indented thanks to IDLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is happening is all the shapefiles (8) are being reprojected, instead of the 6 shapefiles which have different projections to the template projection shapefile. 1 other file is in the same projection, so it shouldn't be projected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 21:19:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214432#M16523</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-10T21:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214433#M16524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed "Spatial" to "spatial" and I also had to place .Name on the end and change "spatialRef" in Project tool to "template". The script is now working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's confusion because sometimes I see "Spatial" and "spatial"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 21:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214433#M16524</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2015-04-10T21:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python - how to select certain shapfiles in folder for projection</title>
      <link>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214434#M16525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bad Joke Friday:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;"You're extra Spatial!"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 23:47:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-how-to-select-certain-shapfiles-in-folder/m-p/214434#M16525</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-04-10T23:47:32Z</dc:date>
    </item>
  </channel>
</rss>

