Skip to content
Snippets Groups Projects
Commit 0fa0b760 authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

Initial commit with template structure + geo locations of ariprorts in Europe.

parent 8c7d887c
No related branches found
No related tags found
1 merge request!1New branch with fixed history
FROM mariadb:11.1
# copy directories with scripts
COPY inputs/update_sys.sh /root/inputs/update_sys.sh
RUN chmod a+x /root/inputs/update_sys.sh
COPY dump /docker-entrypoint-initdb.d
# update system for security reasons
RUN $HOME/inputs/update_sys.sh
#!/bin/bash
# create database
./inputs/setup_db.sh
# load vector data into DB
./inputs/load_vector_data.sh
# load NUTS objects into DB
./inputs/load_table_data.sh
# dump data and drop database on 'local' instance
./inputs/dump_and_drop.sh
echo "*** Dump database:"
mkdir -p ./dump
mariadb-dump -h "" -u "root" -p --databases FACT_air > ./dump/db_air.sql
echo "*** Drop database:"
mariadb -h "" -u "root" -p < inputs/sql/drop_db.sql
#!/bin/bash
# Europe
# size of traffic .. to be developed
for y in {2014..2022}
do
mkdir -p ./temp
wget -O ./temp/temp_M.tsv -N "https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT/demo_r_pjangrp3/1.0?&c[sex]=M&c[time_period]=${y}&format=tsv"
wget -O ./temp/temp_F.tsv -N "https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT/demo_r_pjangrp3/1.0?&c[sex]=F&c[time_period]=${y}&format=tsv"
mariadb -h "" -u "root" -p -e "CREATE TEMPORARY TABLE FACT_population.staging_M (Row varchar(50) NOT NULL, Value INT, Year INT); LOAD DATA LOCAL INFILE \"temp/temp_M.tsv\" INTO TABLE FACT_population.staging_M FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' IGNORE 1 LINES (@col1, @col2) SET Row=@col1, Value=@col2, Year=${y}; CREATE TEMPORARY TABLE FACT_population.staging_F (Row varchar(50) NOT NULL, Value INT, Year INT); LOAD DATA LOCAL INFILE \"temp/temp_F.tsv\" INTO TABLE FACT_population.staging_F FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' IGNORE 1 LINES (@col1, @col2) SET Row=@col1, Value=@col2, Year=${y}; INSERT INTO FACT_population.eu_nuts (GeoID, Year, AgeClass, Pop_M) SELECT SUBSTRING_INDEX(Row,',',-1), Year, SUBSTRING_INDEX(SUBSTRING_INDEX(Row,',',-2),',',1), Value FROM FACT_population.staging_M ON DUPLICATE KEY UPDATE Pop_M = Value; INSERT INTO FACT_population.eu_nuts (GeoID, Year, AgeClass, Pop_F) SELECT SUBSTRING_INDEX(Row,',',-1), Year, SUBSTRING_INDEX(SUBSTRING_INDEX(Row,',',-2),',',1), Value FROM FACT_population.staging_F ON DUPLICATE KEY UPDATE Pop_F = Value;"
rm -r ./temp
done
#!/bin/bash
# Europe
# coordinate reference system: ETRS89 / LAEA
echo "*** Downloading and loading EU airports location." # expected number of records in DB:
# 2006
mkdir -p ./temp
wget -N 'https://ec.europa.eu/eurostat/cache/GISCO/geodatafiles/AIRP_SH.zip' -P ./temp
unzip -d ./temp/ ./temp/AIRP_SH.zip
ogr2ogr -f MySQL MySQL:FACT_air,host=,user=root,password= ./temp/AIRP_SH/shape/data/AIRP_ICAO_PT.shp -nln eu_airports_2006 -update -overwrite -lco engine=Aria
rm -r ./temp
# 2011
mkdir -p ./temp
wget -N 'https://ec.europa.eu/eurostat/cache/GISCO/geodatafiles/Airports-2013-SHP.zip' -P ./temp
unzip -d ./temp/ ./temp/Airports-2013-SHP.zip
ogr2ogr -f MySQL MySQL:FACT_air,host=,user=root,password= ./temp/SHAPE/AIRP_PT_2013.shp -nln eu_airports_2013 -update -overwrite -lco engine=Aria
rm -r ./temp
echo "*** Create database:"
mariadb -h "" -u "root" -p < inputs/sql/create_db.sql
echo "*** Create tables:"
mariadb -h "" -u "root" -p < inputs/sql/create_tables.sql
CREATE DATABASE IF NOT EXISTS FACT_air;
CREATE TABLE FACT_air.eu_traffic (
grd_id varchar(50) NOT NULL,
pop_tot INT NULL,
year INT NOT NULL,
methd_cl varchar(10) NULL,
cntr_code varchar(30) NULL,
data_src varchar(10) NULL,
PRIMARY KEY (grd_id, cntr_code, year)
)
ENGINE=Aria
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci;
DROP DATABASE IF EXISTS FACT_air;
#!/bin/bash
echo "*** Updating system:"
apt update -y && apt upgrade -y
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment