0

Using ArcMap 10.5

I want to find a way to do a bulk attribute update across multiple layers.

Example:

I have 10 layers in a Storm Network and each layer has 5 identical fields (project related information) that I would like to edit all at once. Meaning I enter the data for each field once, and a tool or simple script applies the data to every selected asset across all layers.

My hope was that there already was an add-in somewhere out there or a script that could be downloaded and configured. But I haven't been able to find anything like this which I find surprising.

Anyone willing to share their process for achieving bulk updating of attributes?

  • Welcome to GIS SE! As a new user be sure to take the Tour to learn about our focussed Q&A format. A broad question seeking ideas for solutions is fine to ask in the GIS Chat Room but to ask there you need to gain 20 reputation points first. – PolyGeo Jul 25 '18 at 22:37
  • Re-run tool on another layer from results window? – FelixIP Jul 26 '18 at 0:28
1

Using the built-in batch functionality probably has the lowest barrier to entry here: ArcToolbox > Data Management Tools > Fields > Calculate Field > (right-click) > Batch. This will let you edit a single field on all of the layers you input, and you could repeat that until you're done.

Other options include creating a Model Builder model or a Python snippet. You could do something like this from the Python console:

mxd = arcpy.mapping.MapDocument('CURRENT')
for lyr in arcpy.mapping.ListLayers(mxd):
    print lyr.name
    arcpy.CalculateField_management(lyr, 'SomeField', 100)
    arcpy.CalculateField_management(lyr, 'SomeOtherField', 'twohundred')

Note that using the above directly will run on every loaded layer in the doc.

-1

You can simply use GDAL's OGRINFO to update your data wrap it in a batch script with a for /f or for /r and it will update each file in a directory or recursive folders. You run SQL Queries so you can perform full CRUD operations (Create, Read, Update and Delete). For example for every GeoJSON file (Could be every FileGDB or Shapefile) I want to add the file name as a column.

set /p geojsonfolder=folder path to geojson: cd /d %geojsonfolder% for /r "%geojsonfolder%" %%G in (*.geojson) do ( ogrinfo "%%G" -sql "ALTER TABLE OGRGeoJSON ADD COLUMN fname character(150)" ogrinfo "%%G" -dialect SQLite -sql "UPDATE OGRGeoJSON SET fname = '%%~snxG'" )

  • Here is another one where I am creating a TXT file for every shapefile to look at the fields and metadata. set /p shapefiledir=folder path to shapefiles: cd /d %shapefiledir% for /r "%shapefiledir%" %%G in (.shp) do Echo iterating through shapefiles: %%G echo. echo outputting shapefile metadata - writing txt files for /r "%shapefiledir%" %%G in (.shp) do ogrinfo -ro -so -al %%G>%%G_metadata-fields.txt – Jordan Bess Jul 25 '18 at 22:19
  • Update all records inside a GeoPackage (yes you could do this with field calculator but I find this easier and easy to repeat) ogrinfo SUA.gpkg -dialect SQLite -sql "UPDATE sua SET type = 'MOA' WHERE type = 'M';" – Jordan Bess Jul 25 '18 at 22:21
  • ogrinfo vectortiles.mbtiles -dialect SQLite -sql "INSERT INTO metadata (rowid,name,value) VALUES ('12','cycle','%cycle%');" – Jordan Bess Jul 25 '18 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.