Skip to content

Instantly share code, notes, and snippets.

@jbdesbas
jbdesbas / onf_parcelle_pub.vrt.xml
Last active May 16, 2022 13:19
onf_parcelle_pub.vrt.xml
<!-- Parcelles forestières de l'Office National des Forêts en Hauts-de-France (buffer km) -->
<OGRVRTDataSource>
<OGRVRTLayer name="parcelle_forestiere">
<SrcDataSource>WFS:http://ws.carmencarto.fr/WFS/105/ONF_Forets?</SrcDataSource>
<SrcLayer>PARC_PUBL_FR</SrcLayer>
<OpenOptions>
<OOI key="EXPOSE_GML_ID">NO</OOI>
</OpenOptions>
<SrcRegion clip="FALSE">POLYGON ((579103 6997695, 580761 7001558, 584837 7004703, 587571 7012556, 591593 7017267, 590762 7022295, 594586 7051079, 593335 7071052, 596473 7076232, 594661 7085073, 595662 7089514, 601773 7092190, 608651 7098986, 618354 7103072, 635982 7106966, 640941 7110703, 645076 7109880, 653102 7112036, 656746 7111226, 669828 7115154, 672622 7112574, 675038 7103420, 678738 7096492, 677637 7085125, 684331 7082539, 689115 7074279, 691164 7074164, 694702 7077503, 706352 7082297, 713130 7081417, 723351 7068188, 722741 7061611, 725127 7050924, 727759 7049711, 732990 7053527, 738247 7052558, 741178 7049682, 746729
@jbdesbas
jbdesbas / zonage-inpn.vrt.xml
Last active May 6, 2022 18:00
OGRVRT Zonage INPN
<OGRVRTDataSource>
<OGRVRTUnionLayer name="zonage">
<SourceLayerFieldName>TYPE</SourceLayerFieldName>
<OGRVRTLayer name="znieff1">
<SrcDataSource>WFS:https://ws.carmencarto.fr/WFS/119/fxx_inpn</SrcDataSource>
<OpenOptions>
<OOI key="EXPOSE_GML_ID">NO</OOI>
</OpenOptions>
<SrcLayer>Znieff1</SrcLayer>
@jbdesbas
jbdesbas / micropython_teleinfo_esp822.md
Created April 23, 2022 09:36
micropython_teleinfo_esp822
@jbdesbas
jbdesbas / geoserver2pg.sql
Last active March 24, 2022 14:48
Insert geonetwork mtd into PG
CREATE TABLE xml_mtd ("xml" xml);
/*COPY distant XML file (with removing line feed) */
COPY xml_mtd FROM PROGRAM 'curl "https://www.geo2france.fr/geonetwork/srv/api/records/6ea5c1bd-b10b-4f7e-9139-2f878c63fc74/formatters/xml?attachment=true&approved=true" | tr -d "\n" ';
/*Extract relevant data*/
WITH ns AS (
SELECT ARRAY[
ARRAY['gmd', 'http://www.isotc211.org/2005/gmd'],
ARRAY['gco', 'http://www.isotc211.org/2005/gco'],
@jbdesbas
jbdesbas / upload_media_to_s3.py
Created November 5, 2020 08:49
Taxhub : upload media to S3 cloud
"""A lancer à la racine du dossier Taxhub, après avoir renseigner les accès du S3
dans le fichier de config et activé l'environnement virtuel"""
import config
import os
import boto3
import mimetypes
s3 = boto3.client('s3',
aws_access_key_id=config.S3_KEY,
@jbdesbas
jbdesbas / exemple_taxref_tree_parents.sql
Last active October 29, 2020 11:05
Exemple taxref_tree_parents
--Selection des occurences d'Odonates [185356] et taxons inférieurs
--A utiliser également pour sélectionner des espèces, afin d'inclure les éventuelles sous-espèces
SELECT s.*
FROM gn_synthese.synthese s
JOIN taxonomie.taxref t USING (cd_nom)
JOIN taxonomie.taxref_tree_parents ttp ON ttp.cd_nom_parent = t.cd_ref
WHERE ttp.cd_nom_parent = 185356
--Exemple 2 : Liste des parents sous format JSON
@jbdesbas
jbdesbas / observation.json
Created October 9, 2020 11:26
gn monitoring config observation
{
"specific": {
"cd_nom": {
"type_widget": "taxonomy",
"attribut_label": "Taxon",
"type_util": "taxonomy",
"required": true,
"idComponent": "100"
},
"id_nomenclature_nature_observation": {
from utils_flask_sqla import response
from datetime import date, time, datetime
import uuid
test_dict=dict(
my_datetime=datetime.now(),
my_uuid=uuid.uuid4(),
my_time=time(12,54),
@jbdesbas
jbdesbas / geonature_status.sql
Last active December 27, 2019 08:32
projet pour gérer les statuts de taxon dans taxhub/geonature. Permet de gérer les statuts localiser (LR régionnal, sous-population, arrêtés municipaux, etc..)
/*
--Fonction pas encore dans taxhub
CREATE OR REPLACE FUNCTION taxonomie.find_all_taxons_parents(id integer)
RETURNS TABLE(cd_nom integer, id_rang character varying)
LANGUAGE plpgsql
IMMUTABLE
AS $function$
--Param : cd_nom d'un taxon quelque soit son rang
--Retourne une table avec le cd_nom de tout les taxons parents et leur id_rang.
--Retourne le cd_nom de tous les taxons parents sous forme d'un jeu de données utilisable comme une table. Les cd_nom sont ordonnées du plus bas vers le plus haut (Dumm)
@jbdesbas
jbdesbas / matomo.js
Created November 15, 2019 14:40
Geonature citizen, tracking matomo (piwiki)
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//MY_MATOMO_URL/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 'MY_MATOMO_ID_SITE']);