Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

7

All geoprocessing tools produce a Results object. You want the first output of your GetCount results object. The output will be a string, so you also must convert the string to an integer. if int (arcpy.GetCount_management(PolygonNeighbor_TableSelect) [0]) > 0:


5

If you want to stick to python you can use a dictionary mydict= { 'Oshawa': '70', 'Toronto': '71a', 'Mississauga': '85', 'Kitchener': '77', 'Sudbury': '65' } if !CSDNAME! in mydict.keys(): !ZONE! = (mydict[!CSDNAME!]) else: #do something to flag Or you could create a table and districts and names and do a join. A left outer join (...


3

You can use selection and Python. This may be faster. Make sure your edited feature is selected. Then use the below code in the Python window. if arcpy.Describe ("layer").FIDSet: with arcpy.da.UpdateCursor ("layer", "update_field") as curs: for row in curs: row = ("U",) curs.updateRow (row) else: print "no selection" ...


3

There are a few unnecessary steps in your code. MakeXYEventLayer should work from a CSV file, and possibly a .xlsx file*. You can also take advantage of having one single variable storing the path and then build upon that. If you want shapefile output, specify names with .shp. I used the GDB as output because I didn't see any extensions or another use for ...


3

You can iterate twice, first SearchCursor then UpdateCursor. Store values in a Collections.defaultdict(list) then use set to remove duplicates and join to create a string of the list. import arcpy from collections import defaultdict fc = r'C:\data.gdb\featureclass' fields = ['number','category','combined'] d = defaultdict(list) with arcpy.da.SearchCursor(...


2

You can create a new feature class and use a data access insert cursor, projecting each Geometry with projectAs. Sample code; update with correct values for spatial reference, geometry type, etc.: mergeFcs = ["fc1", "fc2"] #merge feature classes outFc = "out_feature_class" #--- import arcpy outPath, outName = os.path.split (outFc) arcpy....


2

Use IN in your SQL query, and don't include single quotes for numeric field values. CODE in (5020, 5601, 8002)


1

16 bit signed integers can only store whole numbers between -32767 to 32768. Either keep in 32 bit floating point (and compress) or multiply by 10 to the power of the number of decimal places you want to retain before saving to 26 bit int, ie to keep 3 decimal places, multiply by 1000 so 483.415 becomes 483415.


1

I like using Python dictionaries. You can house your key and their respective XYs and use the dictionary to update your table. #point feature class pointFc = r"point\feature\class" #update table tab = r"update\table" import arcpy #create dictionary di = {} #iterate point feature class and store values with arcpy.da.SearchCursor (pointFc, ["No", "x", "x"]...


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