Skip navigation
All Places >

python snippets

Log in to follow, share, and participate in this socialgroup.

Recent Activity

Can someone please assist me with the following task at hand:   I need to export the coordinates of polygon vertices in the following format: Polygon_1, y,x ; y,x ; y,x ; y,x ; y,x   I have 120 000 vertices that needs to be exported in this format (either txt or xls). I have used export feature attribute to ASCII and export as table, but it… (Show more)
Hello guys, is there someone who were annoyed by this kind of problem? So, first of all I want you to notice that the feature class Roads has a POLYLINE geometry type, and there are no multipart features in it. import arcpy for i in arcpy.da.SearchCursor(r'C:\Users\...\Administrative_area.gdb\Roads', ["SHAPE@"]):     print(i[0]) Normally, the… (Show more)
I run a Python script to delete and recreate a set of map services.  To do this, I place a folder with all the mxds and data in the same directory as the existing folder, with a different name. The script then renames the folder using os.rename, and then uses that data for the new map services.   The problem is, I get an 'Access Denied' error… (Show more)
in python snippets
ArcGIS custom toolbox which uses a python script, for updating a mass amount of field aliases at once, using a list of field names and corresponding aliases input by user. Let’s say you have an ArcGIS feature class or table with a bunch of cryptic, abbreviated field names, and you want to add aliases to make them easier to understand. Let’s say…
in python snippets
PROBLEM: I have a python script that replaces an existing feature class within a GDB with new data using the line below (part of a longer script): arcpy.FeatureClassToFeatureClass_conversion(URD, tempGDB, "URD", urd_selection_expression)URD is a sql query layer, tempGDB is an established geodatabase, "URD" is a feature class that is deleted in an… (Show more)
in python snippets
Through a plethora of trials and research, I finally was able to get a script to work. My original question encompassed me needing to take an .mxd and create a PDF mapbook document that will contain a map for each county in the counties FC. Then, I needed to change the title of each map to the name of the county being shown. Lastly, I need to… (Show more)
Hi All,   I am trying to use arcpy on ArcCatalog 10.2.1 to delete some version on our sql database. when I use the function arcpy.DeleteVersion_management(connection,, i get an error "ERROR 000301: The workspace is of the wrong type". The connection is to a .sde file and the user has permission to delete all versions.   Thank you… (Show more)
in python snippets
Hi All,   I am new to python, and was wondering if there is a way to incorporate folder creation as part of my data driven page script, see below:   mxd = arcpy.mapping.MapDocument("CURRENT") ... df = arcpy.mapping.ListDataFrames(mxd)[0] ... ... in_folder = arcpy.GetParameterAsText(0) ... file_name = arcpy.GetParameterAsText(1) ... ... for… (Show more)
I am adding a layer to map docyment through and stand alone ArcPy snippet like this MXD = arcpy.mapping.MapDocument(r"C:\\arcgis\\ArcTutor\\AAA\\MXDs\\map.mxd") df = arcpy.mapping.ListDataFrames(MXD)[0] print('Step 3') layer = arcpy.mapping.Layer("Primary") layer.minScale = 10000 layer.showLabels = True arcpy.mapping.AddLayer(df, layer,… (Show more)
in python snippets
Load more items