Tag Info

New answers tagged

0

Looks like you're running out of memory on with the size of your dataset. In that case, it looks like you'll need to reduce your data somehow. Resample raster? or divide your feature classes up somehow. or find a bigger machine to run these processes on. Are there 10 million polygons? That's a lot of vertices to deal with then. goodluck.


1

Instead of: for fields in arcpy.Listfields(Feature): print fields try: for field in arcpy.Listfields(Feature): print field.name My changing of fields to field is not important but I think it makes the code read better. However, what is important is that ListFields returns a list of field objects and so you need to examine the name property of each ...


0

The double quotes indicate your field name and should not be escaped with a backslash. Try this instead: where_clause = '"AreaSqKm" > {0}'.format(subsize) To test that works I created the test code and tool dialog below, and it worked. I reported a couple of variable values using arcpy.AddMessage() to ensure that they were actually set to what I ...


0

You do not need the escaping backslash ('\"') since you are using single quotes to enclose the whole string. This should work. where_clause = '"AreaSqKm" > {0}'.format(subsize)


0

In order to use the _arc tools, I had to get at the toolbox and alter the alias: import arcinfo, arcpy, os, sys from arcpy import env arcpy.SetProduct("ArcInfo") tbx = arcpy.ImportToolbox(r"C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Coverage Tools.tbx", "newalias") print arcpy.Usage("union_newalias") if tbx is None: print "Toolbox ...


0

After much fanfare, I found this to work. Seems really strange to have to re-name an alias, but it worked. import arcinfo, arcpy, os, sys from arcpy import env arcpy.SetProduct("ArcInfo") tbx = arcpy.ImportToolbox(r"C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Coverage Tools.tbx", "newalias") print arcpy.Usage("union_newalias") ...


1

The Try/except does work - the problem here is GP Services have defined inputs and outputs. When you publish it and go look at the REST end point of the service, you'll see how these items are defined. Your service expects an output of a certain type. When your service "fails", it doesn't return whats expected of it and you get that error. If you don't want ...


2

Original set: Create pseudo-copy (CNTRL-drag in TOC) of it and make spatial join one to many with clone. In this case I used distance 500m. Output table: Remove records from this table where PAR_ID = PAR_ID_1 - easy. Iterate through table and remove records where (PAR_ID,PAR_ID_1 )=(PAR_ID_1, PAR_ID) of any record above it. Not so easy, use acrpy. ...


1

My favorite shortcut for this is to run the Append tool once using the standard toolbox tool and set up my field mappings using the graphic interface. Then when the tool is done running, open the results window, right click on the information about the operation you just ran and click "Copy as Python Snippet". Then you can paste the code into your ...


1

Below code works for me. I do two types of filtering (firstly select all features name start with "One" and then those features from these selected features which have word "domain" in the name) to select features and run merge operation on that features. import arcpy arcpy.env.overwriteOutput = True arcpy.env.workspace = ...


3

The problem is that you don't close the stream and flush the buffer to disk. No problem with Arcpy part. Just change you code like this: #open it up, the w means we will write to it f = open(outfile_path, 'wb') writer = csv.writer(f) ... f.close() import arcpy arcpy.TableToTable_conversion(outfile_path, "C:\dev_folder\orginalDev.gdb", "jsoncsv2")


1

Hi there i had a similar issue as this before , so i had given it some though , never got another started with , it but just on the thoery side i was thinking INPUT SHAPE i was thinking you could create a fishnet on the input shape fishnet with an intersect of you input shape would then You can then calculate the area of these parcels inside the ...


3

In the requester's mxd, if you go to the Customize drop-down and then select Customize Mode (This is in 10.1. I can't remember if 9.3 was exactly the same, but either way look for Customize Mode somewhere), and then right-click on the button in the toolbar do you get the option to View Source? At 9.3 you could make buttons that fired VBA which in turn fired ...


2

Python add-ins are new to 10.1. So your 9.3 user won't be able to use one. If he decides to migrate to 10.1 or higher (wouldn't be a bad thing after all, 9.3 is not supported for a while): Add-ins are stored in your user's profile (...\My Documents\ArcGIS\AddIns). I don't think you can use/find the add-in if you didn't install it on your machine. But if ...


2

I think your code doesn't work because MakeFeatureLayer_management() creates a layer (in memory) , not a layer file (.lyr). Just replace your TablesView variable, e.g. TablesView = "TablesView" and you shouldn't get that error anymore.


1

basically you want an equal size clustering method, so you could search with this key words on the web. For me, there is a good answer on stats.SE with a Python implementation in one of the answers. If you are familiar with arcpy you should be able to use it with your data. You first need to compute the X and Y of your polygons' centroids, then you can ...


2

