Tag Info

Hot answers tagged

5

This is not exactly what you asked for, but a workaround could be to add both IDLE instances to your Send To context menu option. open %APPDATA%\Microsoft\Windows\SendTo choose > New > Shortcut specify the path and command for IDLE, eg C:\Python27\ArcGIS10.2\pythonw.exe "C:\Python27\ArcGIS10.2\Lib\idlelib\idle.pyw" repeat for the other IDLE version Now ...


5

names = ['','_A', '_B', '_C'] mxdPath = wrFolder + "/M_" + WorkrequestRaw +"_01" for name in names: mxdOutput = mxdPath + name + '.mxd' if not arcpy.Exists(mxdOutput): pdfversion = name break


5

Here's the ListLayers documentation ListLayers(map_document_or_layer, {wildcard}, {data_frame}) You can use a wildcard if you know the name of the layer. mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] road_layer = arcpy.mapping.ListLayers(mxd, "Road", df)[0] river_layer = arcpy.mapping.ListLayers(mxd, "River", ...


4

that's nearly it, but the referencing of the field should be done on the field list, not the field name fieldList = arcpy.ListFields(r"C:\your.shp") for field in fieldList[19:]: print field.name


3

I think that you will have to keep the polygons as separate features. Polygon multiparts are an evil construct that has no logical topology for analysis and even display in your case. What is wrong with a separate featureclass? If you want to aggregate the properties, then a Dissolve will do this. You could relate the multiple features to the single ...


3

Based on the comment by @KHibma I put together the code snippet below to demonstrate how to "use arcpy.GetMessageCount and arcpy.GetMessage and get [messages] 1 by 1 by index" import arcpy try: arcpy.CreateFolder_management(r"C:\temp1","test") except: pass for idx in range(0,arcpy.GetMessageCount()): print "Message {}: ...


2

First of all you have some errors in your code: inputlayer = fcs have to be changed inputlayer = fc At my mind the syntax is wrong here: os.path.join(*(fcs) + '.lyr') Here is a working example of your code, it takes mxd file and add every feature class from GDB to mxd file and saves it: import arcpy, os arcpy.env.workspace = r"C:\New File ...


2

Yes, you can run multiprocessing child processes from a toolbox script. Below is some code to demonstrate in a Python Toolbox (*.pyt). There are a number of "gotchas". Some (but not all) will be applicable to Python script tools in a binary toolbox (*.tbx), but I only use Python Toolboxes these days so have not tested. Some "gotchas"/tips: Make sure ...


2

