Tag Info

New answers tagged

1

How about making a script tool via Python? I use the scipy Python module... scipy.stats.linregress() http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html Installing scipy on the top of the ArcGIS Python install is not very straightforward, so beware...


0

I think it is your Select tool which only selects grid_code= 1. The Select Tool selects only what you tell it to select and leaves everything else behind. Therefore with your Copy Feature you are only saving grid_code=1 but nothing else. # Process: Select arcpy.Select_analysis(polygon, polyselect, "\"grid_code\" = 1")


1

I came up with a solution. It sounds complicated but we are looking at six tools and an iteration here! I copy my Shapefile A, use the dissolve Tool to dissolve shapefile A by Name. Then I use this created Shapefile as a in the Split Tool as the Split feature for Shapefile A. I insert into my model Iterate Feature and chose my Split output as a Workspace ...


0

It seems that: Use Summary Statistics on "Shapefile A" with Statistics Field Size and Case Field Name to generate a table with Name frequency and sum_size. This table can be reused as an input in your iteration if you have multiple "Shapefile B"s. Use Join Field to join the summary statistics output table to "Shapefile B" based on Name, adding only the ...


0

You mentioned that you are open to a Python solution, which is good because automating this process with Python is much easier and more flexible than a ModelBuilder approach. First, import the necessary modules import arcpy, os Define the workspace that contains all of the folders with the Landsat imagery arcpy.env.workspace = r'C:\imagery' Specify ...


2

I actually just did something very similar to this in another script, so I'll drop this here if anyone finds it useful. It's 10 lines if you remove the comments. import collections #Summarizes the second number in a list of tuples by the occurrences in the first #e.g., [["a", 1], ["b", 2], ["a", 3], ["c", 7], ["d", 0], ["c", -1]] -> #{'a': 4, 'c': 6, ...


0

Ok, The model is ready: It takes every Band from the main folder and sub folders to do a "Composite Bands". The result is saved in an "Ouput Path". A "Calculate Value" was used to just rename the result with the desirable part of the original name, avoiding, for instance, the double ".tif.tif". The SubModel didn't change :)


0

I've just written this for a similar task. It's for 10.2 but I think it will still work: def unique_values(table, field): with arcpy.da.SearchCursor(table, [field]) as cursor: dict = sorted({x[0] for x in cursor}) print type(dict) #testing to find type for i in range(len(dict)): whereD = dict[i] fname = whereD[0:5] + "_" + whereD[-4:] #just to ...


2

Before getting to the solution to your question, I need to clarify exactly what you're wanting to divide/compare. If you're wanting the areas in all of red vs all of green, you can skip this part. However, if you want to directly compare the areas of name and type within the same total boundary, you'll need to first clip red to the extents of green. Your ...


0

I've made some modified and an additional tools to make this Model Builder a final one. I ran this on test and this works very nicely !! I would like to thank Erica for her help to make this possible


2

I would use an UpdateCursor approach. You will first need to add a new text field to your FC so that you can store the commas. You cannot add commas to integer, float, or double type fields: arcpy.AddField_management(fc, "newField", "TEXT") Then loop through your rows and apply the proper formatting (e.g. convert 300000.456 to 300,000) newValue = ...


2

What's the end goal? If you simply want to display the numbers rounded to whole values with thousands separators, you can do so using Number Formatting within ArcGIS. Search the documentation for "thousands separator" to see all the places this formatting can be configured. You can use that Python string in a Calculate Field function. Before you can ...


1

This is a pretty straightforward task. Hopefully this will get you started: import os, arcpy folders_in = [] #Build this manually or with os.walk()/os.listdir() folders_out = [] exp = '"{:,}".format(!SUM_Acres_!)' #Loop over each folder and get the shapefiles inside for f_in, f_out in zip(folders): arcpy.env.workspace = f_in shapefiles = ...


2

Create two models. One main and one sub. In the sub model, iterate through a folder to pick up the individual bands. Add Collect Values at the end of the model. Refer to the tool documentation for usage info. In the main model, call the sub model and pass the output from collect values to the composite bands tool.


1

How about this: Manually add the 2 fields to your watershed featureclass because at the moment the iterator will try and run that logic every time. So the Rb_Test_EZG layer feeds directly into the iterator. Your iterator output I_Rb_Test_EZG could feed into 2 Field calculate tools that pass in the integral and value values using in-line substitution to ...


4

Alternatively, you can create a string field and calculate the following into it using python: {:,}'.format(!SUM_Acres_!)


11

