Hot answers tagged

6

Slicing should do the trick. To slice a string do this "%var%"[x:y], where x and y are indices representing the start and end positions of the bits of the string you want to keep. The first character of a string has index 0. say you got: var = "myfc_clip" and you want myfc_buffer not myfc_clip_buffer you would do something like this ...


6

I believe you will need to build a small Python script and paste that into your Model. You would use the ArcPy module and build a field list on your layer: fieldList = arcpy.ListFields("C:/Data/MyGIS.gdb/MyLayer") and then you would iterate through the fieldList using a for loop, for example for field in fieldList: #run your spatial analysis ...


6

The easiest solution is to replace the raster calculator with the "Plus" operator in the iterator. The best solution is to use a Python script import arcpy from arcpy.sa import * arcpy.env.workspace = r'your_path_to_directory' for r in arcpy.ListRasters("*"): # list all rasters in workspace outRaster = Raster(r)+1 #perfoms addition ...


6

The way I would set your task up would be to create a custom script which provides greater flexibility than the modeler but can still provide a similar interface to its users. You can create one from: Processing Toolbox > Scripts > Tools > Create new script Then copy/paste the script below and save it into C:/Users/You/.qgis2/processing/scripts. The ...


5

Nest the iterated part in a sub-model. See the "Advanced Use of Model Iterators" section under Integrating a model within a model in the help. Related question: Exporting data from 'collect values' output in ArcGIS model builder


5

@Geoist is right. You'll have much more control over this using Python -- you can nest as many loops as you damn well please. Pseudo Code: Create a search cursor Loop through each record with a for loop Compose a whereClause using the ObjectID (unique identifier) Make feature layer Select by location etc. (delete feature layer to end the loop) Code ...


5

One solution is to use the iterations portion as a completed model, then use that model inside of another that performs the remaining operations on the output of the iteration model. This is called a nested model. Also, consider looking into Python scripting, the options for dropping into and out of iterations are much more flexible.


5

Export your table to a text format. Grab the header row and paste it to a new file. Delete irrelevant column headings (could also turn them off prior to export to avoid this step), and then use find/replace functions to change the delimiting characters to proper syntax for the formula (ie quotes around field names, a plus sign in the middle). Copy and paste ...


4

If you try to output the iterate raster tool directly into raster calculator, you will only see the last iteration in the raster calculator layers and variables list. To get around this nuisance in model builder, use Collect Values to generate a list that you can pass off to Cell Statistics to do your calculations. Simply choose the "MEAN" overlay ...


4

Assuming that your text files are some sort of tables (e.g. CSV having X and Y coordinates in rows with delimited columns), try using 'Iterate Tables' instead of 'Iterate Files'. You will be offered an option of choosing DBF or INFO as the type. Ignore this field. It is optional. You should now be able to connect the output file to the 'Make XY Event ...


4

