Skip to content

Instantly share code, notes, and snippets.

View cquest's full-sized avatar

Christian Quest cquest

View GitHub Profile
@cquest
cquest / sim2pg.sh
Created April 8, 2024 11:56
Import données SIM2 météo-france dans postgresql
#! /bin/bash
# scrip d'import des données SIM2 (sim2/ISBA) dans postgresql
psql -c "
create table sim2 (LAMBX int,LAMBY int,DATE varchar,PRENEI_Q float,PRELIQ_Q float,T_Q float,FF_Q float,Q_Q float, DLI_Q float, SSI_Q float,HU_Q float,EVAP_Q float,ETP_Q float,PE_Q float,SWI_Q float,DRAINC_Q float,RUNC_Q float,RESR_NEIGE_Q float,RESR_NEIGE6_Q float, HTEURNEIGE_Q float, HTEURNEIGE6_Q float, HTEURNEIGEX_Q float, SNOW_FRAC_Q float, ECOULEMENT_Q float, WG_RACINE_Q float, WGI_RACINE_Q float, TINF_H_Q float, TSUP_H_Q float);"
create table sim2_grid (lambx int, lamby int, lat varchar, lon varchar);
\copy sim2_grid from 'coordonnees_grille_sim2_lambert-2-etendu.csv' with (format csv, header true, delimiter ';');
alter table sim2_grid add geom geometry(point,4326) ;
update sim2_grid set geom = st_makepoint(replace(lon,',','.')::numeric, replace(lat,',','.')::numeric);
@cquest
cquest / jorf2geojson.py
Last active October 22, 2023 14:53
Conversion HTML arrêté "ZIPVA" en geojson
#! /usr/bin/python3
# script de conversion du code HTML de l'arrêté https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000048234967
# au format geojson
# !!! MANQUE MURUROA non délimité dans le tableau d'origine !!!
import re, json
from bs4 import BeautifulSoup
cols = ['','immatriculation','communes','nom','dep','limites','ministere','zone_aero']
@cquest
cquest / vid2pix.sh
Created March 13, 2023 06:58
This script converts dashcam videos into geotagged still images
#! /bin/bash
# This script converts dashcam videos into geotagged still images
# - extraction with ffmpeg of key images
# - extraction of GPS location and time using OCR
# - sub-second metadata generation
# - image cropping and optimization
#
# Tested with ThiEYE carview4 dashcam (front and back)
#! /usr/bin/python3
"""
Script de remise en forme du fichier des copropriétés
Auteur: Christian Quest - 24-08-2022
Licence: WTFPL
"""
import sys, csv, re
@cquest
cquest / attributor.py
Created July 24, 2021 17:23
Script de contrôle des attributions sur les cartes OpenStreetMap
#! /usr/bin/python3
import sys, fileinput, socket, re, csv, time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#from selenium.webdriver.chrome.options import Options
from selenium.webdriver.firefox.options import Options as FirefoxOptions
import psycopg2
@cquest
cquest / laboratory.svg
Created May 4, 2021 07:33
Icône de microscope proposée pour healthcare=laboratory
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cquest
cquest / ircom2csv.sh
Last active April 29, 2021 14:59
Script bash de récupération et conversion des fichiers Excel IRCOM en CSV
#! /bin/bash
ANNEE=$1
mkdir -p $ANNEE
cd $ANNEE
# téléchargement des fichiers Excel
wget -N http://www2.impots.gouv.fr/documentation/statistiques/ircom$ANNEE/dep/{01..95}0.xls
wget -N http://www2.impots.gouv.fr/documentation/statistiques/ircom$ANNEE/dep/2A0.xls
@cquest
cquest / zones_couvre_feu.sh
Last active October 22, 2020 10:08
Script de génération des fichiers géographiques des zones couvertes par le couvre-feu sanitaire
#! /bin/bash
# download limites géographiques des communes
wget -N http://data.cquest.org/ign/adminexpress/ADMIN-EXPRESS_2-4__SHP__FRA_L93_2020-09-15.7z
7z x ADMIN-EXPRESS_2-4__SHP__FRA_L93_2020-09-15.7z
# import dans une base locale postgresql/postgis pour traitements géo
ogr2ogr -f pgdump /vsistdout/ -t_srs EPSG:4326 -nln admin_express_communes -nlt geometry ADMIN-EXPRESS_2-4__SHP__FRA_2020-09-15/ADMIN-EXPRESS/1_DONNEES_LIVRAISON_2020-09-15/ADE_2-4_SHP_LAMB93_FR/COMMUNE.shp | psql
# métropoles et régions concernées
@cquest
cquest / osm_junctions2addok.sh
Created February 8, 2020 10:31
Extraction des intersections de rues pour alimenter le géocodeur addok
wget https://download.geofabrik.de/europe/france/ile-de-france-latest-free.shp.zip -N -nv
unzip ile-de-france-latest-free.shp.zip
ogr2ogr -f pgdump /vsistdout/ gis_osm_roads_free_1.shp -nln osm_roads --config PG_USE_COPY YES -lco GEOMETRY_NAME=geometry | psql
psql -tA -c "
SELECT row_to_json(p) FROM
(
SELECT j.*, c.nom as city, c.insee as citycode
FROM (SELECT 'junction_' || st_geohash(st_centroid(unnest(ST_ClusterWithin(st_intersection(r1.geometry, r2.geometry),0.0001)))) as id,
@cquest
cquest / download
Created December 18, 2019 11:27
login et téléchargement de PDF sur data.inpi.fr
#! /bin/bash
# téléchargement de documents PDF sur data.inpi.fr
if [ $# -ne 1 ];
then
echo "Usage: ./download SIREN"
echo "example: ./download SIREN 429211592"
exit
fi