You should use the "Group Analysis" tool to achieve your goal. This tools is a great tool from "spatial statistics" toolbox as @phloem pointed to. However you should fine tune the tool to adapt to your data and problem. I created a similar scenario like the one you posted and got the response close to your goal. Hint: Using ArcGIS 10.2, when I ran the tool, ...


5

I can crush this down to 3 lines of code, no cursors required! import arcpy arcpy.SpatialJoin_analysis("Site", "points","in_memory/points_SpatialJoin", "JOIN_ONE_TO_MANY", "KEEP_ALL", "", "INTERSECT") arcpy.Statistics_analysis("points_SpatialJoin", "in_memory/stats", "Join_Count SUM","Id") Then simply sort the table to find the polygon with most points.


5

The following approach uses a Search Cursor and Python dictionary to perform the following workflow: Select points within each polygon feature Update dictionary with key (OID) and value (point count) for each iteration Find max point value and corresponding OID and write to a text file import arcpy, os points = r'C:\temp\mytest\points.shp' polys = ...


2

This is a known issue. The current version of scipy (actually numpy) is not compatible with python distribution that comes with ArcGIS, although theoretically they should. The core reason is that scipy is not pure Python (for speed) and hence it matters which API against which things have been compiled. I had that issue and I never found a compatible ...


3

You have to get the mxd parameter in the Python code as a string first and then create an ArcMap document object. In the script tool properties, you can still use the parameters data type you've specified, but you cannot pass directly this object to the arcpy code. mxd = arcpy.GetParameterAsText(0) mxd_doc = arcpy.mapping.MapDocument(mxd) #create an ...


0

I was trying to do the same thing and found that you can accomplish this indirectly by setting the following error message in the updateMessages(self) function of the ToolValidator class. It's not ideal, since "optional" will still appear next to the parameter label in the toolbox, but instead of putting the usual error icon of a red hexagon with a big X in ...


1

As per this question I think you (or your IT staff) need to run the autorun.exe application, it will launch the startup window (otherwise known as the Quick Start Guide) of the 10.2 installation for Desktop. From here you can install the 64-bit BGP. I realize that this refers to 10.2 not 10.2.2 but I think it is the same process. Just a side ...


0

I know this post is a little old but I though I would share my answer since I was faced with the same issue. The following script SHOULD copy all tables, feature classes and relationships not in a dataset and also will copy over all datasets including the feature classes, topology, etc withing the dataset. import arcpy, os def ...


2

Here's how to find all the mxds in a directory tree using the os module: import os for root, dirs, files in os.walk('C:/junk'): for file in files: if os.path.splitext(file)[1] == '.mxd': print 'It is an MXD!'


3

Not very elegant but this should work: output = Dir + "\\" + (fc[:2]+"_"+fc.split("_")[1][:-4])[:13] By the way, not sure if there was an indentation issue when you pasted the code in GIS.SE, but the for loop should be something like: # Loop for fc in fcList: output = Dir + "\\" + (fc[:2]+"_"+fc.split("_")[1][:-4])[:13] # Process: Polygon to ...


1

