Tag Info

New answers tagged

1

With some help from colleagues and lots of googling I found the answer. If you choose "Insert" --> Model only tools --> Parse Path, and connect the Raster Dataset to this, choose Parse type = Name, and Rename the "Value" output from the ParsePath tool to "RasterName", you will get JUST the Raster name if you change the expression (blue, in jpeg above) to ...


0

Finally I solved this problem. I have to use a short python-script: ---------- import arcpy myFeature = arcpy.GetParameterAsText(0) myrows = arcpy.SearchCursor(myFeature) myrow = myrows.next() MyField = myrow.getValue("Offset_Y") arcpy.SetParameter(1, MyField) arcpy.SetParameter(2, True) ----------- Where Parameter 0 as Input is the feature where the field ...


0

It depends what tool your Copy Raster tool is feeding into. If you look at the Syntax section of the help for the tool. The output is a Raster Dataset. Many tools take Layers as inputs so without actually seeing your model I suggest you pass the output of the Copy Raster tool into a Make RasterLayer tool then feed that into the downstream tool?


1

Esri has registered 2 duplicate bugs corresponding to your issue: NIM-103740 - When a model with an iterator is run from within ModelBuilder, it completes correctly, but overwrites the outputs when run as a tool; NIM-098729 - In ArcGIS for Desktop 10.2.1, when running a model with the Iterate Feature tool, an incorrect number of outputs are generated ...


2