The ArcGIS help page for iterators in model builder says that you can only have one iterator per model. (It's the first note, below the table of iterator types.) Perhaps that is why you are having trouble trying to use two in the same model. I believe if you want to use multiple iterators in modelbuilder you have to build a model for each one and then nest ...


4

I like to run such things from a file geodatabase to keep all the fields consistent for field mapping in your model. If I interpreted correctly you want to: 1. split your FC by lease type. 2. Dissolve each resulting FC on the lease type and sum the percent interest for that lease type. 3. and then combined all FC's back together. From what I have gathered, ...


4

The input of the While loop should be of boolean data type. I recreated your model and script and called arcpy.SetParameterAsText(1, "FALSE") in the script. For the script output, I used a boolean. ModelBuilder automatically converts the output string "FALSE" to boolean false. The boolean false can be evaluated by the While loop.


4

I usually approach situations like this using a few steps. The general process is to determine the maximum value in each polygon and then determine which points actually has that value: First join a unique identifier from the polygons to the points (Using intersect, spatial join, etc..). This doesn't have to be OBJECTID, but it can be. Then run summary ...


4

I hate to be the bringer of bad news, but your current workflow is probably an inefficient way of reaching your goal. What you should check out is the Spatial Join Tool http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000q000000. It should do, I think, everything you are asking to accomplish if you set up the options right. You'll just ...


4

Use the Calculate Value tool in model builder to drop the last 4 four characters of your Count_Field variable. Set the tool to be a precondition to the alter field tool to ensure it executes first. Set your expression as shown below


4

You could use the Append tool to add your intersect_result to a feature class. First, I would create an empty feature class to store your outputs in, then just add the append tool to your model after your Intersect completes. Make the empty feature class the Target dataset and the intersect_result the input dataset. You can save yourself some trouble ...


4

I was able to get this to work by: Specifying that Workspace is a Precondition to Create File GDB Using %Name%\%Name% as the File GDB Name, not as part of the location This results in the desired output:


4

To answer your specific question "How to iterate through layers of an MXD?" mxd = arcpy.mapping.MapDocument("CURRENT") # Uses your currently open MXD df = arcpy.mapping.ListDataFrames(mxd, '')[0] # Chooses the first dataframe for lyr in arcpy.mapping.ListLayers(mxd, '', df): # Loop through layers # Any tools you want to run on each layer go here ...


3

Two iterators are allowed within a model as long as you embed a model within a model. Check out the advanced use of model iterators section on the integrating a model within a model help page.


3

In the sub model, insert "Collect Values" after the iterator. You find it in the model builder menu "Insert" -> "Model Only Tools"


3

So problem solved. This post encountered a similar issue. It's possible to ignore the field selection in the join field tool. I was not able to use add join and run the iterators successfully. http://forums.arcgis.com/threads/73410-Model-Builder-Using-iterator-and-Add-Join-tools-to-join-tables The starting materials for this process is a spreadsheet of ...


3

Near by Group Something like this sounds like what you need. Conceptually, this question can be answered by the Near tool (what is the nearest feature?). However, the question also contains a constraint *(with the same attributes*?) that is not directly supported by the Near tool. To answer the full question additional ModelBuilder techniques must be ...


3

You need to feed the output of the iterator (green blob) into a make featurelayer tool which would then feed into your selectbyattribute tool.


3

The following python code should help you calculate the distances from points to their corresponding median point. The script creates a new field in your point file and stores the distance to the median point. This script assumes that the point file and median point file have a common field that relates the points to the median points. If you generate the ...


3

I'm not sure how to manage your changing neighborhood size, but here is already an answer. Iterate Rasters runs the same tool/chain of tools for a series of datasets in the specified workspace, so it's not going to do what you need. If you want to reuse the output of the model as input a number of times, you should do the following: Right-click the input ...


3

As a shapefile FIDs' are contiguous and 0 based, you can use that to your advantage: import sys, os, arcpy InFC = sys.argv[1] # must be a shape file OutFC = sys.argv[2] # change as appropriate DivisorSize = 1000 BufferDistance = 100 TempDir = os.environ.get("Temp") MaxFeat = int(arcpy.GetCount_management(InFC).getOutput(0)) StepRange = ...


3

The ultimate in stupidity. All I was missing (in any of the ways I approached it) was "QUOTATION MARKS" around the expression. ie. Expression = "%Value%" if using Parse Path, or "%Name%" if not using Parse Path


3

You need to separate your model into two models. As you have it now, the results table gets created with every iteration. Step 1 needs to be in separate model that calls a sub model, which performs the rest of the steps. Refer to this help file on how to set up nested models.


3

Wouldn't it be more straight forward to: create a list ordered by distance between sales point and closest dealer Iterate that list until you have collected the 40% of sales volume The distance to the last one is the buffer value you are seeking. btw, it can be done with one sql-query (with or without the final buffering)



Only top voted, non community-wiki answers of a minimum length are eligible