<?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 Script to Project Shapefiles in a folder in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237146#M13451</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok...even if it succeeds in your if else block it isn't going to project the file and you aren't giving it a coordinate system, just a name, also, you should add an arcpy overwriteoutputs line so you can experiment and overwrite stuff otherwise you will get a whole load of other errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 Oct 2015 21:11:43 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2015-10-25T21:11:43Z</dc:date>
    <item>
      <title>Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237145#M13450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 14pt;"&gt;I am &lt;EM&gt;very, very&lt;/EM&gt; new to Python and I am trying to write a script that will allow me to Project shapefiles into a coordinate system that is assigned to one particular shapefile in a folder. So I have 4 files and one has that which I want to re-Project the others into. What I am struggling with is the output CS parameter required by the Project_management tool when called in the script. I get an error message saying that the output Coordinate System value and the outputFC parameter is not valid. I'm wondering where I'm going wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 14pt;"&gt;Any help at all would be so greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 14pt;"&gt;&amp;nbsp; Sincerely,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 14pt;"&gt;Natasha&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SR6.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/133232_SR6.jpg" style="width: 620px; height: 371px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Oct 2015 21:05:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237145#M13450</guid>
      <dc:creator>natashaGregory-Michelman</dc:creator>
      <dc:date>2015-10-25T21:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237146#M13451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok...even if it succeeds in your if else block it isn't going to project the file and you aren't giving it a coordinate system, just a name, also, you should add an arcpy overwriteoutputs line so you can experiment and overwrite stuff otherwise you will get a whole load of other errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Oct 2015 21:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237146#M13451</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-10-25T21:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237147#M13452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Natasha,&lt;/P&gt;&lt;P&gt;It looks like you are printing "hooray" if the don't match (!=) and trying to project them if they do.&amp;nbsp;&amp;nbsp; Try changing the != to ==&amp;nbsp; for the first part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, as Dan mentioned, you have issues with you output, in fact the path set in the variable output isn't used.&amp;nbsp; But, that is all part of the learning process.&amp;nbsp; My guess is that is the reason you are creating the script, and not just running it once manually, then double clicking the command in the results tab and changing the input and output shape file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 00:09:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237147#M13452</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-10-26T00:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237148#M13453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;​  Hmm thankyou Rebecca. I am trying hard to get this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   So I'll try changing the syntax but I'm still not sure where the output&lt;/P&gt;&lt;P&gt;CS is supposed to be iterated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  The print statements were just supposed to iterate which shapefiles were&lt;/P&gt;&lt;P&gt;supposed to be projected, or not.​&lt;/P&gt;&lt;P&gt;I'm still unclear as to how this section is useful but I suppose it is&lt;/P&gt;&lt;P&gt;because I at least have a set of files that I know should be re projected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So where should I put the == statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  What I want to accomplish is putting together a script that would&lt;/P&gt;&lt;P&gt;reproject shapefiles in a folder in different projections to one which I&lt;/P&gt;&lt;P&gt;have set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     I appreciate any continued help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Thankyou Rebecca&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Sun, Oct 25, 2015 at 8:10 PM, Rebecca Strauch, GISP &amp;lt;geonet@esri.com&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 00:27:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237148#M13453</guid>
      <dc:creator>natashaGregory-Michelman</dc:creator>
      <dc:date>2015-10-26T00:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237149#M13454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Natasha,&lt;/P&gt;&lt;P&gt;A tip for the future, when posting a question, it will help others help you if you follow the tips here &lt;A href="https://community.esri.com/migration-blogpost/1070" target="_blank"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;​&amp;nbsp;&amp;nbsp;&amp;nbsp; But since it was a short script, I went ahead and started playing with the code myself.&amp;nbsp; Dan had some good comments (and some help sources that you should look thru), but I've re-written the code...keeping the main flow of your script....but have the actual project comment commented out.&amp;nbsp; I haven't quite got the correct syntax for that yet, but this may help you see some of the other issues you have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATED:&amp;nbsp; this should work.&amp;nbsp; Update your paths, and the targetFC of course.&amp;nbsp; You had several this that needed fixing.&amp;nbsp; Read thru this and hopefully you will see what it all means, but ask questions if it doesn't make sense.&amp;nbsp; Keep in mind that shapefiles have a .prj file to assign the projection, and if this is missing the command will have problem projecting.&amp;nbsp; A missing projection will cause issues for any feature class, but shapefiles in particular are a bit more simplistic, so to speak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

#setup pathc
targetFC = r"c:\__projIn\gmu.shp"
filesToExamine = r"c:\__projIn"
outputFCpath =&amp;nbsp;&amp;nbsp; r"c:\__ProjOut"

