Tag Info

Hot answers tagged

8

You can call the GP tools in two ways: arcpy.%toolbox%.%toolname% or arcpy.%toolname%_%toolbox% Both are calling the same function, so there is no difference. It is a matter of taste; I always call functions in the arcpy.Buffer_analysis format because I seem to read the name tool faster in this way (I see first the toolname, and often seeing the ...


4

It works in the python window because JHJ is likely a layer in the map and therefore can be reference in your script as "JHJ". When run outside of Arcmap, you need to tell arcpy where to look. Here are just a few ways you can do this (untested, but it should give you a few ideas): 1) jhj = ...


3

As you suspect arcpy.analysis.Buffer and arcpy.Buffer_analysis are two equivalent ways to run the same tool.


3

The attached (untested) script takes the name of a feature class, splits it by "_" and uses that as a basename for the join operations. The general idea is to use: basename = fc.split("_")[0] which converts, for example, abc_clip_diss to abc Then, you can use that basename to create new variables with os.path.join(): inFeatures = os.path.join(ws, ...


2

This look like there is a null geometry somewhere. To solve this, you should first run the "repair" tool. To avoid you code to crash (as you said that it works for the first polygons), you can add some testing if point: print ("{0}, {1}".format(point.X,point.Y)) else: print "No point"


1

Try setting arcpy.env.workspace to your working directory. e.g., import arcpy arcpy.env.workspace = 'c:/temp/testarcgis/frafil'


1

In AddField, provide the full path to JHJ or change your workspace (arcpy.env.workspace) to r"C:\temp\TestArcGis\FraFil" before AddField.


1

I can see 2 issues in you script: You're missing the second join_field parameter in arcpy.JoinField_management. Refer to the tool's page for the correct syntax: JoinField_management (in_data, in_field, join_table, join_field, {fields}) If you work with shapefiles and dbf tables, you should add the .shp or .dbf extension to your inputs. For example your ...


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


1

In order to carry out binary shapefile operations such as the one you intend to use on more than two files you can do the process in a step wise fashion using temporary files. import tempfile temp_path=tempfile.gettempdir() temp_basename="temp_shape" temp_file=str(os.path.join(temp_path,temp_basename+".shp")) It is important that you write and close any ...


1

The (optional) is added to the interface automatically when you specify that the parameter is optional so it really can't be avoided. You can set all fields as required but default the values to something: Then in the tool if the value is default or nonsensical (not found in file system for example): import arcpy, os, sys Oparam = sys.argv[1] if ...


1

Short answer - No, ArcGIS will always pass parameters as as positional arguments. Longer answer - Sort of, if you use a slightly hacky technique of accepting both positional arguments or options in your script, using the parse_known_args method. Something like: import argparse def main(arg1,arg2,arg3): print arg1,arg2,arg3 parser = ...



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