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
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:
Answers
-
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.
-
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"
Cheers,
EDIT_VECTOR ATTR_TO_RENAME="attribute2=attribute1"
EXPORT_VECTOR TYPE="SHAPEFILE" FILENAME="shapefile3.shp" // plus other parameter as needed
Bob
Categories
- 12.8K All Categories
- 5.7K Features Discussion
- 346 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 639 GM Script Language
- 54 User Scripts
- 115 GPS Features
- 417 Projection Questions
- 829 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 179 Announcement and News
- 922 Bug Report
- 559 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 573 Other Discussion
- 131 GIS Data Sources
- 27 Global Mapper Showcase
- 241 How I use Global Mapper
- 108 Global Mapper Forum Website