Two approaches are possible, depending on what your goal is. Display Purposes Only, Don't Want Extra Field This isn't a function in ModelBuilder, but rather a question of how the number is being displayed in the attribute table. Here's how to change that (based on these instructions): Right-click on the field heading (SUM_Acres_) and choose "Properties" ...


2

The simplest solution is probably to create a topology with the Must Not Overlap rule, select all errors in the Error Inspector window, right-click and choose Substract: You can find out how to create a topology here if necessary. You can create the topology, add feature classes and rules with ModelBuilder with the tools from the Topology toolset, but you ...


0

The code below (which comes from one of my training courses) does the key part of what you are describing. Basically, it takes an input polygon feature class (testFC) on which you have run Polygon Neighbors to create a table (NEIGHBOURS). The feature class has an extra field called NEIGHBOURS (Text, 100) added. What the code does is to: Make a Table ...


4

A shapefile is a kind of feature class, like an FGDB feature class or an SDE feature class. Use iterate feature classes in modelbuilder. You can then output as a feature class, and if it is named correctly (c:\path\to\directory\that\exists\output.shp) you will get a shapefile out.


5

It has already been created. Try SplitLayerByAttributes


0

One way this can be done is in a python script. You'd need to ask for the name of the field you are interested in (in your case it would be the county code) and extract unique values from its rows with a SearchCursor. You could save the data to a list and then iterate through the list and use a where clause with arcpy.Select and output each separate ...


1

I'm guessing based on your final image that while the green does provide 100% coverage, it is broken up into separate polygons - otherwise (if it were a single giant polygon) you'd be getting nothing selected. The problem is your Relationship choice. Within means that only whole polygons (not areas or parts of polygons) from layer A that lie within a ...


2

As far as I am aware you can not get the sequential display of interactive model dialogs that you want in standard model builder. Chaining the submodels in model builder gives you the complete list of all the parameters in the GUI, as you have found out. To simplify the GUI, you would have to switch to a Python toolbox, which gives the option of ...


1

Unfortunately, at the moment (ArcGIS 10.2.2) you cannot initiate opening multiple models. You would need to have several models created within a toolbox and then user will need to run each of them. I suggest taking a look at Python toolboxes. There you can create categories for parameters (this can move you a bit closer to what you want). You will be able ...


1

The raster equivalent to the Make Feature Layer tool that is often mentioned on this site is Make Raster Layer (Data Management): Creates a raster layer from an input raster dataset or layer file. The layer that is created by the tool is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is ...


2

I use this function in python to test if a layer has a selection: def hasSelection(lyr): ''' Check whether specified layer has a selection. ''' import arcpy desc = arcpy.Describe(lyr) if len(desc.FIDSet) == 0: # Layer has no selection return False else: # Layer has a selection return True


0

You'd use an iterator if you've already got the expressions to feed in... In combination with that, you need logic Get Count, see this below - ironically in the very 1st picture it shows the very ModelBuilder logic you want to apply before a buffer execution: Get Count (Data Management) Desktop » Geoprocessing » Tool reference » Data Management toolbox ...


2

Yes, if ModelBuilder finds a corrupt file or if any of the processing fails at any point, the model will stop and you will receive an error message. You may be able to handle, or bypass, some of these errors within ModelBuilder. ModelBuilder has rudimentary error handling capabilities using Python code block in the Calculate Value tool. There is a very ...


1

If you are running a model you created using Model Builder and one of your datasets fails for whatever reason, the tool will stop running. However, if you are using an iterator, any data created as an output prior to the iteration with the failure should still exist. For example, if you are using Model Builder to iterate through 100 rasters and perform ...


0

I ended up having to use Feature Analyst (extension from Overwatch) and used "Image Fusion" tool and clicked "custom", clicked band 1 and input a script assigning values to elevation classes. Then I used batch processing in Lidar Analyst extension to batch process all of the rasters this way. I think regular GIS tools sometimes have trouble handling a lot of ...


3

