Hot answers tagged

12

You can go to Data Management -> Raster -> Raster Processing -> Clip, and Spatial Analyst is not needed. There just check the checkbox "Use input features for clipping geometry". From help: If the checkbox "Use input features for clipping geometry" is checked, then the output raster is clipped based on the perimeter of the polygon shape. If the checkbox is ...


11

As you have discovered, Windows paths contain a single backslash, but in Python a single backslash is an escape character. You have a few options: 1) You can use a raw string (r"stringgoeshere"), or os.path.normpath(), as detailed in this blog post. 2) In order for Python to understand that a string contains a path you need to use double backslashes. So ...


10

You don't say what license or version you are using, but assuming you have ArcInfo, it is possible to use the "Near" geoprocessing tool to find the nearest object in the same layer. From the tool help page: The same dataset can be used as both Input Features and Near Features. When an input feature's nearest feature is itself (NEAR_DIST is 0), this ...


9

A sample code for a script tool which will have a single check box. If a check box will be checked by a user, the tool will verify existance of a specified data file. import arcpy input_fc = r'C:\GIS\Temp\data_shp.shp' #getting the input parameter - will become a tool parameter in ArcGIS of Boolean type ischecked = arcpy.GetParameterAsText(0) #...


9

That's not built into the application, but I assume running the batch file that sets up the virtualenv in a cmd.exe session and then running arcmap.exe from the same DOS box should get you your virtualenv. ArcMap and friends will modify the path slightly to include the install's arcgisscripting and arcpy. Edit: you will need to explicitly call the ...


9

Assuming your tool is always outputting the output file in the same directory, this function will return the next highest-numbered file name: import os def getNextFilePath(output_folder): highest_num = 0 for f in os.listdir(output_folder): if os.path.isfile(os.path.join(output_folder, f)): file_name = os.path.splitext(f)[0] ...


9

To add a custom toolbox, in ArcMap or ArcCatalog, open ArcToolbox and right click in the white space and go to Add Toolbox: To see the script, right click on the tool, and go to Edit or Export Script. If you use Export Script, create a new text file and select it when exporting. You might need to go into the Geoprocessing menu, and go to Geoprocessing ...


8

Right-click on the toolbox in ArcToolbox and select Save As specifying 9.3 as the outgoing version. I ran into this problem previously, it is wise to copy your 9.2, 9.3 etc toolboxes to a new location prior to loading into version 10. I should add, that user toolboxes won't be available by default in version 10 even though they may have been so in 9.x. ...


8

I figured out how to do this by using the Make Query Table tool, Copy As Python Snippet, the Python window and the Copy Features tool. After running the Make Query Table tool to pull through just the fields I wanted to appear in the output I was able to Copy As Python Snippet this code from the Geoprocessing | Results window into the Python window of ArcMap....


8

This help topic discusses some of the raster format limitations for Spatial Analyst: Data formats supported by Spatial Analyst While it is focused mainly on vector overlay operations, this blog post has many suggestions, including improvements made at 10.1 and 10.1 SP1. In particular, if you are working with very large datasets, then using 64-bit ...


8

I believe the AreaOnAreaOverlayer is the transformer that performs the equivalent of an ArcGIS Union. Performs an area-on-area overlay so that all input areas are intersected against each other and resultant area features are created and output. The resultant areas have all the attributes of all the original features in which they are contained.


7

Every mainstream version control software, be it central central version control like SVN or distributed solutions like Git, Mercurial, Bazaar etc. allow storage of binary files. They are all quite effective both performance-wise and also in terms of occupied space. Inspecting differences between revisions/versions of a file is of course different story. ...


7

Based upon your comments in other responses, it sounds like you really just want to alert the user about things that have occurred during the operation of your script, rather than necessarily keep the script dialog box open. A couple of alternative approaches could be: Write the pertinent information back to the ArcGIS GP console by adding messages, ...


7