There are many Python modules you can use for manipulating Excel sheets: xlutils; xlwt; openpyxl; xlrd You could use any of those that allow modifications on Excel sheet; developing this piece of code is not dependent on ArcGIS in any way. When you have a chunk of code that does the work for you, you can wrap it to a custom Python script tool (or a Python ...


1

If your new fields have a pattern in their naming (e.g., [table_name]_y as in your snapshots), you can use inline variable substitution. More specifically, if you change Field Name parameter to %Name%_y, this will transfer all GRID_CODE values to this field in your individual DBFs.


0

When faced with a problem like this I use os.walk() which returns all files and then see if the files match what I want by extension, here's an example for shapefiles: import sys, os, arcpy InFolder = sys.argv[1] for (path, dirs, files) in os.walk(InFolder): for ThisFile in files: fName,fExt = os.path.splitext(ThisFile) if fExt.upper() ...


1

Please have a look at the second example in here. Most probably your question is related to finding the right term here, which is inline variable substitution.


0

Quick and dirty way of achieving this is to first make "Contour Output" a managed output (i.e., it will be generated in any case as long as you have default/scratch workspace) or save this into a folder location and use Copy Features tool with the inline variables as you used in your "Contour Output". Obviously this one has an extra step but as I said it is ...


0

It seems your code sums the area covered by the polygons. Instead of relying on a field that may or may not exist, and may or may not be correct you can get the area of the shapes at runtime: Assuming that the feature class is in an appropriate spatial reference to sum the area: def MySub(TotalArea1): TotalArea = 0.0 with ...


2

Your sub-model should end with a Collects Value tool (exposed as a parameter). This collects the featureclasses and returns a list to the master model. Your merge tool can take this list as the input.


1

The geopy module is quick and easy for tasks such as this. Straight from the docs: >>> from geopy.geocoders import Nominatim >>> geolocator = Nominatim() >>> location = geolocator.geocode("175 5th Avenue NYC") >>> print(location.address) Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ... ...


2

If the model is outside of ArcMap you will first have to use Make Feature Layer tool, then you may use Select Layer by Attribute tool followed by the Delete Features tool.


0

You can do this in a single step using the Select (Analysis) tool that works on a feature class. If you were planning to Select By Attribute where Field = 'X' and then delete the selected records simply use Select (Analysis) to select records where Field <> 'X' instead.


2

ModelBuilder is old, clunky, and is not getting any significant updates with ArcGIS Pro, if this tweet is any indication. I have never been a big fan of it (though begrudgingly still use it when I have to), so you might consider this answer as a sidestepping of the question and a recommendation to look at alternatives. FME is arguably the most obvious ...


1

After input from radouxju, Martin and Hornbydd and some trial and error I found the Python code below to be working. Problem was mainly the os.path.split(image)[-1][:-5] which was replaced with os.path.basename(image).rstrip(os.path.splitext(image)[1]) import arcpy, glob, os from arcpy import sa #spatial analyst liste_a = glob.glob("d:\\folderA\\*.tif") ...


0

import arcpy, glob, os from arcpy import sa #spatial analyst liste_a = glob.glob("D:\\folderA\\*.tif") #get a list of tif (or other extension) for image in liste_a: #loop on images print image # just checking... image_a = Raster(image) #create raster object based on the raster name image_b = Raster("D:\\folderB\\" + ...


1

If your Have field is of type date and you Needed field type is string, you can do it with the following statement in the field calculator of Arcmap: !DateFieldName!.split( )[1]


-2

Have you tried .replace(X,Y) code in python? -replace one with another in the string


2

The introduction of Python toolboxes at ArcGIS 10.1 for Desktop invalidates your four year old statement that all: Toolboxes, and thus their models, are binary. Standard toolboxes are binary but Python toolboxes (*.pyt) are text files. Consequently, I think Python toolboxes should be considered if version control of source code trumps the requirement ...


2

Take a look at this tool Feature Class To Feature Class (Conversion), the help section contains sample scripts if you want to go the arcpy path. Right clicking on the tool reveals a "batch" option, you can set the names how you want.


2

You could use the Parse Path (ModelBuilder) tool with the input being your MXD. The resulting PATH will be your input to the Create File GDB (Data Management) tool. Below is a simple model showing this. It seems that you cannot use the output value from the Parse path tool as a direct input into the Create File GDB tool. This is probably because the File ...


0

If you want your feature class from your sub model to connect to the Make Feature Layer tool just drop the Collect values tool and expose the MKey_MUL3 output as a parameter in your sub model. Then that should connect in the master model.


0

You can run the output of the Proxy_Background through the copy features tool with the output called in_memory\temp then connect it to your make feature layer tool.


1

If you are running a model from within ArcMap or ArcCatalog, go to Geoprocessing>Geoprocessing Options and put a check in the box next to Overwrite the outputs of geoprocessing operations. If you are going to export your model and run it as a Python script, add this line to your script. arcpy.env.overwriteOutput = 1


2

This can be achieved in several steps. Run a Spatial Join for your buffer polygons and road network layers (right-click the buffer polygons layer in the TOC and choose Join and Relates > Join). You will get an output polygon feature class which contains information on how many road features were located (even partially) within the buffered polygons. ...


1

Here is a bare-bones example (borrowing from both Jim and Richard's answers): import arcpy fc = r'C:\junk\FILE_GDB.gdb\Export_output_gdb' # input feature class field1, field2 = 'Distance', 'Type' # fields to sort, and group fcOut = r'in_memory\blah' # output feature class # set up counters bankcount = 0 churchcount = 0 ...


0

The SearchCursor syntax in the previous comments and posts is outdated and 10 times slower than a data access cursor if you have Desktop 10.1 or later. Only use DA cursors. Here is my script, assuming your categories of banks and churches are in the same field in the feature class, this script will get the top ten items for all categories or only specified ...


1

I think we can handle this using an arcpy.SearchCursor (I still use the Old School SearchCursor) and usage of the arcpy.Select_analysis() tool. The following is probably inefficient but I hope it helps. This assumes the Banks and Churches layer is held in a File Geodatbase (.gdb): import arcpy BanksAndChurches = r'Path\To\BanksAndChurches\FeatureClass' ...


1

Without seeing the model or the exported Python script it is hard to say this definitively but ... If you have the line below in your Python script: arcpy.env.overwriteOutput = True then it should take care of ensuring that what you try to write can be written. Alternatively, you could use two lines like the following to ensure that the outputFC does ...


0

Feature Layers are temporary. Your data currently will only exist for the duration of the model. Per ESRI documentation of Make Feature Layer: Make Feature Layer (Data Management): Creates a feature layer from an input feature class or layer file. The layer that is created by the tool is temporary and will not persist after the session ends ...


2

If Shapefile you can only delete (single delete) one feature set. Or use Iterate with Feature Datasets (Geodatabase) Delete Fields http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000004n000000


2

Personally I would avoid the batch tool approach. Create a sub-model and cycle through the datasets using an iterator deleting the fields as necessary.



Top 50 recent answers are included