After doing a bit of forum research, it appears you might be bumping into a few things. Restart the machine (worth a shot) Turn off background geoprocessing (You've done this) Check the name of any output/input files for any tools I would maybe put a print statement after the assignment of the "outfile" variable print outfile Take a look at the ...


4

You are trying to put a string into the insertRow method, but that method expects a list or tuple. The insertrow method first counts the items in the list or tuple to see if the item count matches the row field count, but since a string item count is most likely 0 it always fails to match up with the field count of the row (i.e., 1). So instead try ...


5

You have to insert a list, you're inserting a single value. for uv in uniqueList: cursor.insertRow(uv) should be for uv in uniqueList: cursor.insertRow([uv])


1

Instead of using: where_clause = '"COMPANY" = \'company_query\'' I think the simplest (of many) ways is to use: where_clause = '"COMPANY" = ' + "'" + company_query + "'" Around company_query I have double-single-double quotes and before COMPANY there is a single-double quote.


0

It would be interesting to see which words are appearing in your layout. Are they all related somehow? Are they all lines in your script that are commented out? Do these lines of text appear in data view also? Or just the layout view? I would check these things out and see if there was a specific pattern of which are appearing. Then you could maybe try ...


1

Presumably these are text elements so you should be able to go into Layout or Data View of ArcMap and use the Select tool from the Draw toolbar to click on them, and then hit the Delete key to remove them. If this works, but next time you run your ArcPy script they come back, then you will need to try and debug your script.


2

The trick to doing this is to first create a legend style item either in your user style file or in a custom style file. For the sake of simplicity, I'll show you how to do it using your user style. In ArcMap, go to Customize > Style Manager You should see a folder in the Style Manager which references the user style file ArcGIS auto-creates to store all ...


0

Figured this out. import xml.etree.ElementTree as ET import urllib u = urllib.urlopen('https://api.octranspo1.com/v1.1/GetNextTripsForStop', 'appID=7a51d100&apiKey=5c5a8438efc643286006d82071852789&routeNo=95&stopNo=3008') data = u.read() f = open('route3008.xml', 'wb') f.write(data) f.close() doc = ET.parse('route3008.xml') for bus in ...


2

As of 10.3, there are new attributes on the Extension object that may be of use to you: the Extension.currentLayer and Extension.editSelection properties.


2

I would use below code-- If you have access to "Data Access Module" import arcpy,os,sys pattern = 'fish_46.shp' folder = 'C:\Users\USER_NAME\Desktop\delete'## root folder field = 'Id' ## your field where calculation to be applied files_process = [] for root,dirs,files in os.walk('C:\Users\USER_NAME\Desktop\delete'): for filenames in files: if ...


1

You are receiving that error because you are not providing one of the supported data types to Merge_management: Input datasets can be point, line, or polygon feature classes or tables. You can create a Layer object from a shapefile and save the Layer as a Layer file. However, you need to be aware that the spatial data is not saved as part of the ...


0

# save mxd and export to pdf for df in arcpy.mapping.ListDataFrames(mxd): mxd.activeView = df.name mxd.title = df.name mxd.saveACopy("E:\\Python Lab 2\\PythonInArcGIS\\Providence_1.mxd" + df.name + ".mxd") mxd = arcpy.mapping.MapDocument("E:\\Python Lab 2\\PythonInArcGIS\\Providence_1.mxd" + df.name + ".mxd") # I also tried this code mxd = ...


1

Closing ArcMap solved the problem. I thought the problem will be because of the rapid field adding and I found a lot of articles on the web speaking about the problem. Well, it has been solved.


0

I think you're going to need to save edits first When you make edits to a table/feature class in ArcGIS, those edits are held in memory and are not committed to the actual table/feature class until you save edits. This is why you can "undo" edits when you are in an editing session. So, if one tries to execute a cursor against a dataset prior to committing ...


0

Why don't you just use arcpy.SpatialReference(WKID)?


4

The error is due to the fact that you're using a tuple (returned from your cursor) as your input for your MakeFeatureLayer_management. This function requires a feature class or layer as its input. If you're wanting to know where your layers lie in relationship to a polygon, I suggest using a spatial join as opposed to a cursor. It is faster, and a good ...


0

Per my comment. You are looping through and checking the layer.name property against the file paths declared in your #local variables section and added to your names list. The 2 options I can see to fix your code as-is are, Wrap RI_Schools & RI_Sewers in quotes, e.g. names = ["RI_Schools", "RI_Sewers"] or Use the layer.dataSource property (more info) ...


2

So currently you're using the input of your shape file name but not indicating a directory. The full path is needed for the merge to work. Or you can set your environment's workspace each time you find a file. You're also not actually merging anything, since you have only a single input. I'd populate a list of all the matches found, so that you can use it ...


4

Here's what you need to do, with comments: # Reference the MXD containing your layers. # If you're doing this in the Python Window of the MXD, # use the "CURRENT" keyword instead of providing a path # to the MXD you already have open. mxd = arcpy.mapping.MapDocument(r"C:\Users\Daimon Nurse\Desktop\Zonetrial.mxd") # mxd = ...


0

On first glance I would recommend that after toggling the layer visibility to False and refreshing...that you the save the mxd before exporting. Either use the save() method or the saveACopy method on the MapDocument object. Consider also trying the RemoveLayer function as an alternative. You likely need to save after this operation as well before ...


0

The way I came up with has the drawback that it places twice as many parameters on the tool dialog as the answer (which I prefer) by @MrBubbles but I will record it here any way. The pictures below show its tool dialog in operation. The choice of the first parameter (e.g. Category A) triggers every second other parameter to be updated (via tool validation) ...


0

Orion, I just noticed you mentioned in your response to msi_g that even after installing 64-bit Background Geoprocessing that your tool is still running in the foreground. By default, all models and script tools run in the foreground, which means by default they all run in a 32-bit environment. Have you unchecked the "Always run in foreground" checkbox on ...


0

Make sure you have the script tool set to run in-process. http://resources.arcgis.com/en/help/main/10.2/index.html#//00150000000r000000


0

Okay so I finally figured this out. It was a stupid mistake on my part. The files I had in the specified folders were actually feature classes and not datasets. Anyway it is not possible to create a dataset inside a folder. It can only be done inside a geodatabase. So for someone who knows their way around with ArcGIS, they could have noticed that I had just ...



Top 50 recent answers are included