Created
February 17, 2021 18:58
-
-
Save ThomasG77/243f658d1001b2e31c18d383a6757c77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate structure | |
rm -rf demo | |
mkdir demo | |
mkdir demo/germany | |
mkdir demo/france | |
cd demo/germany | |
# Get data | |
ogr2ogr germany.shp /vsicurl/https://github.com/datasets/geo-countries/raw/master/data/countries.geojson -dialect SQLite -sql "SELECT * FROM countries WHERE ADMIN = 'Germany'" | |
cd ../france | |
ogr2ogr france.shp /vsicurl/https://github.com/datasets/geo-countries/raw/master/data/countries.geojson -dialect SQLite -sql "SELECT * FROM countries WHERE ADMIN = 'France'" | |
cd ../.. | |
# See directory structure | |
tree demo | |
# Merge and add a custom column filled with infos from origin layers | |
ogrmerge.py -single -overwrite_ds -o merged.shp demo/*/*shp -src_layer_field_name custom1 -src_layer_field_content '{DS_NAME} AND {AUTO_NAME}' | |
# See how the custom field content has been filled | |
ogrinfo -geom=NO merged.shp merged | |
# In src_layer_field_content from ogrmerge.py line, | |
# use below template keyword to see change in | |
# '{AUTO_NAME}' | |
# '{DS_BASENAME}' | |
# '{DS_BASENAME}' | |
# '{DS_NAME}' | |
# '{DS_INDEX}' | |
# '{LAYER_NAME}' | |
# '{LAYER_INDEX}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment