Hot answers tagged

5

As mentioned in the documentation, you can refer to other 'types' by using the appropriate ID. This is what you set in the wizard when creating the combo-box, button, etc. and you can change it by editing the config.xml file in the root directory of your addin source. A really simple example that clears a combo-box list when the user presses a button: ...


4

You're tripping over your own feet here.. All cursors need to be removed or they will lock the data; until you free the cursor you could still go back to it at any stage. In your code you're using a mixture of old and new style cursors, I wouldn't, try to stick to one or the other. They both work but I would use arcpy.da cursors exclusively. Older style ...


3

You are 99% there. The issue you are having is that the arcpy.getParameterAsText is returning a tuple.(e.g. "FCpath1,FCpath2" ) This is not a list (e.g. ['FCpath1','FCpath2'] ) like you had before. Your script is now iterating over the tuple, passing the first letter instead of the whole path. Based on the error we can see that your first input is from the ...


3

You've got a little tied up constructing your string def label(wah, field): for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == wah: if lyr.supports("LABELCLASSES"): for lblClass in lyr.labelClasses: lblClass.expression = "<FNT size='8'>[{}]</FNT>".format(field) ...


3

If I am understanding you right you started out with an NLCD raster and a polygon feature class of your grids. You then converted the raster to polygon within each of your grids cells to yield polygons with the corresponding NLCD land cover class. Spatial Analyst Approach: I would redesign your workflow as follows: Before converting to polygons I recommend ...


2

Assuming that you are using the "CURRENT" map I think what you may be missing is: arcpy.RefreshActiveView() at the end of each iteration.


2

Is using direct connect an option? This is preferred as SDE services (Three Tier connections) are depreciated. If must use a three tier connection your SDE administrator will be able to tell you the service name, 5150 and 5151 are the most common ones I have come across (they correspond to the port number).


2

Since your working in arcpy and doing a simple data transfer, use a search cursor to load your Spatial Join count results as the value in a dictionary associated with the FID key and then use and update cursor to read the FID from the current feature being updated and lookup the count from the dictionary to post it. It takes a few more lines of code to set ...


2

If it's simply a matter of whether or not your license server is running, you could ping it, parse the response, and then act accordingly. Something like: import subprocess p = subprocess.Popen(["ping", "<lic server>"], stdout=subprocess.PIPE) print p.communicate() ('\r\nPinging <lic server> [184.154.235.5] with 32 bytes of data:\r\nRepl y from ...


2

I'm not sure where your single quotes came from in the expression. They aren't there in the hard-coded version, and they aren't needed. Change: lblClass.expression = "'["+field+"]'" to: lblClass.expression = "["+field+"]" Or, better yet: lblClass.expression = '[{0}]'.format(field) The string formatting is prettier (especially with longer string ...


2

By using os.path.basename(shpLst[0]), you are specifying the first list item in the shpLst list. This will be the same every time. Instead, you need to perform string manipulation with the fc variable. Slicing a basename can be problematic if the number of characters is different for any of the basenames. The os module's split method is what is needed in ...


2

Point Distance - arcpy.PointDistance_analysis (in_features, near_features, out_table, {search_radius})


1

You can use Exists (arcpy) to check for duplicates in your geodatabase. For example: import arcpy, os, fnmatch from arcpy import env env.overwriteOutput=True rootDir = "whatever directory" search = "whatever criteria" outGDB = "whatever GDB" shpLst = [] for root, dirs., files in os.walk(rootDir, topdown=True): for filename in fnmatch.filter(files, ...


1

Remove the line that converts defq to unicode. I do not think it is needed. Also you are changing the definition query on a layer that at the same time is using a cursor based on a different definition query. That will screw up the cursor. Embedded loops almost always cause problems when the same layer is being changed in both loops. Load the ...


1

Looks like you are not referencing the full path to your newly created SDE connection. Try this: edit = arcpy.da.Editor(os.path.join(outFolderPath, outName))


1

The row object can't be used in the manner that you're attempting: arcpy.FeatureClassToFeatureClass_conversion(row1[1],outSup... Because it's a row and not a feature class, to split your feature class to a single feature per output: desc = arcpy.Describe(catch10) OID_Field = desc.OIDFieldName # the name of the OID field, could be OID, OBJECTID, FID or ...


1

Yes you can. You should be able to do this with an update cursor. Something like this would work: # make sure you're in an edit session fields = [blob_field, file_name] #blob field is your blob field and file_name is the file name field with arcpy.da.UpdateCursor(attachments, fields) as rows: for r in rows: # save to jpg on disk for temp ...


1

The tile layers are image tiles (unless you are pulling from the new Vector Tiles services), so all the data in them is flattened into an image. There would be no way to 'vectorize' them. I think ESRI vector tiles are still in Beta development, and I have no idea whether they are planning to allow you to export them as a map other vector formats (eps or ...


1

Fonts are part of the Windows OS, not specifically ArcMap. In order to add a font to your system, typically you would have a .ttf (TrueType Font, seems to be the most common) or.otf file. To install it, you simply double-click the file and follow the prompts. I think Myriad Pro is bundled with Adobe Reader and the files are located in the Reader install ...


1

Refer to this help page. You are going to need the true type font file for Myriad Pro, a .ttf file. Following those steps will add the font to ArcMap and allow you to use it in your .mxd


1

I am not sure if you set the arcpy paths correctly, but this is how I did to import arcpy into Spyder. To set the path of arcpy, go to Tools -> PYTHONPATH Manager and add the following paths: C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolbox\Scripts C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy C:\Program Files (x86)\ArcGIS\Desktop10.3\bin It ...


1

I found that using "isMultipart" returned any features that had more than 1 feature part AND any features that had donut holes. I created this script that will instead loop over the features, check the the number of actual objects, then select all features that have 2 or more geometry objects via SelectLayerByAttribute_management. import arcview, arcpy ...



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