Tag Info

Hot answers tagged

6

You should be able to use either the Copy Rows tool or the Table to Table tool to get the job done. Just make sure to give your out_table/out_name parameter ends with '.csv' and you should have no trouble.


4

Yes you can, you could do it by adding a global variable that keeps track of your clicks. For example: class ToolClass2(object): """Implementation for Test_addin.tool (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" global clickCount clickCount = 0 def onMouseDownMap(self, x, y, button, shift): global clickCount ...


4

For a full geodatabase, a quick solution is to create a bounding polygon based on the extents of each feature class. Of course, I assume that all your feature classes are in the same coordinate system. you can loop on the feature classes of the geodatabase, request the extent and store the min, max values in X and Y. something like below (same for Y) minX ...


3

use the equivelant cursor without .da. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000039000000 ex: shapefieldname = arcpy.Describe(featureclass).ShapeFieldName sCur = arcpy.SearchCursor(featureclass, {where_clause}, {spatial_reference}, {fields}, {sort_fields}) for row in sCur: feature = row.getValue(shapefieldname) ...


3

You can try this, it requires saving your layers out to a lyr file on disk before adding it to the second map. In map one, run this code: arcpy.SaveToLayerFile_management("yourlayerinmap", r'youroutputlocation') In map two, run this code: mxd = arcpy.mapping.MapDocument('CURRENT') df = arcpy.mapping.ListDataFrames(mxd)[0] layer = ...


2

Consider using Dissolve. This will write the output to a new feature class but it may be more efficient. In my experience dissolve operations have taken less time than merge. Run a benchmark to determine which is faster. There may be some issue with merge/dissolve wrt to performance and dissolving circular arcs (such as results of buffering points, ...


2

This is pieced together from the link @PolyGeo commented. Copy/paste this into the Python window: sr = arcpy.SpatialReference() sr.loadFromString('{B286C06B-0879-11D2-AACA-00C04FA33C20}') mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] df.spatialReference = sr arcpy.RefreshActiveView() I tested it in ArcMap and it ...


2

You could loop through all the feature classes in the gdb and use the minimum bounding geometry gp tool to create convex hull polys in memory and then run a final minimum bounding geometry process on all these polys. This is untested, but something like this may work: import os, arcpy def iter_ws(workspace, dataType='Any', ftype='ANY', wildcard='*'): ...


2

Here's a different way to do this by setting the dataframe equal to the current layer's extent. It a lot more simple. Also, you'd better check your path because it shows the MXD being inside the geodatabase. import arcpy import os path = "C:\\Users\\Et\\Documents\\ArcGIS" #need to use two backslashes mxd = arcpy.mapping.MapDocument(os.path.join(path, ...


2

The Point (geometry) object won't carry forward values for other columns. It'll let you set it but it gets ignored. It seems you're expecting the geometry object to act like the Row object from the old cursor objects. Why don't you skip the geometry list step and just use arcpy.NumPyArrayToFeatureClass to go straight from array to feature class?


2

You may use Iterate Feature Selection Iterates over features in a feature class.


2

Your cursor is returning a row object. If you look at the syntax section of the help file for the Polygon to Raster tool what do you see as the input data type? You need to supply the actual geometry (the polygon). You are using the older SLOWER cursor. Consider editing your code to use the cursor from the da module. There are plenty examples in the help and ...


2

SearchCursor is a class in the arcpy.da module and not a module itself, so if you wanted to import just that class you could use: from arcpy.da import SearchCursor You could then reference it as just SearchCursor. You can also import the entire module and reference the class within, and it's also worth noting that import arcpy automatically imports ...


1

I think your syntax is astray. From the documentation for arcpy.da.SearchCursor the syntax I would expect to see is more like some example code from there which I have included here: import arcpy fc = "c:/data/base.gdb/well" fields = ["WELL_ID", "WELL_TYPE", "SHAPE@XY"] # For each row print the WELL_ID and WELL_TYPE fields, and the # the feature's x,y ...


1

Give this a shot: import arcpy, os import arcpy.mapping from arcpy import env env.workspace = "C:\\Project" for mxd in arcpy.ListFiles("*.mxd"): mapdoc = arcpy.mapping.MapDocument(os.path.join("C:\\Project", str(mxd))) mapdoc_name = str(os.path.splitext(mxd)[0]) width, height = str(round(mapdoc.pageSize.width, 2)), ...


1

This is because you are giving the layer the full path name when you create the Raster Layer. This is what you are doing: arcpy.MakeRasterLayer_management(Raster(layerName),layer) The output argument "layer" is a full file path. What you should change it to is this: arcpy.MakeRasterLayer_management(Raster(layerName),layerName) This will give you ...


1

I have not tested this but the Field (arcpy) documentation says that the required property is Read and Write so I think that will be the place to start experimenting. There is a code sample there that could be used as a starting point. I would try using: field.required = False and see if it sticks. This sentence: Updating a field property only ...


1

# PubishMapBook.py # Purpose: Create map book pdf, output Data driven pages series from .mxd, # assemble map book and save # Import modules import arcpy import os # set the current workspace to your folder arcpy.env.workspace = r"C:\your_data" # set up variables for output path and PDF file name outDir = r"C:\your_data" finalpdf_filename = outDir + ...


1

To determine where in your long script your performance bottlenecks are located, I recommend that you use Python's time module, in a way similar to how I did in this answer to another question. Once you know where any bottlenecks are you should be able to isolate them into test code snippets that can be used to try and develop alternative (faster) coding ...


1

Here's the update: I used tkFileDialog.askdirectory() to get the gdb name to set the workspace. Then I used arcpy.da.Walk() from the data access module to load the feature classes into an array. My next step would be, put a ttk combobox on the GUI and load feature classes into the drop-down of the combobox so users get to specify the feature class to do ...


1

as @FelixIP mentioned - you'll want to move the name of the output raster inside the loop (you could specify the directory outside the loop if you like, then append the output raster name) - you'll also need to change the name of the output variable to match that of the variable created with the Con statement and save it within the loop as well to save each ...


1

You should just install the 32 bit version of Anaconda.


1

You're using a 64 bit version of Python in your Anaconda installation and ArcMap's Python is 32 bit. You'll need to install some 64 bit ArcGIS build (either 64 bit Background Geoprocessing or ArcGIS for Server) and point to that instead, or install a 32 bit Anaconda instance instead and try again. See the downloads page and get the 32 bit installer.


1

The answer which I found yesterday, and PolyGeo referenced in his comment above, was to use the full path to the sde instead of the relative path. I still don't understand why the IDLE GUI/shell can't use the relative path when the ArcMap python window can.


1

Thanks for all the great ideas. Unfortunately I was stuck using arcGIS as getting admin privileges at my workplace is near impossible. Basically what I ended up doing was appending 100 files at a time rather than 1 at a time. This reduced the runtime to just over 24 hours.


1

ArcGIS 10.1 has a few bugs when it comes to working with buffers. Especially with Geodesic buffers and the dissolve type "all" method. (NIM083208, NIM082599, NIM086086,NIM087868,NIM087913). I swapped to a projected system, then separated the buffer component into it's own module and the random errors stopped.



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