As an alternative to pymssql, you might consider using the arcpy.ArcSDESQLExecute class to execute your SQL statements. Something along the lines of (simplest form and untested): import arcpy sde = r"Database Connections\Connection-to-SDE.sde" sde_conn = arcpy.ArcSDESQLExecute(sde) sql = """CREATE TABLE tempIntersect_withNATA (ZIP varchar(max), ...


2

Using field calculator (or, arcpy.management.CalculateField() if you want): In the code block: def fix_matrix(field_value): if field_value.endswith("A") or field_value.endswith("B"): return field_value[:-1]+"AB" else: return field_value In the expression: fix_matrix(!MATRIX!) + !PLANT! + !PCT! + !SITE!


2

>>> outPoly = "C:\output\newpoly.shp" >>> print "'{0}'".format(outPoly) 'C:\output ewpoly.shp' >>> >>> outPoly = r"C:\output\newpoly.shp" >>> print "'{0}'".format(outPoly) 'C:\output\newpoly.shp' >>> This probably explains it best: https://docs.python.org/2.0/ref/strings.html


2

Never tried multiprocessing, decided to give it a go. This script: import os, sys, arcpy, multiprocessing from arcpy import env env.overwriteoutput=1 scratchGDB=r'd:\rubbish\TEST.gdb' def function(inputs): print ("got arg %s" % inputs) outTblName = inputs[0] city = inputs[1] pop = inputs[2] with ...


2

You need to make sure the pageNum is an integer, and you need to split the input values. For this example, you'll need to enter the pages like 1, 2, 3 with spaces. Give this a try: import arcpy mxd = arcpy.mapping.MapDocument("E:\\User Folders\\Recreation.mxd") ddp = mxd.dataDrivenPages pageNumbers = raw_input("Enter Page/s: ") for pageNum in ...


2

You need to make a list of the jpeg's and the n loop trough them. You can use the glob module for that: import arcpy, os , glob outworkspace = r"C:\Project\out\OtherFormat" listOfJPG = glob.glob( r"C:\Project\out\*.jpg") arcpy.RasterToOtherFormat_conversion(listOfJPG , outworkspace ,"TIFF") print 'converted'


2

Your example code does not do what your post title asks. You are not attempting to update multiple columns (which are called fields) with a cursor. You are attempting to process through the cursor records (which are called features or rows) more than once with a single cursor. That is not allowed and is never really necessary, since there are better ...


2

This question is pretty close to off-topic (pure python). However, here is another method. import os, sys, string import arcpy mxdPath = os.path.join(wrFolder, "M_" + WorkrequestRaw +"_01") for letter in [''] + list(string.ascii_uppercase): mxdOutput = (mxdPath + '_' + letter).strip('_')+ '.mxd' if not arcpy.Exists(mxdOutput): pdfversion = ...


1

As @GeoJohn pointed out, the CopyFeatures operation in the second loop should be added to the first loop. I think the real problem is that you are trying to place feature classes from an SDE environment into a normal directory. Shapefiles are the format you need if you want the final datasets to sit in C:\output. When you passed the feature class name ...


1

Try this to construct name: for i in range(10): fName='%s_%s.mxd'%("BASENAME",chr(65+i)) and break if does not exist. Construct new name using i


1

It is hard to be certain what you are trying to do, and it should be fine to do all of this is a single pass of the update cursor. However, I think you may be wanting to change data on the second pass based on changes made in the first pass so I have structured the code below to do that. Perhaps give it a run and see how it goes. with ...


1

So ESRI has arcpy versions of some common operations from the os module, especially when it comes to listing directories. I have not used arcpy.ListWorkspaces() before, but it seems like it should work for you, and you could add arcpy.ListWorkspaces("*","FileGDB") because you are specifically looking for File Geodatabases. Generally it's good practice to ...


1

The code you posted should not give an indentation error. I recommend that you open a new Python script and copy/paste the code you posted and run that. I will be very surprised if you receive an indentation error by doing that. I suspect that you may have moved the start of the last line left or right in the process of writing your question. W.r.t. ...


1

CopyRows can't output to Excel, it can only output to dBASE, ArcSDE geodatabase, file geodatabase, personal geodatabase or INFO tables. You need to use the TableToExcel_conversion tool. Then you need to use os.path.dirname to get the gdb parent directory. Something like (untested...): import os, arcpy folder = arcpy.GetParameterAsText(0) for dirpath, ...


1

Below your 'CopyRows' command, where you're outputting tables inside the gdb, you need to output essentially to a level 'up', as indicated in your diagram...do this with a simple os.path.dirname(dirpath). (Make sure you've imported the os module.) FYI, to be consistent you should use os.path.join similarly (instead of '+ os.sep +'): os.path.join(dirpath, ...


1

Inside a geodatabase you can only store GeoDatabase types, from Esri Help: A key geodatabase concept is the dataset. It is the primary mechanism used to organize and use geographic information in ArcGIS. The geodatabase contains three primary dataset types: Feature classes Raster datasets Tables So, in a GeoDatabase you can only store Tables, ...


1

Get the list of columns for a table in Oracle using ALL_TAB_COLUMNS from this query using ArcSDESQLExecute... select column_name from all_tab_columns where table_name = 'TABLE_NAME'. The returned list may need to be processed to eliminate unwanted columns.



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