Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@ThomasG77
ThomasG77 / README.md
Last active June 23, 2025 08:50
Liste des tribunaux judiciaires via site https://cartejudiciaire.fr/

Données récupérées depuis https://cartejudiciaire.fr/

Sûrement possible de reconstituer les périmètres depuis https://www.data.gouv.fr/fr/datasets/liste-des-juridictions-competentes-pour-les-communes-de-france/ mais cela aurait été laborieux...

wget https://cartejudiciaire.fr/resultats/2025/cartes/tj_population.html
grep 'geo_json_8b7d5198a511cd18e16301b3ef38921c_add({"bbox": ' tj_population.html | sed 's#);##g' | sed 's#            geo_json_8b7d5198a511cd18e16301b3ef38921c_add(##g' | jq '.features | map(del(.properties."Population du ressort (en milliers d‘habitants)", .properties."__folium_color"))' | jq '{"type": "FeatureCollection","features": .}' >| tj-2025.geojson
``
@ThomasG77
ThomasG77 / index.js
Created June 12, 2025 09:28
Issue with geobucket package
import { jenksBuckets } from "geobuckets";
const data = [60, 26, 20, 17, 10, 27, 98, 42, 55, 35];
const numClasses = 3;
const buckets = await jenksBuckets(data, numClasses);
console.log(buckets);
@ThomasG77
ThomasG77 / README.md
Last active June 11, 2025 10:56
Rapide exploitation des données SWI catnat (grilles et données)

Rapide exploitation des données SWI catnat (grilles et données)

Coordonnées des mailles https://donneespubliques.meteofrance.fr/client/document/metadonnees_swi_276.csv (pris depuis la page https://donneespubliques.meteofrance.fr/?fond=produit&id_produit=301&id_rubrique=40 partie Documentation)

curl -s https://donneespubliques.meteofrance.fr/client/document/metadonnees_swi_276.csv | sed 1,4d | sed 's/#//g' >| mailles_safran.csv

ogr2ogr -f "ESRI Shapefile" -dialect SQLite -sql "SELECT num_maille, lambx, lamby, lambx93, lamby93,lat_dg,lon_dg,PolygonFromText('POLYGON((' || (lambx * 100 - 4000) || ' ' || (lamby * 100 - 4000) || ',' || (lambx * 100 - 4000) || ' ' || (lamby * 100 + 4000) || ',' || (lambx * 100 + 4000) || ' ' || (lamby * 100 + 4000) || ',' || (lambx * 100 + 4000) || ' ' || (lamby * 100 - 4000) || ',' || (lambx * 100 - 4000) || ' ' || (lamby * 100 - 4000) || '))', 27572) AS geometry FROM mailles_safran" mailles_safran.shp mailles_safran.csv
zip mailles_safran.zip mailles_safran.shp maille
@ThomasG77
ThomasG77 / get-ocs-data-filtered.py
Created May 22, 2025 13:20
OCSGE téléchargement IGN flux Atom
import xml.etree.ElementTree as ET
import requests
base_url_ocsge = "https://data.geopf.fr/telechargement/resource/OCSGE"
limit = 50
first_page = f'{base_url_ocsge}?page=1&limit={limit}'
r_first_page = requests.get(first_page)
root = ET.fromstring(r_first_page.text)
plugin_file_to_patch = iface.userProfileManager().userProfile().folder() + '/python/plugins/' + 'cadastre' + '/dialogs/search_dialog.py'
# Read in the file
with open(plugin_file_to_patch, 'r') as file:
filedata = file.read()
# Replace the target string
filedata = filedata.replace("['ogc_fid', 'tex', 'idu', 'geo_section', 'geom', 'comptecommunal', 'geo_parcelle']", "['ogc_fid', 'tex', 'idu', 'geo_section', 'geom', 'geo_parcelle']")
# Write the file out again
@ThomasG77
ThomasG77 / README.md
Created February 11, 2025 16:31
API jours fériés: passage sous forme de tableau

API jours fériés: passage sous forme de tableau

curl -s https://calendrier.api.gouv.fr/jours-feries/metropole.json | jq '[. | to_entries|sort_by(.key)| .[] | {"date":.key, "event": .value}]'
fetch('https://calendrier.api.gouv.fr/jours-feries/metropole.json').then(res => res.json()).then(json => {
    console.log(Object.entries(abc).map(([k,v]) => ({"date":k, "event": v})).toSorted((a, b) => a.date - b.date))
})
@ThomasG77
ThomasG77 / pnr.geojson
Created February 6, 2025 15:03
PNR demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ThomasG77
ThomasG77 / guf_pnr2013.geojson
Created February 6, 2025 12:46
PNR as GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.15.0/proj4.min.js" integrity="sha512-4cx6CH/aJi50kdbQ5dj6bDJM1WS0AOFBGgBfgSP2Ux2eK/5JhkL2pjUDIHwd8z6rfGuGr/aptDqs0EzbeRndvQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
proj4.defs("EPSG:2154","+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs");
function geometryPoint(entry, transformer) {
return transformer(entry)
}
@ThomasG77
ThomasG77 / leaflet-wmts-grayscale.html
Last active November 8, 2024 19:02
Leaflet styling source to black&white/grayscale on client side
<<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
#viewerDiv {
width:100%;
height:600px;