Tag Info

Hot answers tagged

13

If the length of the ID field values is always constant I would recommend using either Field Calculator or Calculate Fields tool with python slices. TOWN calculation: !ID![:8] ERF calculation !ID![8:16] PORTION calculation !ID![-5:]


7

A good starting point to understanding this is a help page entitled Understanding the progress dialog box in script tools: There are four functions you use to control the progress dialog box and its progressor. This certainly works for foreground Geoprocessing and I assume that it will have a similar effect on the Background Geoprocessing dialog.


5

Ok, based on what I think you are asking for, I think all you should need is: import arcpy toolboxes = arcpy.ListToolboxes() for toolbox in toolboxes: print toolbox tools = arcpy.ListTools('*_'+toolbox[toolbox.index('(')+1:toolbox.index(')')]) for tool in tools: print tool print '\n' Fair warning, this script will print every tool ...


3

Building on @artwork21's excellent answer, the following is how you would accomplish the task with Python using an UpdateCursor. import arcpy # The input feature class fc = r'C:\temp\myfgdb.gdb\yourFC' # Add three new fields arcpy.AddField_management(fc, "TOWN", "TEXT") arcpy.AddField_management(fc, "ERF", "TEXT") arcpy.AddField_management(fc, "PORTION", ...


3

Those coordinate differences are measured in Angstroms. File geodatabase uses a technique similar to the integer storage representation conversion in enterprise geodatabases (ArcSDE) to snap 64-bit floating-point coordinate values to a feature class coordinate resolution grid. This coordinate resolution is established at feature class creation (and it's ...


3

@dvdhns suggestions, are what you should do. However you don't need to write a xslt for html conversion because Esri has done this for your before. see this code snippet: import arcpy from arcpy import env env.workspace = "C:/data" #set local variables dir = arcpy.GetInstallInfo("desktop")["InstallDir"] xslt = dir + "Metadata/Stylesheets/ArcGIS.xsl" ...


3

No. You cannot directly export ESRI Feature Class metadata into PDF files. This is how I would attempt to do it using python, rather than ArcObjects: Use arcpy to export the metadata to xml files. Use python and xslt (xml style sheets) to format the xml files into something human readable, my recommendation is a simply formated txt or html file. Use a ...


2

I have tested it like this: def updateParameters(self): ValuesStr = self.params[0].value Values = ValuesStr.split(';') self.params[1].value = Values[0] self.params[2].value = Values[1] self.params[3].value = Values[2] self.params[4].value = Values[3] isExportFeatureClassStr = Values[4] if isExportFeatureClassStr == ...


2

Have you tested ReconcileVersions_management in data management toolbox? This tool reconciles a version or multiple versions against a target version. It can be used standalone or with python window of ArcMap. However that tool won't pop up the interactive conflict window. To pop up that window I suggest you to create a python addin (a bottom) and set the ...


2

I assume you are trying to convert your scripts so that they can be used in open source software or with open source libraries, otherwise the question's title would not make too much sense to me. First of all you have to be aware that arcpy.AddMessage solely makes sense in one specific context: when used in a script tool that is used within ArcGIS. It does ...


2

ArcPad Checkout from python command line works in arcgis 10.1, but you need to add arcpad toolbox with arcpy.AddToolbox(). this is a working sample script, in this script i pass the path of the axf as first argument in commande line: import arcpy , sys arcpy.env.overwriteOutput = True arcpy.AddToolbox(r"C:\Program Files ...


2

Here's a script I just happened to have lying around, it merges all lines, points and polygons from a database into a new database feature class; there's no field mapping, at this time we just wanted to see all the geometries together without having to load over 1k layers... A feature class (shapefile or database) can only store one geometry type so it's ...


2

You can use an asterisks to specify all of the fields in the feature class. Try the following example: import arcpy fc = r"C:\Users\Scratch\oc.shp" with arcpy.da.SearchCursor(fc, "*") as cursor: for row in cursor: """ row[0] = OID or FID row[1] = Centroid coordinates row[2] = Your 1st field row[3] = Your 2nd ...


2

Out of range means that you are trying to access a field that is not included in your result. Before you use your cursor you have to define which fields you want it to return. Those fields should be entered in a list. In your case you would change this line: catchments = arcpy.da.SearchCursor(oc,"FEATUREID") to something like this: catchments = ...


2

The search cursor second parameter is the field name list. You are only providing one field name that is why it is not going beyond index 0. A list (or tuple) of field names. For a single field, you can use a string instead of a list of strings. Try: catchmentFields = ["FEATUREID", "field2", "field3"] catchments = arcpy.da.SearchCursor(oc, ...


2

You are almost there. You just need to test in the list comprehension you get that the v.name is not equal to certain strings. def getParameterInfo(self): """Define parameter definitions""" param0 = arcpy.Parameter( displayName="Input Features", name="in_features", datatype="GPString", ...


2

Do you have a selection currently applied to testlayer? Do you have a definition query on testlayer? Both of these can limit the number of records in the cursor when executed directly in ArcMap.


2

I figured it out! My question was misguided and sent everyone in the wrong direction, sorry for the confusion folks. The error was that the tool parameters and the command line parameters were not, after all, precisely the same. The "magic" is that when using a Toolbox all paths are converted to fully qualified paths, ..\source\data.gdb\some_layer --> ...


2

When running your tools from the console it is suggested you use the more general sys.argv instead of the arcpy-specific arcpy.GetParameterAsText(). This page from Esri shows you how to use sys.argv. Change all of your inputs to this, and you should be able to run it from the console. mxd = sys.argv[1] clip_layer = sys.argv[2] out_gdb = sys.argv[3] Also ...


1

With arcpy you can only modify the following types of symbology for vectors: Graduated symbols Graduated colors Unique values. You cannot actually change the type of symbology (e.g. from single symbol to graduated colors) but you can change some properties of the symbology type chosen. Using arcpy this is anyway not possible with piecharts, as far as I ...


1

Start by checking if the value is None. If it is, replace the value with this if rowData[idx] is None: rowData[idx] = datetime.datetime(1970, 1, 1, 0, 0)


1

This way it worked fine for me: Try to get symbology in a separate line?


1

I always find it's easiest to first check if your value is not NULL before adding it to a table. For example, say you have a value to be added to your table in variable Value. A simple if statement will do the trick. if will return True if the variable contains a value and is not NULL Code: *processing* = Value if Value: *update table etc*


1

I have tried calling the list as weighted_overlay(variables, other parameters), and using just variables = [] in the function code, which did not work. If you are defining the list outside of the function, you do not want to then redefine it within the function. def weighted_overlay(variables, other parameters): variables = [] print ...


1

I've used filled elevation model (with streams removed) to replicate your coefficients: Keeping in mind that water usually runs downhill :), it is reasonable to expect that all the values in output should be less or equal to the value at start point. I've checked results using difference [Filled]-[ScriptOutput] and found that script (see below) failed ...


1

Try this: # Import arcpy module import arcpy # Check out any necessary licenses arcpy.CheckOutExtension("spatial") # Local variables: c1 = "F:\\img1.tif" c2 = "F:\\img2.tif" c3 = "F:\\img3.tif" output = "F:\\output.tif" # Process: Raster Calculator arcpy.gp.RasterCalculator_sa("(\"%c1%\"+\"%c2%\"+\"%c3%\")/3", output)


1

Is 'rows' defined? Looks like you should be calling for row in testcursor: Try this: # create empty list LayerList = [] # create search cursor testCursor = arcpy.SearchCursor(r'D:\workspace\testlayer') for row in testCursor: if row.getValue("SURVEY_NAME"): survey = str(row.getValue("SURVEY_NAME")) print survey if survey not ...


1

It is about transferring points coordinates to table. You might use this process: Add X and Y fields to points' table Join above to TABLE using common field. Calculate similar field e.g. [XN]=Points!X Export joined table to new one. Create XY event table from output at step 4. Based on your Q you'll end up with duplicate points in some cases.


1

Try this: import os, arcpy, shutil from arcpy import env if os.path.exists(r'E://tmp//ProcData'): shutil.rmtree(r'E://tmp//ProcData') if not os.path.exists(r'E://tmp//ProcData'): os.makedirs(r'E://tmp//ProcData') importFiles = r'E://tmp//RawData' outputFolder = r'E://tmp//ProcData' spatialRef = arcpy.SpatialReference(26917) env.workspace = ...


1

As it turns out this is caused by an "issue" in the env.settings. I used arcpy.ResetEnvironments() and arcpy.ClearEnvironment("workspace") before using the arcpy.arcpy.MakeRasterLayer_management and everything worked as expected. arcpy.ClearEnvironment("workspace") arcpy.ResetEnvironments() AddRasterMxd = ...



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