Skip navigation
All Places >

python snippets

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

Recent Activity

BEHSEINI
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
BEHSEINI
I am trying to add a Feature Class from a Geodatabase Dataset to an MXD and save a copy like this but I am getting following errors on each methos import arcpy import os arcpy.env.workspace = r"C:\arcgis\ArcTutor\AAA\MXDs" MXD = arcpy.mapping.MapDocument(r"C:\arcgis\ArcTutor\AAA\MXDs\map.mxd") DF = arcpy.mapping.ListDataFrames(MXD)[0] lyr =… (Show more)
in python snippets
dmajumder23
I am having some issues with creating a  script to count stairwells from a stair shapefile. I have two shapefiles one being stairs and another one being  stairwell.   I  was instructed to use this  code  and  make  a simple  script. i am not used to working with python so if you can help that would be much appreciated. code is pasted below.   def… (Show more)
in python snippets
Entsika_Liesl
Hi All,    I am new to python, and have been using data driven pages to export multiple maps. However, I would like to change the way I'm naming my maps. Currently it is the custom name + the page name that is linked to the data driven pages.See script below:   mxd = arcpy.mapping.MapDocument("CURRENT") ... df =… (Show more)
behClevest
I am trying to create a Python Toolbox and I need to load some chekboxes to a parameter (param2) after selecting a value in previous parameter (param1). As you can see I have name of states in param1 and need to load a code like this after changing on param1 inFeature = parameters[0].valueAsText slectedCounty = parameters[1].valueAsText counties =… (Show more)
in python snippets
NHVRGIS
Hi All,   I am trying to write unit tests that will ensure all SHAPE related fields within an MXD are hidden. However, even if the SHAPE field visibility is unchecked within the ArcMAP -> Layer Properties -> Fields -> "Choose which fields will be visible" GUI, it seems impossible to read/access this state in ArcPY.   The following will all… (Show more)
in python snippets
behClevest
Can you please take a look at this snippet and let me know why I am not able to properly pass the Where Clause ('"[NAME_1]" = Ohio') in SearchCursor?     import arcpy from arcpy import env def unique_values(table , field): with arcpy.da.SearchCursor(table, [field], '"[NAME_1]" = Ohio') as cursor: return sorted({row[0] for row in cursor}) uniques… (Show more)
in python snippets
behClevest
I am using following to copy selected feature from a Shapefile to a Dataset in a File Geodatabase   As you can see I tried to create layer from shapefile by doing arcpy.MakeFeatureLayer_management(inFeature, 'lyr') and then select the attribute like    arcpy.SelectLayerByAttribute_management('lyr', "NEW_SELECTION", '"NAME_1" =… (Show more)
in python snippets
Archaeojp
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
behClevest
Can you please take a look at this demo and let me know why I am not able to create new feature class from a shapefile  based on selecting by attribute and saving the new future in a Geodatabase?   The file is adding to the GDB but it is empty on attributes and geometry     # Import arcpy module import arcpy # Local variables: Dataset =… (Show more)
in python snippets
Load more items