mirror of
https://github.com/oDinZu/natural-earth-vector.git
synced 2025-02-22 00:04:57 -05:00
wikidata : refactored "run_all.sh" process with individual modes: fetch,write,fetch_write,copy,all
This commit is contained in:
parent
8bfe7ed9d5
commit
ef10e96db1
80
run_all.sh
80
run_all.sh
@ -17,30 +17,78 @@ cat VERSION
|
||||
# Show some debug info
|
||||
python3 ./tools/wikidata/platform_debug_info.py
|
||||
|
||||
# Fetch latest wikidata labels
|
||||
# --- output: x_tempshape/*/*.new_names.csv files
|
||||
time ./tools/wikidata/update.sh fetch
|
||||
|
||||
# Write wikidata labels to the shape files
|
||||
# --- output: x_tempshape/*/*.shp files and some audit logs
|
||||
time ./tools/wikidata/update.sh write
|
||||
# Summary Log file
|
||||
logmd=x_tempshape/update.md
|
||||
rm -f $logmd
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------------
|
||||
# mode = fetch | write | fetch_write | copy | all
|
||||
# LetterCase = uppercase --> variable names [WIKIDATAID, NAME_AR, NAME_BN, NAME_DE, NAME_EN, NAME_ES, ... ]
|
||||
# LetterCase = lowercase --> variable names [wikidataid, name_ar, name_bn, name_de, name_en, name_es, ... ]
|
||||
# --------------------------------------------------------------------------------------------------------------------
|
||||
# |mode |LetterCase| shape_path | shape filename
|
||||
# == 10m ================= |==== |==========| ============| ================================================
|
||||
./tools/wikidata/update.sh all uppercase 10m_cultural ne_10m_admin_0_countries_lakes
|
||||
./tools/wikidata/update.sh all uppercase 10m_cultural ne_10m_admin_0_countries
|
||||
./tools/wikidata/update.sh all uppercase 10m_cultural ne_10m_admin_0_disputed_areas
|
||||
./tools/wikidata/update.sh all uppercase 10m_cultural ne_10m_admin_0_map_subunits
|
||||
./tools/wikidata/update.sh all uppercase 10m_cultural ne_10m_admin_0_map_units
|
||||
./tools/wikidata/update.sh all uppercase 10m_cultural ne_10m_admin_0_sovereignty
|
||||
./tools/wikidata/update.sh all lowercase 10m_cultural ne_10m_admin_1_states_provinces_lakes
|
||||
./tools/wikidata/update.sh all lowercase 10m_cultural ne_10m_admin_1_states_provinces
|
||||
./tools/wikidata/update.sh all lowercase 10m_cultural ne_10m_airports
|
||||
./tools/wikidata/update.sh all lowercase 10m_cultural ne_10m_populated_places
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_geographic_lines
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_geography_marine_polys
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_geography_regions_elevation_points
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_geography_regions_points
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_geography_regions_polys
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_lakes_europe
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_lakes_historic
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_lakes_north_america
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_lakes
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_playas
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_rivers_europe
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_rivers_lake_centerlines_scale_rank
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_rivers_lake_centerlines
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_rivers_north_america
|
||||
./tools/wikidata/update.sh all lowercase 10m_cultural ne_10m_admin_1_label_points_details
|
||||
# == 50m ================= |==== |==========| ============| ================================================
|
||||
./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_sovereignty
|
||||
./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_countries
|
||||
./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_countries_lakes
|
||||
./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_map_units
|
||||
./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_map_subunits
|
||||
./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_tiny_countries
|
||||
#./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_breakaway_disputed_areas # KeyError: 'WIKIDATAID'
|
||||
#./tools/wikidata/update.sh all uppercase 50m_cultural ne_50m_admin_0_breakaway_disputed_areas_scale_rank # KeyError: 'WIKIDATAID'
|
||||
./tools/wikidata/update.sh all lowercase 50m_cultural ne_50m_admin_1_states_provinces
|
||||
./tools/wikidata/update.sh all lowercase 50m_cultural ne_50m_admin_1_states_provinces_lakes
|
||||
./tools/wikidata/update.sh all lowercase 50m_physical ne_50m_lakes
|
||||
./tools/wikidata/update.sh all lowercase 50m_physical ne_50m_lakes_historic
|
||||
./tools/wikidata/update.sh all lowercase 50m_physical ne_50m_playas
|
||||
./tools/wikidata/update.sh all lowercase 50m_physical ne_50m_rivers_lake_centerlines
|
||||
./tools/wikidata/update.sh all lowercase 50m_physical ne_50m_rivers_lake_centerlines_scale_rank
|
||||
# ==110m ================= |==== |==========| ============| ================================================
|
||||
./tools/wikidata/update.sh all uppercase 110m_cultural ne_110m_admin_0_sovereignty
|
||||
./tools/wikidata/update.sh all uppercase 110m_cultural ne_110m_admin_0_countries
|
||||
./tools/wikidata/update.sh all uppercase 110m_cultural ne_110m_admin_0_countries_lakes
|
||||
./tools/wikidata/update.sh all uppercase 110m_cultural ne_110m_admin_0_map_units
|
||||
./tools/wikidata/update.sh all lowercase 110m_cultural ne_110m_admin_1_states_provinces
|
||||
./tools/wikidata/update.sh all lowercase 110m_cultural ne_110m_admin_1_states_provinces_lakes
|
||||
./tools/wikidata/update.sh all lowercase 110m_physical ne_110m_lakes
|
||||
./tools/wikidata/update.sh all lowercase 110m_physical ne_110m_rivers_lake_centerlines
|
||||
# ======================== |==== |==========| ============| ================================================
|
||||
|
||||
# show summary
|
||||
cat x_tempshape/update.md
|
||||
|
||||
# list new files
|
||||
ls -la x_tempshape/*/*
|
||||
|
||||
# Update shape files
|
||||
cp -r x_tempshape/10m_cultural/* 10m_cultural/
|
||||
cp -r x_tempshape/10m_physical/* 10m_physical/
|
||||
cp -r x_tempshape/50m_cultural/* 50m_cultural/
|
||||
cp -r x_tempshape/50m_physical/* 50m_physical/
|
||||
cp -r x_tempshape/110m_cultural/* 110m_cultural/
|
||||
cp -r x_tempshape/110m_physical/* 110m_physical/
|
||||
ls -Gga x_tempshape/*/*
|
||||
|
||||
# Run the final update process
|
||||
make clean all
|
||||
|
||||
echo " ---- end of run_all.sh ------ "
|
||||
ls -la $log_file
|
||||
ls -Gga $log_file
|
@ -7,84 +7,60 @@
|
||||
pip3 install -U csvtomd
|
||||
pip3 install -U requests
|
||||
|
||||
#run from the project root ( expected 10-20 minutes )
|
||||
time ./tools/wikidata/update.sh fetch # download new names from wikidata as a csvfile
|
||||
time ./tools/wikidata/update.sh write # update shape files with the csv files
|
||||
cat ./temp_shape/update.md
|
||||
#run from the project root ( expected 30-40 minutes )
|
||||
# be careful this is running 'make all'
|
||||
./run_all.sh
|
||||
|
||||
# See the changes: temp_shape/*
|
||||
# Check the logs & shape files
|
||||
# if everything is ok, move the shape files to the correct folder
|
||||
# Check the log file
|
||||
cat x_tempshape/run_all.log
|
||||
|
||||
# Check the summary ..
|
||||
x_tempshape/update.md
|
||||
|
||||
# Check the individula changes - every tables - in the temp_shape/*
|
||||
# Check the logs & shape files
|
||||
# if everything is ok, move the shape files to the correct folder
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
# Fetch all wikidata labels(names):
|
||||
# Run individual process ( updating "10m_physical/ne_10m_lakes_north_america.shp" )
|
||||
|
||||
command:
|
||||
`./tools/wikidata/update.sh fetch`
|
||||
|
||||
output - lot of csv files:
|
||||
```bash
|
||||
# |mode |LetterCase| shape_path | shape filename
|
||||
# == 10m ================= |==== |==========| ============| ================================================
|
||||
./tools/wikidata/update.sh all lowercase 10m_physical ne_10m_lakes_north_america
|
||||
```
|
||||
$ find ./temp_shape/*/*.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_0_countries_lakes.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_0_countries.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_0_disputed_areas.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_0_map_subunits.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_0_map_units.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_0_sovereignty.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_1_label_points_details.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_1_states_provinces_lakes.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_admin_1_states_provinces.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_airports.shp.new_names.csv
|
||||
./temp_shape/10m_cultural/ne_10m_populated_places.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_geographic_lines.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_geography_marine_polys.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_geography_regions_elevation_points.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_geography_regions_points.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_geography_regions_polys.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_lakes_europe.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_lakes_historic.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_lakes.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_playas.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_rivers_europe.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_rivers_lake_centerlines_scale_rank.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_rivers_lake_centerlines.shp.new_names.csv
|
||||
./temp_shape/10m_physical/ne_10m_rivers_north_america.shp.new_names.csv
|
||||
|
||||
mode =
|
||||
* fetch = fetch Wikidata Labels(names) via SPARQL - and create a csv file
|
||||
* write = create a new temp Shape file with the new wikidata names
|
||||
* fetch_write = fetch and write
|
||||
* copy = copy the temp Shape + audit files to the original place
|
||||
* all = fetch + write + copy
|
||||
|
||||
|
||||
step by step
|
||||
```bash
|
||||
# |mode |LetterCase| shape_path | shape filename
|
||||
# ======================== |=========== |==========| ============| ================================================
|
||||
# fetch Wikidata Labels(names) via SPARQL - and create a csv file
|
||||
./tools/wikidata/update.sh fetch lowercase 10m_physical ne_10m_lakes_north_america
|
||||
|
||||
# create a new temp Shape file with the new wikidata names
|
||||
./tools/wikidata/update.sh write lowercase 10m_physical ne_10m_lakes_north_america
|
||||
|
||||
# copy the temp Shape + audit files to the original place
|
||||
./tools/wikidata/update.sh copy lowercase 10m_physical ne_10m_lakes_north_america
|
||||
|
||||
```
|
||||
|
||||
# Write all wikidata labels(names):
|
||||
|
||||
|
||||
command:
|
||||
`./tools/wikidata/update.sh write`
|
||||
|
||||
Output - updated shape files and audit logs about the changes ...
|
||||
|
||||
summary of the changes: ./temp_shape/update.md
|
||||
|
||||
example:
|
||||
|
||||
```
|
||||
$ find ./temp_shape/10m_physical/ne_10m_lakes_north_america*
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.cpg
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.dbf
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.prj
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.changes_log.csv # Column changes - csv format
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.changes_log.csv.md # Column changes - markdown
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.new_names.csv # input csv
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.summary_log.csv # Summary of the changes - csv
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.summary_log.csv.md # Summary of the changes - markdown
|
||||
./temp_shape/10m_physical/ne_10m_lakes_north_america.shx
|
||||
```
|
||||
|
||||
|
||||
### /temp_shape/10m_physical/ne_10m_lakes_north_america.shp.changes_log.csv # Column changes - csv format
|
||||
### /temp_shape/10m_physical/ne_10m_lakes_north_america.changes_log.csv # Column changes - csv format
|
||||
|
||||
```
|
||||
"wd_id","status","variable","value_old","value_new"
|
||||
@ -101,7 +77,7 @@ $ find ./temp_shape/10m_physical/ne_10m_lakes_north_america*
|
||||
"Q1800890","NEWvalue","name_sv","","Chemong Lake"
|
||||
```
|
||||
|
||||
### ./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.changes_log.csv.md # Column changes - markdown
|
||||
### ./temp_shape/10m_physical/ne_10m_lakes_north_america.changes_log.csv.md # Column changes - markdown
|
||||
|
||||
wd_id | status | variable | value_old | value_new
|
||||
-----------|------------|--------------|-------------------|-----------------------------------
|
||||
@ -118,10 +94,10 @@ Q1800890 | MODvalue | name_en | Lake Chemong | Chemong Lake
|
||||
Q1800890 | NEWvalue | name_sv | | Chemong Lake
|
||||
|
||||
|
||||
### ./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.new_names.csv # input csv
|
||||
### ./temp_shape/10m_physical/ne_10m_lakes_north_america.new_names.csv # input csv
|
||||
|
||||
```bash
|
||||
$ cat ./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.new_names.csv | head
|
||||
$ cat ./temp_shape/10m_physical/ne_10m_lakes_north_america.new_names.csv | head
|
||||
"wd_id","wd_id_new","population","name_ar","name_bn","name_de","name_en","name_es","name_fr","name_el","name_hi","name_hu","name_id","name_it","name_ja","name_ko","name_nl","name_pl","name_pt","name_ru","name_sv","name_tr","name_vi","name_zh"
|
||||
"Q1426999","","","","","Theodore Roosevelt Lake","Theodore Roosevelt Lake","","","","","","","","","","","","","Рузвельт","","","",""
|
||||
"Q4397897","","","","","","Ross Barnett Reservoir","","","","","","","","","","","","","Росс Барнетт","","","",""
|
||||
@ -135,7 +111,7 @@ $ cat ./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.new_names.csv | h
|
||||
...
|
||||
```
|
||||
|
||||
### ./temp_shape/10m_physical/ne_10m_lakes_north_america.shp.summary_log.csv # Summary of the changes - csv
|
||||
### ./temp_shape/10m_physical/ne_10m_lakes_north_america.summary_log.csv # Summary of the changes - csv
|
||||
|
||||
```csv
|
||||
"shapefilename","var","value"
|
||||
@ -170,17 +146,12 @@ shapefilename | var | value
|
||||
|
||||
# My best practice ...
|
||||
|
||||
|
||||
* First iteration
|
||||
`./tools/wikidata/update.sh fetch`
|
||||
`./tools/wikidata/update.sh write`
|
||||
|
||||
* check the audit csv files ( Open by Libreoffice , filter , check the wikidata history )
|
||||
* Run step by step ( line by line) : `./run_all.sh` in `fetch_write` mode
|
||||
* check the audit csv files ( Open by Libreoffice , filter )
|
||||
* find & fix the 'fake' wikidata changes :(
|
||||
* iterate or modify input csv and write shape files
|
||||
* check shape files and move the shape files to the correct folders
|
||||
|
||||
|
||||
# known problems
|
||||
|
||||
### updating 10m_cultural/ne_10m_admin_1_label_points_details.shp
|
||||
@ -230,7 +201,7 @@ lettercase = lowercase variable names [wikidataid, name_ar, name_bn, name_de, na
|
||||
* 110m_cultural/...
|
||||
* 110m_physical/...
|
||||
|
||||
see the _latest_ information in the `update.sh`
|
||||
see the _latest_ information in the `./run_all.sh`
|
||||
|
||||
|
||||
### supported languages ( now: 21)
|
||||
@ -259,9 +230,3 @@ variable name | language | language wikipedia link
|
||||
NAME_VI | Vietnamese | https://en.wikipedia.org/wiki/Vietnamese_language
|
||||
NAME_ZH | Chinese | https://en.wikipedia.org/wiki/Chinese_language
|
||||
|
||||
|
||||
### program files
|
||||
|
||||
* fetch_wikidata.py :
|
||||
* write_wikidata.py :
|
||||
* update.sh :
|
||||
|
@ -1,10 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
mode=${1-all}
|
||||
|
||||
|
||||
|
||||
|
||||
# check correct start with file existence
|
||||
if [ ! -f tools/wikidata/fetch_wikidata.py ];
|
||||
@ -13,86 +9,72 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mode=$1
|
||||
nei_letter_case=$2
|
||||
nei_path=.
|
||||
neo_path=x_tempshape
|
||||
ne_shapepath=$3
|
||||
ne_shapefile=$4
|
||||
|
||||
mkdir -p ${neo_path}/${ne_shapepath}
|
||||
logmd=${neo_path}/update.md
|
||||
|
||||
echo " "
|
||||
echo "########## /tools/wikidata/update.sh parameters:"
|
||||
echo " 1: mode : ${mode}"
|
||||
echo " 2: nei_letter_case: ${nei_letter_case}"
|
||||
#echo " nei_path : ${nei_path}"
|
||||
echo " 3: neo_path : ${neo_path}"
|
||||
echo " 4: ne_shapepath : ${ne_shapepath}"
|
||||
echo " 5: ne_shapefile : ${ne_shapefile}"
|
||||
echo " "
|
||||
|
||||
|
||||
|
||||
|
||||
function fetch_names {
|
||||
nei_letter_case=$1
|
||||
nei_path=$2
|
||||
neo_path=$3
|
||||
ne_shapepath=$4
|
||||
ne_shapefile=$5
|
||||
|
||||
mkdir -p ${neo_path}/${ne_shapepath}
|
||||
|
||||
echo " "
|
||||
echo "########## Fetching ... ${nei_path}/${ne_shapepath}/${ne_shapefile} "
|
||||
echo " "
|
||||
echo "parameters:"
|
||||
echo " nei_letter_case: ${nei_letter_case}"
|
||||
echo " nei_path : ${nei_path}"
|
||||
echo " neo_path : ${neo_path}"
|
||||
echo " ne_shapepath : ${ne_shapepath}"
|
||||
echo " ne_shapefile : ${ne_shapefile}"
|
||||
echo " "
|
||||
echo " Fetch wikidata labels "
|
||||
echo " ================================="
|
||||
ogrinfo -al -so ${nei_path}/${ne_shapepath}/${ne_shapefile}.shp
|
||||
|
||||
|
||||
ogrinfo -al -so ${nei_path}/${ne_shapepath}/${ne_shapefile}
|
||||
|
||||
python3 tools/wikidata/fetch_wikidata.py -input_shape_name ${nei_path}/${ne_shapepath}/${ne_shapefile} \
|
||||
python3 tools/wikidata/fetch_wikidata.py -input_shape_name ${nei_path}/${ne_shapepath}/${ne_shapefile}.shp \
|
||||
-input_lettercase ${nei_letter_case} \
|
||||
-output_csv_name ${neo_path}/${ne_shapepath}/${ne_shapefile}.new_names.csv
|
||||
echo " created : ${neo_path}/${ne_shapepath}/${ne_shapefile}.new_names.csv "
|
||||
echo " "
|
||||
}
|
||||
|
||||
|
||||
function write_names {
|
||||
nei_letter_case=$1
|
||||
nei_path=$2
|
||||
neo_path=$3
|
||||
ne_shapepath=$4
|
||||
ne_shapefile=$5
|
||||
|
||||
mkdir -p ${neo_path}/${ne_shapepath}
|
||||
|
||||
echo " "
|
||||
echo "########## Writing ... ${neo_path}/${ne_shapepath}/${ne_shapefile} "
|
||||
echo " "
|
||||
echo "parameters:"
|
||||
echo " nei_letter_case: ${nei_letter_case}"
|
||||
echo " nei_path : ${nei_path}"
|
||||
echo " neo_path : ${neo_path}"
|
||||
echo " ne_shapepath : ${ne_shapepath}"
|
||||
echo " ne_shapefile : ${ne_shapefile}"
|
||||
echo " "
|
||||
|
||||
|
||||
if [ ! -f ${nei_path}/${ne_shapepath}/${ne_shapefile} ];
|
||||
echo " Write shapefile with wikidata labels "
|
||||
echo " ================================="
|
||||
echo " shapefile info : ${neo_path}/${ne_shapepath}/${ne_shapefile} "
|
||||
if [ ! -f ${nei_path}/${ne_shapepath}/${ne_shapefile}.shp ];
|
||||
then
|
||||
echo "ERROR: ${nei_path}/${ne_shapepath}/${ne_shapefile} not exist! STOP "
|
||||
echo "ERROR: ${nei_path}/${ne_shapepath}/${ne_shapefile}.shp not exist! STOP "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f ${neo_path}/${ne_shapepath}/${ne_shapefile}.new_names.csv ];
|
||||
then
|
||||
echo "ERROR: ${neo_path}/${ne_shapepath}/${ne_shapefile}.new_names.csv not exist! STOP "
|
||||
echo "hint: You should run the fetch part first! "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
python3 tools/wikidata/write_wikidata.py -input_shape ${nei_path}/${ne_shapepath}/${ne_shapefile} \
|
||||
python3 tools/wikidata/write_wikidata.py -input_shape ${nei_path}/${ne_shapepath}/${ne_shapefile}.shp \
|
||||
-input_lettercase ${nei_letter_case} \
|
||||
-input_csv ${neo_path}/${ne_shapepath}/${ne_shapefile}.new_names.csv \
|
||||
-output_shape ${neo_path}/${ne_shapepath}/${ne_shapefile} \
|
||||
-output_shape ${neo_path}/${ne_shapepath}/${ne_shapefile}.shp \
|
||||
-output_csvlog ${neo_path}/${ne_shapepath}/${ne_shapefile}.changes_log.csv \
|
||||
-output_csvsumlog ${neo_path}/${ne_shapepath}/${ne_shapefile}.summary_log.csv
|
||||
|
||||
|
||||
echo " " >> $logmd
|
||||
echo "### ${neo_path}/${ne_shapepath}/${ne_shapefile}" >> $logmd
|
||||
echo " " >> $logmd
|
||||
csvtomd ${neo_path}/${ne_shapepath}/${ne_shapefile}.summary_log.csv >> $logmd
|
||||
echo " " >> $logmd
|
||||
echo "### ${neo_path}/${ne_shapepath}/${ne_shapefile}" >> $logmd
|
||||
echo " " >> $logmd
|
||||
csvtomd ${neo_path}/${ne_shapepath}/${ne_shapefile}.summary_log.csv >> $logmd
|
||||
|
||||
csvtomd ${neo_path}/${ne_shapepath}/${ne_shapefile}.changes_log.csv > ${neo_path}/${ne_shapepath}/${ne_shapefile}.changes_log.csv.md
|
||||
csvtomd ${neo_path}/${ne_shapepath}/${ne_shapefile}.summary_log.csv > ${neo_path}/${ne_shapepath}/${ne_shapefile}.summary_log.csv.md
|
||||
@ -106,104 +88,49 @@ function write_names {
|
||||
|
||||
cat ${neo_path}/${ne_shapepath}/${ne_shapefile}.summary_log.csv.md
|
||||
echo " "
|
||||
|
||||
echo " (write) created :"
|
||||
echo " -------------------"
|
||||
ls -Gga ${neo_path}/${ne_shapepath}/${ne_shapefile}*
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
function update_names {
|
||||
|
||||
if [[ "$mode" == "fetch" ]]
|
||||
then
|
||||
echo "fetch ... $1 $2 $3 $4 $5"
|
||||
fetch_names $1 $2 $3 $4 $5
|
||||
elif [[ "$mode" == "write" ]]
|
||||
then
|
||||
echo "write ... $1 $2 $3 $4 $5"
|
||||
write_names $1 $2 $3 $4 $5
|
||||
else
|
||||
echo "fetch+write ... $1 $2 $3 $4 $5"
|
||||
fetch_names $1 $2 $3 $4 $5
|
||||
write_names $1 $2 $3 $4 $5
|
||||
fi
|
||||
function copy_names {
|
||||
echo " "
|
||||
echo " Copy shape + audit files "
|
||||
echo " =============================== "
|
||||
cp -v ${neo_path}/${ne_shapepath}/${ne_shapefile}*.* ${ne_shapepath}/
|
||||
}
|
||||
|
||||
if [[ "$mode" == "fetch" ]]
|
||||
then
|
||||
#echo "fetch"
|
||||
fetch_names
|
||||
elif [[ "$mode" == "write" ]]
|
||||
then
|
||||
#echo "write"
|
||||
write_names
|
||||
elif [[ "$mode" == "fetch_write" ]]
|
||||
then
|
||||
#echo "fetch_write "
|
||||
fetch_names
|
||||
write_names
|
||||
elif [[ "$mode" == "copy" ]]
|
||||
then
|
||||
#echo "copy files"
|
||||
copy_names
|
||||
elif [[ "$mode" == "all" ]]
|
||||
then
|
||||
#echo "fetch + write + copy"
|
||||
fetch_names
|
||||
write_names
|
||||
copy_names
|
||||
else
|
||||
echo "Unknown mode! the first parameter should be:[fetch/write/fetch_write/copy/all]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
exit
|
||||
|
||||
|
||||
|
||||
|
||||
logmd=x_tempshape/update.md
|
||||
rm -f $logmd
|
||||
|
||||
# lettercase = uppercase --> variable names [WIKIDATAID, NAME_AR, NAME_BN, NAME_DE, NAME_EN, NAME_ES, ... ]
|
||||
# lettercase = lowercase --> variable names [wikidataid, name_ar, name_bn, name_de, name_en, name_es, ... ]
|
||||
|
||||
# lettercase | input folder | output folder | shape_path | shape filename
|
||||
# ----------------------| ------------ | ------------- | -------------| ---------------------------------------
|
||||
update_names uppercase . x_tempshape 10m_cultural ne_10m_admin_0_countries_lakes.shp
|
||||
update_names uppercase . x_tempshape 10m_cultural ne_10m_admin_0_countries.shp
|
||||
update_names uppercase . x_tempshape 10m_cultural ne_10m_admin_0_disputed_areas.shp
|
||||
update_names uppercase . x_tempshape 10m_cultural ne_10m_admin_0_map_subunits.shp
|
||||
update_names uppercase . x_tempshape 10m_cultural ne_10m_admin_0_map_units.shp
|
||||
update_names uppercase . x_tempshape 10m_cultural ne_10m_admin_0_sovereignty.shp
|
||||
|
||||
update_names lowercase . x_tempshape 10m_cultural ne_10m_admin_1_states_provinces_lakes.shp
|
||||
update_names lowercase . x_tempshape 10m_cultural ne_10m_admin_1_states_provinces.shp
|
||||
update_names lowercase . x_tempshape 10m_cultural ne_10m_airports.shp
|
||||
update_names lowercase . x_tempshape 10m_cultural ne_10m_populated_places.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_geographic_lines.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_geography_marine_polys.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_geography_regions_elevation_points.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_geography_regions_points.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_geography_regions_polys.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_lakes_europe.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_lakes_historic.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_lakes_north_america.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_lakes.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_playas.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_rivers_europe.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_rivers_lake_centerlines_scale_rank.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_rivers_lake_centerlines.shp
|
||||
update_names lowercase . x_tempshape 10m_physical ne_10m_rivers_north_america.shp
|
||||
|
||||
update_names lowercase . x_tempshape 10m_cultural ne_10m_admin_1_label_points_details.shp
|
||||
|
||||
|
||||
|
||||
update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_sovereignty.shp
|
||||
update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_countries.shp
|
||||
update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_countries_lakes.shp
|
||||
update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_map_units.shp
|
||||
update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_map_subunits.shp
|
||||
update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_tiny_countries.shp
|
||||
|
||||
# missing / KeyError: 'WIKIDATAID'
|
||||
#update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_breakaway_disputed_areas.shp
|
||||
#update_names uppercase . x_tempshape 50m_cultural ne_50m_admin_0_breakaway_disputed_areas_scale_rank.shp
|
||||
|
||||
update_names lowercase . x_tempshape 50m_cultural ne_50m_admin_1_states_provinces.shp
|
||||
update_names lowercase . x_tempshape 50m_cultural ne_50m_admin_1_states_provinces_lakes.shp
|
||||
update_names lowercase . x_tempshape 50m_physical ne_50m_lakes.shp
|
||||
update_names lowercase . x_tempshape 50m_physical ne_50m_lakes_historic.shp
|
||||
update_names lowercase . x_tempshape 50m_physical ne_50m_playas.shp
|
||||
update_names lowercase . x_tempshape 50m_physical ne_50m_rivers_lake_centerlines.shp
|
||||
update_names lowercase . x_tempshape 50m_physical ne_50m_rivers_lake_centerlines_scale_rank.shp
|
||||
|
||||
update_names uppercase . x_tempshape 110m_cultural ne_110m_admin_0_sovereignty.shp
|
||||
update_names uppercase . x_tempshape 110m_cultural ne_110m_admin_0_countries.shp
|
||||
update_names uppercase . x_tempshape 110m_cultural ne_110m_admin_0_countries_lakes.shp
|
||||
update_names uppercase . x_tempshape 110m_cultural ne_110m_admin_0_map_units.shp
|
||||
update_names lowercase . x_tempshape 110m_cultural ne_110m_admin_1_states_provinces.shp
|
||||
update_names lowercase . x_tempshape 110m_cultural ne_110m_admin_1_states_provinces_lakes.shp
|
||||
update_names lowercase . x_tempshape 110m_physical ne_110m_lakes.shp
|
||||
update_names lowercase . x_tempshape 110m_physical ne_110m_rivers_lake_centerlines.shp
|
||||
|
||||
|
||||
#known problems:
|
||||
# ----------------------------------------------------------------------------------------
|
||||
# Warningis - in 10m_cultural ne_10m_admin_1_label_points_details.shp
|
||||
#
|
||||
# WARNING:Fion a:CPLE_AppDefined in b'Value -4.75267000000000017 of field longitude of feature 4645 not successfully written. Possibly due to too larger number with respect to field width'
|
||||
# WARNING:Fiona:CPLE_AppDefined in b'Value 10.2509999999999994 of field latitude of feature 4646 not successfully written. Possibly due to too larger number with respect to field width'
|
||||
# WARNING:Fiona:CPLE_AppDefined in b'Value -3.34011000000000013 of field longitude of feature 4646 not successfully written. Possibly due to too larger number with respect to field width'
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user