POST
|
Thank you Logan for your quick response, the explanations and your patience :). I will implement more functions to the script, but I think I have no more questions for the moment. Thanks again, Romy
... View more
08-22-2011
11:45 AM
|
0
|
0
|
2317
|
POST
|
Use Feature Layer, not Feature Class. See the comments at the top of my example script. Oh, thanks, I could not see the wood for the trees. The scrips works fine now. I have only two questions left concerning the following lines of python code: outputFCs = [] # is this the indication that the new variable outputFCs contains a list of values? rows = arcpy.SearchCursor(selectingLayer) for row in rows: arcpy.management.SelectLayerByLocation(inputLayer, "HAVE_THEIR_CENTER_IN", row.getValue(selectingLayerShapeFieldName), "", "NEW_SELECTION") count = int((arcpy.GetCount_management(inputLayer))[0]) rowValue = str(row.getValue(selectingFeaturesFieldName)) arcpy.AddMessage("%d feature(s) of layer %s found in layer %s (%s: %s)" % (count, inputLayerName, selectingLayerName, selectingFeaturesFieldName, rowValue)) if (count > 0): outputFC = inputLayerName + "_" + rowValue arcpy.AddMessage("Copying selected feature(s) to %s" % outputFC) arcpy.CopyFeatures_management(inputLayer, outputFC) outputFCs.append(outputFC) #what does the .append function? I have no idea what this line of code does. del row, rows arcpy.SetParameterAsText(4, ";".join(outputFCs)) #SetParametersAsText ist used to give back a result from the script. Is this some kind of text message for the user, saying that some new layers have been created? What does this line of script do? I did not recognize any text messages from the script. And the Desktop Help is a bit confusing for me ("Sets a specified parameter property by index using an object. This is used when passing objects from a script to a script tool. If you need to pass a text value to a script tool, use SetParameterAsText.") Thank you, Romy
... View more
08-21-2011
03:02 AM
|
0
|
0
|
2317
|
POST
|
Hi, today I tried to get the cript running and it does. Unfortunately it copies all features into the input layer and then loops over all 4000 objects and not only the selected houses. I think it has something to do with how I implemented the script in ArcMap. I went to own_toolbox and added the new script. In the script´s Parameters I just added the Selecting Features Layer as a Parameter (Parameter #1 in your script example) but I am not sure wich data type I should select (I used Feature Class) and wich parameter properties to use. All other parameters were set in the script (with full pathnames). If I run the script now, the user is prompted to put in the path of the selecting Features Layer... and I think the previous selection made in ArcMap is not even considered... Can you help me with the correct setup? Thank you, Romy
... View more
08-20-2011
09:52 AM
|
0
|
0
|
2317
|
POST
|
Thank you for your advice and the sample code. The hint with Feature Layer sounds promising. I´ll try to implement that in my code, but won´t be able to do that until tomorrow. I´ll give a short response if the script runs. Thank you very much! Romy
... View more
08-16-2011
10:49 AM
|
0
|
0
|
2317
|
POST
|
Hi Stacy, thank you for the helpful information and examples. I´d like to run the loop for an existing selection of features, that means as a first step the user interactively defines the features that should be further analyzed by my script. Then a loop process should run for every selected feature. I tried to work with an interactive user selection and used the "Feature Set" Tool for this, but it does not work the way I want. I have a layer with lots of houses and one layer with DTM points and I´d like to clip DTM points inside the selection and write them into different files named after the ID of the selected house (I use %ID_house% for this). As a result I should get files with the house ID as name and a bunch of points that lay inside this house. But "feature set" only gives me the points inside the interactively digitized polygons and not the whole house... So my workaround is to make the user do a selection with the ArcMap selection tool first and then run my tool... (please see my Thread here: But you pointed out that Python may ignore this previous selection. What can I do instead? Romy
... View more
08-15-2011
08:12 AM
|
0
|
0
|
2317
|
POST
|
Hi, I have problems to get a loop for selected features running in Python. I built a workflow in Model Builder and exported the script to python. But in Python I get an error message if I try to run it. It says: Python cannot open a toolbox... I get the feeling that the function "iterateFeatureSelection_mb" does not work in py. I could not find it in the Desktop Help, too. Could someone have a look on this. I am new to Python and don´t know how to write this as a loop. Thank you! Posted the code below and attached the model from Model Builder as an image. import arcpy # Load required toolboxes arcpy.ImportToolbox("Model Functions") # Local variables: Solarpot_PotsdamPVend = "Solarpot_PotsdamPVend" DSM_inside_PV_Punkt = "D:\\UniGIS\\MT\\Daten\\Bearbeitung\\MT_Scratch.gdb\\DSM_inside_PV_Punkt" Geb_Geb_ID = "I_Solarpot_PotsdamPVend" Punkt_inGeb__Geb_ID_ = "D:\\UniGIS\\MT\\Daten\\Bearbeitung\\MT_scratch.gdb\\Punkt_inGeb_%Geb_ID%" # Process: Iterate Feature Selection arcpy.IterateFeatureSelection_mb(Solarpot_PotsdamPVend, "", "false") # Process: Clip arcpy.Clip_analysis(DSM_inside_PV_Punkt, Geb_Geb_ID, Punkt_inGeb__Geb_ID_, "")
... View more
08-14-2011
01:33 AM
|
0
|
9
|
20093
|
POST
|
Hello Shitij, thank you, I have tried Feature set and made a model with the model builder to test it. It does work, but unfortunately not in the way I expected. Maybe I am doing something wrong? I used it in ArcMap and defined a feature interactively, but what i got as a selection is a draws polygon (defined schema) and not an interactively selected EXISTING feature. I don´t know how to explain it, but please have a look at the attached image. Can anybody help me with this, please. Thank you, Romy.
... View more
08-12-2011
09:17 AM
|
0
|
0
|
263
|
POST
|
Hi, in the meantime I have figured out how to use a Search and an Update Cursor to acces the result values and write them into a new field of the input data. This works for a single result file. But how to do that for a whole list of files? Also, I still need help with the user input. It should be possible for the user to select a number of object in a fb for wich the analysis should be done. Something like the mouse selction in ArcMap which then creates a list of features to loop through... Any ideas? Thank you, Romy
... View more
08-07-2011
10:07 AM
|
0
|
0
|
263
|
POST
|
Hello everybody, I am currently working on a new tool for ArcGis 10. What I have done so far is to build a workflow combining different tools in the Model Builder. Then I exportet it to a Python script. Now, I want to add a few things to the script which can not be done in the Model Builder. I am a beginner in Python and have difficulties with the next steps. In the attached sketch I made a draft of how the tool should work. 1. How to implement a user-defined selection of the input features that should be analyzed, the user should be able to select the objects that should be analyzed 2. For every selected object an analysis will be performed inside a loop which should create a new output feature (shapefile), these result files should contain the ID of the selected input object as name; (the analyzing process inside the loop is already done ) 3. One or many field values from each output file should be added as a new field(s) to the input file 4. Non-selected objects in the input file should have a "0" in the new field Anybody having ideas for that? A script example with some explanations would be very helpful for me an an Python beginner.
... View more
08-06-2011
10:15 AM
|
0
|
3
|
523
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|