The only thing I see in your code that could cause this problem is that you are setting the MXD value to "CURRENT", which is fine... IF you have an MXD open (executing the script tool from within ArcMap). I was able to cause your code to fail with the same response if I tried executing the code form the stand-alone ArcCatalog application. Is that what you ...


7

To get the result you are looking for you need the inputs in your model to be empty when you save it and they both need to be set as parameters. Do this by right clicking on them in model building and choosing 'Model Parameter'. You can set up everything else, but leave the input and/or target parameters blank. Then when you open the tool the user will ...


7

If you stay with the tools, you can first select all the fields then unselect the ones that you want to keep. You could also create a Python script to do this, but if you don't have a fixed rule and you need to enter the field names manually, this will not help. import arcpy # if you can use a key to identify the fields to remove, then it's solved ...


7

After running the tool navigate to the 'Results' window, right click on the process and select "Copy As Python Snippet".


6

To see how to get a checkbox onto the dialog of a Python script tool try using some test code like this: inputString = arcpy.GetParameterAsText(0) inputBoolean = arcpy.GetParameterAsText(1) arcpy.AddMessage("String set to " + inputString) arcpy.AddMessage("Boolean set to " + str(inputBoolean)) Then when you add this script as a tool you will need two ...


6

Alternatively, you could proceed as followed: Use the aggregate tool on your input data to create a coarser raster with the same extent. Convert the resulting raster to points. Use these points to sample the original grid. The key here is the aggregation factor which controls the degree of generalization of your input data, e.g. the spacing of the ...


6

Try sys.argv[0], on Windows it will return the full path to the currently running script.


6

In my personal experience, no. Looking at the product matrix, there is also nothing to indicate they would groom their performance as such. http://www.esri.com/library/brochures/pdfs/arcgis10-functionality-matrix.pdf I would suggest running some test cases with the same data, stored locally, on the same computer, with different licenses in order to ...


6

That's just the statistics. By default it is set to the minimum and maximum possible values. If you use the 'Calculate Statistics' tool from the toolbox it should set those to more meaningful numbers. If you don't want to calculate statistics in your layer properties you can change the minimum and maximum values of the display manually if you have a ...


6

I agree with afalciano. You can create a model that combines the two tools, that could look like this: It would give you a interface that offers both selection types: DonĀ“t forget to set the Selection type of the second selection to "SUBSET_SELECTION" This model could then be called from a python script importing the toolbox using arcpy.ImportToolbox()...


6

You can set the value of the parameter to the values you want to be checked, at least when using a Python Toolbox. The same should be true for your case. For example: def getParameterInfo(self): p = arcpy.Parameter() p.datatype = 'String' p.multiValue = True p.name = 'test' p.displayName = 'Test' p.parameterType = 'Required' p....


6

This help topic should get you started -- basically you embed your toolbox in a Python package and install it in your local Python installation. Then your tool should show up automatically under system toolboxes.


6

At the bottom of the help page for each tool, ESRI provides a list of the environments that can impact the tool's processing. For example, the Resample help page does not include Mask in its list. It does not include Cell Size in its list either, because the cell size option that is a direct and required input to the tool would overwrite it anyway. The ...


5

"I don't believe there is an issue due to the fact that my routes cross the 180/-180... I believe ArcMap understands how to handle those circumstances." Not in WGS84, no. A feature cannot cross the international date line. You must break it at the international date line or it will throw a bad geometry. Too many bad geometries, and the tool bails out. ...


5

Currently I have the workflow of ArcCatalog: opening toolbox > selecting model > editing > file > export > to python, switch to SCM tool > refresh changes > commit changes (enter log comment). It's cumbersome so I don't do it so much, and thereby lose many of the benefits of versioning.


5

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 ...


5

When your command is run inside ArcMap (should work in ArcCatalog and other applications as well): var arcToolBoxExtension = _app.FindExtensionByName("ESRI ArcToolbox") as IArcToolboxExtension; if (arcToolBoxExtension != null) { var arcToolBox = arcToolBoxExtension.ArcToolbox; var gpTool = arcToolBox....



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