I adapted the solution to move / shift points point into a certain direction (angle) and a given distance. Looks like: def shiftXYCoordinates(shape,angle,distance): point = shape.getPart(0) point.Y += distance * math.cos(math.radians(angle)) point.X += distance * math.sin(math.radians(angle)) return point and be called like shiftXYCoordinates(!SHAPE!, ...


2

You would need to have a column in your input feature class which will represent the RouteName (i.e., feature1 and feature2 belong to routeA; feature3 and feature4 belong to routeB and so on). After you've prepared the input feature class (or maybe you already have one), you would need to use the Add Locations GP tool to load the stops into an existing ...


0

To address your first question of how "to sum the acreage of matching "WUNAME" and populate the "WU_Acre"", I would use the Summary Statistics (Analysis) tool which: Calculates summary statistics for field(s) in a table. You would use a case field of WUNAME to get the SUM of your WU_Acre field. I recommend you get this first part working before ...


1

The problem in your current method, and the reason summarizing afterward as @Branco suggests would not work, is that your spatial join operation creates the first attribute you want (total points per poly) while it destroys/eliminates the second variable (owner) you want to summarize. In order to summarize, you need whatever variables you want in the same ...


1

The definition query of the layer and zooming to is the easy part: import arcpy # Assuming that Value is set by the form, there is only one data frame # and the layer name is LayerName doc = arcpy.mapping.MapDocument("Current") dataFrame = arcpy.mapping.ListDataFrames(doc)[0] # the first data frame MapLayers = ...


0

Instead of using all those if...elif statements, you might find it easier to use a dictionary: def gst(old_value): old = ['P00', 'P09', 'P01', 'P02', 'P03', 'P04', 'P05', 'P06', 'P10', 'P11'] new = ['A91', 'A91', 'A89', 'A90', 'A90', 'A40', 'A40', 'A40', 'A40', 'A40'] return dict(zip(old, new)).get(old_value)


3

On your return statement - remove the colon at the end. i.e.: def gst(old_value): if old_value == 'P00': return A91 Also, if A91 is not an existing variable, and you want to have it as a string - you must enclose it in quotes -> 'A91'


1

If you have two sources, first join them together, either by spatial or attribute criteria. Then you can use columns of both data sources in the Field calculator. Field calculation examples using code blocks and multiple parameters.


0

Absolutely. I'd suggest skipping ModelBuilder and go for an ArcPy based solution. You would need to iterate through the table with county codes and states and for each code/state (depending on your business logic) select and export shapefiles. Take a look at search cursors. Select Layer By Attribute or Make Feature Layer will help you when setting the SQL ...


0

PolyGeo has it right, you must connect the data, in this case both datasets need to be connected to the merge command. It seems though you may be a little confused about what you are trying to do. The merge tool takes the two inputs and puts them together into one output: If you have shapefiles A and B and merge them to C then C contains all of the features ...


0

The next step is to connect your data and tool. This is described in a documentation page entitled Adding and connecting data and tools under the heading Connecting data and tools. There are two ways to connect variables to tool parameters: using the Connect tool or the tool's dialog box.


13

I really like Aarons answer, but something more simple and local: subprocess.Popen([r"C:\Program Files (x86)\Windows Media Player\wmplayer.exe",r"C:\Users\Public\Music\Sample Music\Maid with the Flaxen Hair.mp3"]) using the subprocess module cause windows media player to open a file.. import subprocess wmPlay = r"C:\Program Files (x86)\Windows Media ...


13

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with ...


0

Create a CSV file: Low,High,Val 0,1,1 1,2,2 2,3,3 3,4,4 4,5,5 It is best to import it to a dbf, INFO or GDB table after entering the text values. Then use Reclassify by Table, it doesn't care what the ranges of individual rasters are. According to the documentation, build the statistics first then run this tool (iteratively if you like). From_value_field ...


0

Try something like this: import arcpy def turn_off_layers(mxd, df): for lyr in arcpy.mapping.ListLayers(mxd, "", df): lyr.visible = False mxd.save() def print_layers(mxd,df): for i,lyr in enumerate(arcpy.mapping.ListLayers(mxd, "", df)): lyr.visible = True mxd.save() arcpy.mapping.ExportToPDF(mxd, ...


0

I've recently revisited this tool that was giving me problems. I finally found out what the issue was. The tool was writing hundreds of feature classes to a feature dataset. Once that number got to be above a couple hundred, the performance slowed and the tool would only iterate 27 times. If I switch the writing of the feature classes to a different FGDB ...


0

USE A SELECT BY ATTRIBUTES "TEST" = 'A' OR "TEST" = 'B' THEN USE THE MERGE TOOL THIS ALLOWS YOU TO ESSENTIALLY SELCT OUT TO A NEW FEATURE CLASS AND DROP ANY EXTRA FIELDS TOO THE DELETE TOOL IS SLOW, THE DELETE FIELD IS SLOW, AND EDIT SESSIONS CAN BE A PAIN


3

You can use Calculate Field to do the work for you. The attached model adds a new field "b" and calculates that field based on a bit of Python code.


0

Here is a slightly different approach to your problem... Instead of storing the descriptive information in the column 'b', import your shapefile into a file geodatabase and create a coded value domain with the value (column 'a') and description (column 'b'). This way, the end-user will see a more descriptive information when looking at your data.



Top 50 recent answers are included