New answers tagged

1

I think you need to change: row[1] = scvDict(mxLoc) to row[1] = scvDict[mxLoc] Also, oldAddr is currently unused, which is fine, but you could change this line to use it. print("Looking at row {0} with an address of {1}.".format(mxLoc, oldAddr))


1

These are great resources for your issue. https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-classes/geometry.htm https://pro.arcgis.com/en/pro-app/arcpy/data-access/updatecursor-class.htm import arcpy # Location of point and polygon shapefiles arcpy.env.workspace = r'C:\gispy\stackexchange' Point = 'Point.shp' Polygon = 'Polygon.shp' polyGeom = ...


1

This should do the trick. It uses a pandas dataframe with the newer da.SearchCursor. import arcpy import pandas as pd df = pd.read_csv(r"path", usecols = ["GISID"]) fc = r".shp" fields = ['GISID'] gis_poles_assets =[] with arcpy.da.SearchCursor(fc, fields) as cursor: for row in cursor: gis_poles_assets.append(row[0]) for index, row in df....


1

You are using the old cursor which is much slower than the data access cursor. Create a view of the csv and use cursors on both shape and view to list all values then compare using sets: import arcpy fc = r'C:\GIS\ArcMap_default_folder\Default.gdb\ak_riks' fcfield = 'polenr' poles_in_fc = [f[0] for f in arcpy.da.SearchCursor(fc, fcfield)] csv = r'C:\GIS\...


0

I think the MapSeries class, and creating MapSeries objects using the Layout class, are useful for map series requirements that are relatively straightforward. Whenever, I have more complex requirements, I instead use a SearchCursor to iterate the index layer, and zoom to the extent of each feature in it, before exporting a PDF file for each of those ...


1

I'd find your first geometry with a search cursor. Then iterate how many times desired, create new geometries based on the last iteration, and store those geometries in a list. Finally, use an insertcursor to insert your geometry. #number of iterations iterations = 50 #get first geom with arcpy.da.SearchCursor (infc, "SHAPE@") as curs: lastGeom = curs....


0

import arcpy, itertools fc_to_update = r'C:\data.gdb\features' field_to_update = 'somefieldname' alist = [1,2,3,4,5,6] repeatingGenerator = itertools.cycle(alist) #https://stackoverflow.com/a/45037522/6936582 with arcpy.da.UpdateCursor(fc_to_update, field_to_update) as cursor: for row in cursor: row[0] = next(repeatingGenerator) cursor....


0

The first thing to do to run faster is to use arcpy.da.SearchCursor instead of arcpy.SearchCursor Also it seems to me that there are too many commands in your loop. For example, "Add field" would be more efficient if you run it once before you split. And it seems to me that you could avoid writing new datasets if you work with selected features.


Top 50 recent answers are included