Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@ThomasG77
ThomasG77 / pdftk-split-every-n-page.sh
Created February 18, 2021 16:34
Need to split PDF every n pages, do it with pdftk
# Recipe from https://unix.stackexchange.com/questions/66931/split-pdf-into-documents-with-several-pages-each
pagesper=2
file=layout_atlas_multipage.pdf
number=$(pdfinfo -- "$file" 2> /dev/null | awk '$1 == "Pages:" {print $2}')
count=$((number / pagesper))
filename=${file%.pdf}
counter=0
while [ "$count" -gt "$counter" ]; do
@ThomasG77
ThomasG77 / csw-consume-observatoire-territoires.py
Created May 3, 2024 12:43
Consommation CSW Observatoire des territoires
from owslib.csw import CatalogueServiceWeb
url_csw = 'https://www.observatoire-des-territoires.gouv.fr/outils/cartographie-interactive/services/csw/'
csw = CatalogueServiceWeb(url_csw)
infos = []
csw.getrecords2(startposition=0, maxrecords=20)
for rec in csw.records:
result = [csw.records[rec].title, csw.records[rec].identifier]
@ThomasG77
ThomasG77 / README.md
Last active April 30, 2024 15:17
Recipe to get JSON using pagination using command line tools e.g curl, jq, bc, cat
@ThomasG77
ThomasG77 / index.html
Last active April 24, 2024 13:25
Demo to use Overpass JSON API with OpenLayers 3 & 4
<!DOCTYPE>
<html>
<head>
<title>Overpass JSON</title>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
@ThomasG77
ThomasG77 / README.md
Last active April 20, 2024 16:12
Pompage dump données Geoportail de l'urbanisme

Copie données WFS depuis le géoportail de l'urbanisme

Ici on prend les données GPKG mais shp et CSV aussi disponibles selon vos préférences

# Infos pompées de https://www.geoportail-urbanisme.gouv.fr/image/Manuel_export_massif.pdf
# Obtenu via discussion https://georezo.net/forum/viewtopic.php?pid=367182#p367182
# Do once (to get ssh key)
timeout 5 ssh -oStrictHostKeyChecking=accept-new -p 2200 gpu_depot_exports@sftp-public.ign.fr
# List files
<!DOCTYPE html>
<html>
<head>
<!--
Copyright (c) 2015-2020 Jean-Marc VIGLINO,
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
-->
<title>ol-ext: WMS Capabilities control</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ThomasG77
ThomasG77 / README.md
Created April 14, 2024 21:47
Compile Node - quick recipe

Compile Node

sudo mkdir -p /opt/node/bin
chmod -R 777 /opt/node/
cd ~
git clone --depth 1 --branch v20.9.0 https://github.com/nodejs/node
cd node
sudo apt-get install build-essential python3-distutils git
sudo apt install clang-10
@ThomasG77
ThomasG77 / README.md
Last active April 9, 2024 17:36
Fichiers IGN à disposition via la Géoplateforme
@ThomasG77
ThomasG77 / README.md
Last active April 8, 2024 20:17
Run PyQGIS in Jupyter Notebook
@ThomasG77
ThomasG77 / README.md
Created April 8, 2024 11:17
Generate daily stations from meteo france data

Récupération des stations quotidiennes depuis les données Météo France

import json
import urllib.request
from glob import glob
import pandas as pd
import geopandas