# get SR for targetFC
targetDescribe = arcpy.Describe(targetFC)
targetSR = targetDescribe.spatialReference
targetSRName = targetSR.Name

print targetSRName

# get a list of shapefiles
arcpy.env.workspace = filesToExamine
fcList = arcpy.ListFeatureClasses()

# loop through the list
for fc in fcList:
&amp;nbsp; fcDescribe = arcpy.Describe(fc)
&amp;nbsp; fcSR = fcDescribe.spatialReference
&amp;nbsp; fcSRName = fcSR.Name
&amp;nbsp; print fcSRName
&amp;nbsp; if fcSR.Name == targetSR.Name:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "hooray"
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "No"
&amp;nbsp;&amp;nbsp;&amp;nbsp; outFC = arcpy.os.path.join(outputFCpath, fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(fc, outFC, targetSR)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:57:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237149#M13454</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T11:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237150#M13455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rebecca I am looking through this reply and I very much appreciate you&lt;/P&gt;&lt;P&gt;response and I am so new to Python that I am thoroughly confused.&lt;/P&gt;&lt;P&gt;I also appreciate Dans replies and I am learning from all of it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;outFC = arcpy.os.path.join(outputFCpath, fc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the above line confuses me as I don't know where to put os and Ive not&lt;/P&gt;&lt;P&gt;understood it nor have we used it in  our syntax however I will try to&lt;/P&gt;&lt;P&gt;incorporate it in my code and accommodate what you so generously have&lt;/P&gt;&lt;P&gt;helped try to write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I will go through the documentation that you and Dan have&lt;/P&gt;&lt;P&gt;advised me to do both in posting and in realizing the skillset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankyou very much, very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Natasha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    I'm trying right now and again, I appreciate your assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Sun, Oct 25, 2015 at 8:53 PM, Rebecca Strauch, GISP &amp;lt;geonet@esri.com&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 01:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237150#M13455</guid>
      <dc:creator>natashaGregory-Michelman</dc:creator>
      <dc:date>2015-10-26T01:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237151#M13456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFC = arcpy.os.path.join(outputFCpath, fc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joins the output path/folder and the input feature class name, so the output will not overwrite the input. This will create a new &amp;lt;fc&amp;gt;.shp in the output folder I set up as a variable at the top of the script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....Once you feel you have your answer, make sure to mark one of the comments as "answered" and any others you find as helpful.&amp;nbsp; This will help others find the solution, and will close this thread. thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 01:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237151#M13456</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-10-26T01:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237152#M13457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rebecca this is really helpful and I so appreciate it.&lt;/P&gt;&lt;P&gt;  Thanks so much for this information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will follow your direction as per information on the GeoNet site.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again. Many thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Sun, Oct 25, 2015 at 9:44 PM, Rebecca Strauch, GISP &amp;lt;geonet@esri.com&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 01:52:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237152#M13457</guid>
      <dc:creator>natashaGregory-Michelman</dc:creator>
      <dc:date>2015-10-26T01:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237153#M13458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Happy I could help.&amp;nbsp; By the way, unless this is for a class (in which case you do need to work on figuring things out yourself), don't have an hesitation about using code that is posted.&amp;nbsp; I good programmer (in my opinion) is always trying to put themselves out of work....but there is no reason to reinvent the wheel.....unless you are trying to clean code up and/or make it faster, etc.&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many threads on geonet re: learning python.&amp;nbsp; Here are a few that you may want to check out.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/121021"&gt;Seeking advice on how to go about learning Python&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/docs/DOC-1773"&gt;Python: Getting Started&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/docs/DOC-3070"&gt;Think Python: How to Think Like a Computer Scientist&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/531357"&gt;Re: Mastering Python&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/docs/DOC-3114"&gt;Introduction to Writing Geoprocessing Scripts with Python 10.2/10.3 Class Resources&lt;/A&gt; &lt;/P&gt;&lt;P&gt;And Dan has quite a few blog posts on many advanced topics....he has a list of the blogs&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/55036"&gt;NumPy and Python... lists, link, samples and esoterica...&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Python can be great fun.&amp;nbsp; Good luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2015 02:09:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237153#M13458</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-10-26T02:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237154#M13459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan I found what you were talking about in the Project 2 sample script:&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/project.htm" title="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/project.htm"&gt;Project—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankyou&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 01:35:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237154#M13459</guid>
      <dc:creator>natashaGregory-Michelman</dc:creator>
      <dc:date>2015-10-27T01:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Project Shapefiles in a folder</title>
      <link>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237155#M13460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it was only a matter of time&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt; keep at it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 01:55:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/python-script-to-project-shapefiles-in-a-folder/m-p/237155#M13460</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-10-27T01:55:17Z</dc:date>
    </item>
  </channel>
</rss>

