Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@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;
@ThomasG77
ThomasG77 / .gitignore
Last active October 21, 2024 17:29
"Poor man" head tail in QGIS
outside/
__pycache__
{
"title": "poissons",
"name": "poissons",
"fields": [
{
"name": "operation",
"type": "integer",
"constraints": {
"unique": true
}
@ThomasG77
ThomasG77 / recipe-fantoir-topo-2024.sh
Created September 30, 2024 13:06
Recette génération fantoir
git clone [email protected]:BaseAdresseNationale/fantoir.git
cd fantoir
yarn
# Data generated using https://github.com/landryb/topo2fantoir to convert Topo to fantoir
# Manual download of https://drive.opendata.craig.fr/s/opendata?path=%2Fadresse%2Ffantoir
# then concatenate after decompressing all gz files to fantoir.txt
cat fantoir.txt | yarn build
# Remarque ci-dessous obsolète: il reste des fichiers fantoir pour 2023 mais pas pour 2024 avec disparition fantoir au profit de Topo