1

I have lots of feature classes that I'm working with, but the attribute tables are really messy because I got the information from different sources. So I decided to clean them up.

I made a table for every criteria one row. I want to use the table with an iterator, so all the features are imported, renamed and sorted out at once. I added ONE column (called "Keep_it") with the name of the column that I want to keep from the old feature - all the other columns should be deleted.

It's working perfectly if I only want to keep one column from every feature, but for some of my features I want to keep two or three columns.

I tried to add a second column, but it was not working, because it was empty for most of my features. I also tried to add more than one column name in the "keep_it_2" column... also not working.

Here you can see my Table:

enter image description here

enter image description here

So for ObjectID 1 I want to keep the Field named "WSGNR" and "WSG_Name". Just keeping "WSGNR" from "keep it" works - but to combine it with a second field is not working.

Any ideas?

closed as off-topic by PolyGeo Oct 10 '18 at 4:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What software are you working with? – Erik Aug 16 '18 at 15:23
  • ESRI ArcGIS 10. – Lisa Aug 16 '18 at 15:30
  • Could you add some screenshots showing what you want to do? – BERA Aug 16 '18 at 16:21
  • 1
    And what does your code look like for deleting all fields but WSGNR? – BERA Aug 17 '18 at 10:17
  • 1
    "ArcGIS 10" is several generations of software, spanning most of a decade. Please specify the exact software in use. – Vince Aug 17 '18 at 18:03
0

There's probably a 'cleaner' way to do it, but you could use the 'Merge' tool under Data Management>General. Just input the feature class and use the field map parameter to quickly remove fields you don't want, or to rename them, even.

  • I know that I can do it manually the way you described. But I'm trying to automatize the process so i can iterate over all my input data. – Lisa Aug 17 '18 at 6:48
  • Oh, I missed the part where you wanted to keep specific columns on a per-feature basis. – Tim R Aug 17 '18 at 14:45
-1

I just find this to be easier to do with GDAL using OGR2OGR - just do a regular SQL Query in the SELECT statement you list the columns you want to keep and you can alias columns as well as changing order. Here is an example.

ogr2ogr -f "GeoJSON" -skipfailures -progress -sql "SELECT BDRY_IDENT as IDENT,TYPE,NAME,CLASS FROM boundary_airspace_highandlow_merged WHERE TYPE IN ('11','8') AND CLASS='C'" %process_dir%\class_c_airspace_forlinelimitedattributes.geojson %process_dir%\boundary_airspace_highandlow_merged.shp

Easiest way to install GDAL is via OSGEO4W Installer and it will install most utilities and QGIS Desktop.

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