|
POST
|
@Jeremy: The link you posted is for creating tools in .NET (C# or VB.Net). @Dwight: Here is the dummy code for the tool you are envisioning. However, I wonder why you need two parameters to get the input text file! One parameter of type 'Text File' should do. The output parameter (5th parameter of the tool) is set after you convert the lines (SetParameterAsText). You won't see it on tool dialog as its type is set to 'Derived'. However, if you drag-drop the tool on a Model - you'll see the output is automatically added to chain this tool to following tools. Anyway, if it is not a one-time solution you are looking for, it is recommended that you dig in the links Dale posted. import arcpy
import os
in_path = arcpy.GetParameterAsText(0)
in_file = arcpy.GetParameterAsText(1)
in_text_file = os.path.join(in_path, in_file)
out_path = arcpy.GetParameterAsText(2)
out_file = arcpy.GetParameterAsText(3)
out_csv_file = os.path.join(out_path, out_file)
try:
#output = open(out_csv_file, "a")
#inputfile = open(in_text_file)
#for line in inputfile:
# line = line.replace("|", ",")
# output.write(line)
#
#inputfile.close()
#output.close()
arcpy.SetParameterAsText(4, out_csv_file)
arcpy.AddMessage("done")
except Exception as ex:
arcpy.AddError(ex)
... View more
06-12-2012
01:48 PM
|
0
|
0
|
3048
|
|
POST
|
Which version of ArcGIS you are on? Please add another print statement in the try block and see whether you get any success message. try:
gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION")
print gp.GetMessages()
except:
print gp.GetMessages(2)
... View more
06-12-2012
10:05 AM
|
0
|
0
|
785
|
|
POST
|
After you set an empty string (red) for the search_distance parameter: gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION") Please enclose the call with try-except block as follows: try:
gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION")
except:
print gp.GetMessages(2) What error message do you get now?
... View more
06-12-2012
07:29 AM
|
0
|
0
|
1752
|
|
POST
|
Not possible in Python - yet. As Dan mentioned in the other thread work is underway to create tools or provide arcpy function to carry spatial adjustment but that will not be available in 10.1. You can use ArcObjects code in .Net (or Java) to automate the process. You'll get example codes and informative links in this SDK topic: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000042w000000
... View more
06-11-2012
07:59 PM
|
1
|
0
|
1017
|
|
POST
|
May not be possible in ModelBuilder. You need to chain the same sequence of tools in a Python script and use that script in a script tool. Script tool has tool validator class through which you can control validation. If you want to do so, start here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Customizing_script_tool_behavior/00150000000t000000/ To get started with creating script tools, start here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_creating_script_tools/001500000006000000/
... View more
06-11-2012
07:31 PM
|
0
|
0
|
914
|
|
POST
|
Try this workflow: Add a field ORIG_AREA of type Double to your buff_water. In the attribute table, right-click on ORIG_AREA and select Field Calculator. Set ORIG_AERA equal to Shape_Area. I'm making a duplicate of the Shape area for use in a later step. Use Make Feature Layer to make a layer from your vegetation polygons (even if you are in ArcMap). Pay special attention to Field Info parameter and don't forget to check mark the Use Ratio Policy for Shape field (see screenshot below). Name the output as vegetation_Layer. [ATTACH=CONFIG]15119[/ATTACH] Run Clip tool with with buff_water as input and vegetation_Layer as clip features. Name the output of Clip as buff_water_Clip. This output will look like vegetation layer but will contain attributes of buff_water. Add a field VEG_RATIO of type Double to buff_water_Clip. This field will contain the percentage of vegetation in each buff_water polygon - here is how you calculate the percentage. Open the attribute table of buff_water_Clip. Right-click on VEG_RATIO field and select Field Calculator ... - Select Python as parser. In the code block set VEG_RATIO as: ( !Shape_Area!/ !ORIG_AREA!) * 100 Add another field called VEG_TYPE of type TEXT/string to buff_water_Clip table. Now calculate VEG_TYPE using Calculate Field tool. Open Calculate Field tool and set parameter values using the screenshot below: [ATTACH=CONFIG]15118[/ATTACH] In case the image is not clear, use this as Expression: calc_veg_type(!VEG_RATIO!) Use use this chunk of code in Code Block section - change the return value as per your requirements: def calc_veg_type(field): if field >= 10.0: return 'Vegetated' return 'Not vegetated'
... View more
06-11-2012
03:38 PM
|
0
|
0
|
934
|
|
POST
|
Does the workflow run successfully on Desktop? If you can share your model & data then we can try to reproduce the issue and find what's going on. Thanks.
... View more
06-11-2012
01:00 PM
|
0
|
0
|
1363
|
|
POST
|
Just tested the code I posted above (obtained from http://www.pythonware.com/library/pil/handbook/image.htm) with some files having multiple dots in their names such as: IMG.Churro.ecf.PNG Spider.man.IMG.4181.PNG IMG.ecf.JPG The output thumbnails came out as: IMG.Churro.ecf.thumbnail Spider.man.IMG.4181.thumbnail IMG.ecf.thumbnail If you want the extension of the thumnail image, change this line of code: img.save(file_loc + ".thumbnail", "PNG") To this line: img.save(file_loc + ".thumbnail.png", "PNG")
... View more
06-11-2012
11:20 AM
|
0
|
0
|
944
|
|
POST
|
This code is working fine on 10.0 - in my script tool I only have one parameter - the path to the folder. in_path = arcpy.GetParameterAsText(0)
for root, dirs, files in os.walk(in_path):
for f in files:
existing_file = os.path.join(root, f)
file_loc = os.path.splitext(existing_file)[0]
try:
img = Image.open(existing_file)
thumb_size = 128, 128
img.thumbnail(thumb_size, Image.ANTIALIAS)
img.save(file_loc + ".thumbnail", "PNG")
except:
arcpy.AddMessage("Skipping, not an image :" + existing_file)
pass # not an image file
... View more
06-11-2012
10:12 AM
|
0
|
0
|
944
|
|
POST
|
What is your sep variable? What values are expected for this parameter? I'm trying to reproduce your case. Thanks.
... View more
06-11-2012
08:21 AM
|
0
|
0
|
944
|
|
POST
|
If you really want a pop-up dialog you can create a script tool. For your convenience I'm attaching a python script tool as a zip file. When unzipped, you'll see following files there: PopUp.tbx - a toolbox containing a script too and a Model. pop_up_script - the source script of the tool. calling_script - how to call the tool from another stand-alone script. python_window.txt - how to call the tool from Python window. In ArcMap, browse to the location of the toolbox (unzipped folder). From the toolbox open the script tool - whatever text value you enter will be returned as a text. For this particular tool, it changes all character to upper case and returns it. If you need help - start here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_creating_script_tools/001500000006000000/
... View more
06-09-2012
09:32 PM
|
1
|
1
|
7160
|
|
POST
|
Here is an example where I have two feature classes input_1 and input_2. Input_1 has 6 polygons - labelled with object IDs 1, 2, 3, 4, 5, 6 and colored yellow. Input_2 also has 6 polygons - labelled with object IDs 23, 24, 25, 26, 27, 28 and colored green. [ATTACH=CONFIG]15089[/ATTACH] Between them, 3 polygons from each of the inputs overlap (leaf green - 1, 3, 4 from Input_1 and 24, 27, 28 from Input_2). Thus the output will have 9 features as Input_1 OIDs 1, 3, 4 and Input_2 OIDs 24, 27, 28 are unioned into 3 features. Each input has a field called Weight - these fields will be transferred to the output. In the output table, Input_1 (yellow) has no overlapping features (with OIDs 23, 25, 26) from Input_2 and thus has no corresponding attribute value for Weight field. As the Weight values are coming from Input_1, of the 9 output rows, these 3 rows will have 0 value (which means no value in this case). The Weight field carried over from Input_2 to the output will be named Weight_1 (although field label will be Weight) as there cannot be two fields with same name. Input_2 has no overlap with 2, 5, 6 of Input_1 and thus no corresponding feature in the output. Weight_1 values for these 3 rows will have a value of 0 as well.
... View more
06-09-2012
08:28 PM
|
0
|
0
|
751
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 12-18-2019 03:56 PM | |
| 1 | 05-06-2020 01:18 PM | |
| 1 | 07-23-2021 10:33 AM | |
| 1 | 07-28-2020 09:10 AM | |
| 2 | 07-27-2020 04:47 PM |
| Online Status |
Offline
|
| Date Last Visited |
10-25-2021
03:13 PM
|