New answers tagged

2

You are creating the same feature layer for each row, and the layer is the entire shapefile. Then rasterizing the shape. Add a where clause to only make a feature layer of current cursor row and rasterize "Layer" : ... with arcpy.da.SearchCursor(shp, PIDname) as sCur: for row in sCur: out_Raster = "PID{}.tif".format(row[0]) ...


3

There's a number of issues here: Both row[0] and row2[0] are already PointGeometry type objects, for which .firstPoint is the Point accessor property. Use the arcpy.Array object to bundle the Points, as in the documentation. Never, never, never use a Geometry constructor (arcpy.Point, arcpy.Polyline, arcpy.Polygon) without the SpatialReference of the target ...


1

Using BERA's suggestion this is the dictionary that was successful in creating the soil class values. fc= r'D:\GIS\PollinatorProject\Pollinator\Pollinator.gdb\soil_samples' fields = ['L1_SOILTYP', 'ClassofSoil'] type_to_class = { 'CLAY, DUMP': '1', 'DRY CLAY': '1', 'Clay' : '1', 'CLAY' : '1', 'CLAY MOIST' : '1', 'CLAY(WEATHERED ...


2

You can use a dictionary to shorten your code: import arcpy fc = r'D:\GIS\PollinatorProject\Pollinator\Pollinator.gdb\soil_samples' fields = ['L1_SOILTYP', 'SoilClass2'] type_to_class = {'CLAY,DUMP':'1', 'CLAY(WEATHERED SHALE)':'1', 'FILL,CLAY':'1', 'SAND':'2', 'TOO SANDY':'2', 'Sand, coarse':'2', 'COARSE SAND':'2', 'Sandy ...


0

So, apparently insertCursor demands a list object. With the following, the code works. I'll leave it here for posterity; if mods want to remove the question in case they find it too basic, that's fine too. def get_extent_centroid(layer): desc = arcpy.Describe(layer) if desc.dataType in ['FeatureLayer', 'RasterLayer']: extent = desc.extent array = ...


2

As commented by @user2856 using a where_clause on your UpdateCursor is all that is needed. If you have variables fc, fld and val set to a feature class, a field name in that feature class, and a value in a text field respectively then this should work to change the value to a new value of "X": with arcpy.da.UpdateCursor(fc,fld,"{0} = '{1}'&...


3

The documentation for the 'field' class explains that the .aliasName attribute holds the value of the field alias. So change the field_names = line to this: field_names = [field.aliasName for field in fields if field.name in fieldsToKeep] Or if you want to be a bit clearer, change it to this: field_aliases = [field.aliasName for field in ...


Top 50 recent answers are included