EDIT_VECTOR - attributes to keep vs delete

I have been experimenting with EDIT_VECTOR and I couldn't figure out how to merge two shapefiles with the attributes I want to keep. I can do this with the user interface and I would like to be able to automate.

I have two shapefiles; 
shapefile1.shp has 1 attribute; "attribute1"
shapefile2.shp has 20 different attributes. I would like to remove all of them except "attribute2"

I would like to be able to import these 2 different shapefiles into GM, then export them as one shapefile (shapefile3.shp) with only "attribute1". I would also like to be able to save attribute2 values from shapefile2.shp as attribute1, so I would end up with only "attribute1" in the new shapefile.

I would appreciate any input/examples you previously used!
Thanks
Tagged:

Best Answer

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,834
    Answer ✓
    Hello,

    Here is a bit of script that will do what you want to do.  It assumes that you have already imported your two files.
    EDIT_VECTOR ATTR_TO_KEEP="attribute1" ATTR_TO_KEEP="attribute2"
    EDIT_VECTOR ATTR_TO_RENAME="attribute2=attribute1"
    EXPORT_VECTOR TYPE="SHAPEFILE" FILENAME="shapefile3.shp" // plus other parameter as needed
    Cheers,
    Bob

Answers

  • kaankaan Posts: 12
    alternatively, I am the one creating "shapefile2.shp" with GM. If I could select the attributes I want to keep with EXPORT_VECTOR that would also solve my issue. I don't see the option to select attributes for that though.
Sign In or Register to comment.