I think I can make my analysis work if I can fill in the blanks. I know the first two and the distanceList values, but beyond that everything I have tried does not work.
I can only guess it wants you to pass them as parameters before the list rather than as magic numbers e.g
buff_dist1 = 100
buff_dist2 = 200
buff_dist3 = 300
distanceList = [ buff_dist1' ....
Also be aware your "riverbuffer" + ".shp" needs to change name during the iteration to reflect the input distance. Currently it will just overwrite with the same name.
Use something like
"Riverbuffer_" + str(distance) + "_ft.shp"
Thank you so much! What you did makes sense. I am trying to fit that to the template I have since I am only supposed to fill in the blanks, but I cannot figure out how to fill the three middle lines without having to change the rest of the code, which I do not think we are supposed to do. All of the lines are to have something filled in, but those three do not seem necessary for it to work, so I am not sure what would go there. Possibly argument variables? But I think if I did that then I would need to also import sys and change the parameters listed within the buffer analysis.
<SPAN class="comment token">#set a list of 100, 200 and 300ft</SPAN> <SPAN class="comment token">#variables should be snake case btw...</SPAN> distanceList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">100</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">300</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#buffer river by ieterating values supplied in distanceList</SPAN> <SPAN class="comment token">#for every number in distanceList, input this numbe as a variable in the </SPAN> <SPAN class="comment token">#buffer function below</SPAN> <SPAN class="comment token">#within the for loop, the 'distance' variable will represent a distance in your list</SPAN> <SPAN class="comment token">#If you dont pass this in with 'Feet' it will default to metres</SPAN> <SPAN class="comment token">#for the out_feature_class, I'll take this distance value, covert it to a string (str)</SPAN> <SPAN class="comment token">#and add it on to the end of the buffer name (concatenating).</SPAN> <SPAN class="keyword token">for</SPAN> distance <SPAN class="keyword token">in</SPAN> distance_List<SPAN class="punctuation token">:</SPAN> out_feature_class <SPAN class="operator token">=</SPAN> <SPAN class="string token">"riverbuffer_"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>distance<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"_ft"</SPAN> <SPAN class="comment token"># turn your distance into a string with 'Feet' on the end</SPAN> <SPAN class="comment token">#e.g. "100 Feet"</SPAN> distance_ft <SPAN class="operator token">=</SPAN> str<SPAN class="punctuation token">(</SPAN>distance<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" Feet"</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Buffer_analysis<SPAN class="punctuation token">(</SPAN>in_features<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="punctuation token">,</SPAN> distance_ft<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="string token">"buffer for distance "</SPAN> <SPAN class="operator token">+</SPAN> distance_ft <SPAN class="operator token">+</SPAN> <SPAN class="string token">" is done"</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The directions are not very detailed. It says I am to use river.shp as the input and I can define any distances as long as they are in feet. It says to provide user input for the three parameters when implementing the data in PythonWin and each buffer should be named based on its buffer distance (ex. river100).
I attached the python code to the original question and here is an example of the river.shp data.
This will be very simple, however please provide more info such as the intro to your homework and your data.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.