Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Gratier ThomasG77

View GitHub Profile
View qtnetwork.py
#!/usr/bin/python
'''
QNetworkAccessManager in PyQt
In this example we get a web page.
Author: Jan Bodnar
Website: zetcode.com
'''
View README.md
View check-ign-data-availability.py
import re
import urllib.request
from bs4 import BeautifulSoup
url = 'https://geoservices.ign.fr/documentation/diffusion/telechargement-donnees-libres.html'
urls = []
with urllib.request.urlopen(url) as f:
View report-http-broken.txt
├─BROKEN─ https://wxs.ign.fr/q2vmpil73wqufui9guglnusl/telechargement/prepackage/SCAN500-E080_PACK_GUF_2014-02-01%24SCAN500_1-0__JP2-E080_UTM22RGFG95_D973_2014-02-01/file/SCAN500_1-0__JP2-E080_UTM22RGFG95_D973_2014-02-01.7z (HTTP_404)
├─BROKEN─ https://orthohr:orthohr@wxs.ign.fr/o5eat18emvtnmvp2vtyfihlg/telechargement/prepackage/ORTHOHR-JP2_PACK_D016_2017-01-01%24ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01/file/ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01.7z.001 (HTTP_401)
├─BROKEN─ https://orthohr:orthohr@wxs.ign.fr/o5eat18emvtnmvp2vtyfihlg/telechargement/prepackage/ORTHOHR-JP2_PACK_D016_2017-01-01%24ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01/file/ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01.7z.002 (HTTP_401)
├─BROKEN─ https://orthohr:orthohr@wxs.ign.fr/o5eat18emvtnmvp2vtyfihlg/telechargement/prepackage/ORTHOHR-JP2_PACK_D016_2017-01-01%24ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01/file/ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01.7z.003 (HTTP_401)
├─BROKEN─
View generate-image-to-drawing.py
# Code borrowed from https://py.plainenglish.io/convert-a-photo-to-pencil-sketch-using-python-in-12-lines-of-code-4346426256d4
# This code depends from OpenCV Python library you can install with
# pip install opencv-python
# You run it with the following. It relies on Python 3
# python3 generate-image-to-drawing.py /tmp/puppy.png
# or how you installed or your OS
# python generate-image-to-drawing.py /tmp/puppy.png
# It will generate an image at /tmp/puppy_sketch.png
import argparse
@ThomasG77
ThomasG77 / pdftk-split-every-n-page.sh
Created Feb 18, 2021
Need to split PDF every n pages, do it with pdftk
View pdftk-split-every-n-page.sh
# 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
View download-gpkg-topage-2019.txt
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/CoursEau/CoursEau_FXX-gpkg.zip
https://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/TronconHydrographique/TronconHydrographique_FXX-gpkg.zip
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/PlanEau/PlanEau_FXX-gpkg.zip
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/SurfaceElementaire/SurfaceElementaire_FXX-gpkg.zip
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/BassinHydrographique/BassinHydrographique_FXX-gpkg.zip
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/BassinVersantTopographique/BassinVersantTopographique_FXX-gpkg.zip
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/LimiteTerreMer/LimiteTerreMer_FXX-gpkg.zip
http://services.sandre.eaufrance.fr/telechargement/geo/ETH/BDTopage/2019/NoeudHydrographique/NoeudHydrographique_FXX-gpkg.zip
View demo-gdal-merge-single.sh
# 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