Hot answers tagged arcpy
One way to handle intermediate data is to use the in_memory workspace. For example: arcpy.Project_management(Footprints, "in_memory", out_coordinate_system) You can specify multiple in_memory objects by adding a name and path separator: "in_memory\temp1" "in_memory\temp2" ... If your datasets are very large and you are worried about cumulative ...
Should be: stringvariable = "banana" arcpy.CalculateField_management("c:\point.shp", "SUBDIRECT", "'" + stringvariable + "'", "PYTHON") If you double quote stringvariable, Python won't interpret it as "banana". Also, You have to quote the string for the field calculator to work.
One possibility might be to create a new file geodatabase, set your current workspace environment to it, do your processing, and at the end delete the file geodatabase.
A SearchCursor is read-only. You want to use an UpdateCursor. Also don't forget to call the cursor's updateRow method after setting a row's values. See Accessing data using cursors in the help for more information.
Your code is not actually selecting anything, you are making a subset view of your data with the MakeFeatureLayer tool. You need to run the selectbyattribute tool on your layer. The desktop help suggests if you want to zoom to selected features in a specific layer you should use this code: df.extent = lyr.getSelectedExtent()
The in_memory workspace is usually the way to go for intermediate data and is faster because it doesn't actually write the output to disk. However, you can also define a scratch workspace (arcpy.env.scratchWorkspace) for those tools that don't respect the in_memory workspace or if your result is too big to fit in memory. Esri defines this as a default output ...
pythonaddins is limited in getting parameters directly from a user that are not associated with the table of contents as pythonaddins is mainly a way to offer python developers a way to interact with user events. That being said the main mechanism for a developer to get parameters from a user in the same way as arcpy.GetParameterAsText is through ...
You can use the following to grab the OID of selected features within a layer. FIDSet = arcpy.Describe(layer).FIDset records = [int(FID) for FID in FIDSet.split(";")] if FIDSet else  This way, you can make a selection, grab the OIDs, and clear selection. arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION") It should occur quickly, so the ...
I am going to suggest that you use a few of the profiling tools in Python to give you some insight as to what is going on with your script. You may have an undetected memory leak or you may be running out of memory as suggested. TL;DR; I would encourage you to seek visibility into how your script's performance and memory management or else you are just ...
Your code looks to do a lot of unnecessary things. For instance, you iterate over filed list, but never use variables fl or fld. So here is code that could do what you need from my understanding. It first gather all the place_name variables and put it in a dictionary and after, iterate thought the second feature class and update the values. import arcpy ...
Thanks, that's what I needed. This now zooms in: mxd = arcpy.mapping.MapDocument('CURRENT') df = arcpy.mapping.ListDataFrames(mxd, "Layers")  lyr = arcpy.mapping.ListLayers(mxd, "Siteslyr", df) arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", ' "gid" = 2739 ') df.zoomToSelectedFeatures()
You can save your mxd as a template. When you create a new document from a template, an untitled map is opened based on the selected template. You must save your mxd in %APPDATA%\ESRI\Desktop10.2\ArcMap\Templates so it's available in the list of templates in ArcMap.
Only top voted, non community-wiki answers of a minimum length are eligible