﻿{"id":8944,"date":"2019-07-01T11:47:59","date_gmt":"2019-07-01T09:47:59","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=8944"},"modified":"2019-07-01T11:48:00","modified_gmt":"2019-07-01T09:48:00","slug":"une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/","title":{"rendered":"Une fonction PL\/pgsql pour l&rsquo;analyse exploratoire de donn\u00e9es spatiales avec des polygones de Vorono\u00ef"},"content":{"rendered":"\n<p>L&rsquo;analyse exploratoire des donn\u00e9es spatiales est une \u00e9tape incontournable dans les processus d&rsquo;analyse spatiale.<\/p>\n\n\n\n<p>Un des outils pour cette exploration est la construction des polygones de Vorono\u00ef. (<a href=\"https:\/\/www.sigterritoires.fr\/index.php\/analyse-exploratoire-des-donnees-pour-la-geostatistiqueles-diagrammes-de-voronoi\/\">Voir Analyse exploratoire des donn\u00e9es pour la g\u00e9ostatistique:les diagrammes de Vorono<\/a>\u00ef)<\/p>\n\n\n\n<p>Si l&rsquo;extension Geostatistical Analyst d&rsquo;ArcGis permet une grande vari\u00e9t\u00e9 d&rsquo;affichages d&rsquo;une couche de polygones de Vorono\u00ef, avec QGis on est limit\u00e9s au simple affichage des polygones et des valeurs de l&rsquo;attribut analys\u00e9. Ce qui manque c&rsquo;est les diff\u00e9rents affichages correspondant \u00e0 des statistiques locales.<\/p>\n\n\n\n<p>Dans un pr\u00e9c\u00e9dent article (<a href=\"https:\/\/www.sigterritoires.fr\/index.php\/calculer-des-moyennes-locales-sur-des-polygones-de-voronoi-avec-qgis\/\">Calculer des moyennes locales sur des polygones de Vorono\u00ef avec Qgis<\/a>), qui commence \u00e0 dater, nous avions donn\u00e9 les moyens d&rsquo;afficher la vue \u00ab\u00a0Moyenne\u00a0\u00bb des polygones: Pour chaque polygone on recherche les polygones qui ont un c\u00f4t\u00e9 ou un vertex commun avec lui, puis on calcule la moyenne d\u2019un attribut pour cet ensemble (la moyenne du polygone central plus les valeurs des polygones adjacents). C&rsquo;est cette moyenne qui est affect\u00e9e au polygone au lieu de la valeur originale de l&rsquo;attribut..<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>C&rsquo;est vrai que dans les traitements disponibles dans QGis, ou bien utilisant des scripts R, on peut calculer ces statistiques. mais le processus et long et fastidieux.<\/p>\n\n\n\n<p>Pour les utilisateurs de Postgresql\/Postgis, il faut noter que <a href=\"https:\/\/www.sigterritoires.fr\/index.php\/debuter-avec-postgrespostgis\/\">Postgis<\/a> ne poss\u00e8de pas du tout ce type de fonctions.<\/p>\n\n\n\n<p>La solution pr\u00e9sent\u00e9e ici implique la disponibilit\u00e9 d&rsquo;une base Postgresql\/postgis et de QGis:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>On utilise QGis pour calculer les polygones de Vorono\u00ef en cr\u00e9ant une table Postgresql en sortie.<\/li><li>On ex\u00e9cute la fonction dans la base de donn\u00e9es pour cr\u00e9er les champs statistiques dans la couche de Vorono\u00cf<\/li><li>On utilise QGis pour visualiser les diff\u00e9rents champs statistiques<\/li><\/ul>\n\n\n\n<p style=\"font-size:0\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Les statistiques locales des polygones de Vorono\u00ef<\/h2>\n\n\n\n<p>Dans l&rsquo;analyse exploratoire il y a trois types de statistiques utilis\u00e9es avec les polygones de Vorono\u00ef:<\/p>\n\n\n\n<p>\n&#8211;<strong>Des fonctions de lissage <\/strong>qui amenuisent les fortes \nvariations entre polygones voisins, de mani\u00e8re \u00e0 mieux voir les \nph\u00e9nom\u00e8nes globaux sur la zone d&rsquo;\u00e9tude.\n\n<\/p>\n\n\n\n<p> En calculant <strong>la moyenne <\/strong>de chaque polygone avec ses voisins, la variation entre  voisins devient  moins brutale. On obtient alors une carte plus liss\u00e9e des donn\u00e9es.  Ceci est utile quand il y a une trop forte variation entre les points  voisins ce qui a pour r\u00e9sultat sur la carte globale de masquer ou de  rendre plus difficile de voir les ph\u00e9nom\u00e8nes globaux. <\/p>\n\n\n\n<p><strong>-Des fonctions pour mettre en \u00e9vidence la variabilit\u00e9 locale<\/strong>.  Si les outils de lissage (moyenne, mode, m\u00e9diane) sont des outils qui s\u2019int\u00e9ressent \u00e0 ce que l\u2019on peut appeler la <strong>tendance centrale<\/strong> d\u2019une distribution, les outils comme l&rsquo;<strong>entropie<\/strong>, les \u00e9carts-type et les \u00e9carts inter-quantile  s\u2019int\u00e9ressent \u00e0 la <strong>dispersion<\/strong> des distributions. <\/p>\n\n\n\n<p> L\u2019interpr\u00e9tation de ces types de carte d\u00e9pendent de la connaissance  des donn\u00e9es, car la variabilit\u00e9 sera toujours exprim\u00e9e en cinq classes,  avec des bornes diff\u00e9rentes selon les donn\u00e9es. Par contre, la carte  d\u2019entropie ne se pr\u00e9sente pas de la m\u00eame mani\u00e8re. Elle a toujours 5  classes mais les bornes des classes ne d\u00e9pendent pas des donn\u00e9es  trait\u00e9es. Elles sont fixes, la valeur d&rsquo;entropie prenant une valeur comprise entre 0 et 2.3219 .<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Des fonctions de recherche de valeurs anormales<\/strong>, telle que le <strong>cluster<\/strong>.  Il est important d\u2019identifier les valeurs aberrantes pour deux raisons:  elles peuvent \u00eatre des anomalies r\u00e9elles du ph\u00e9nom\u00e8ne, ou la valeur peut  avoir \u00e9t\u00e9 mesur\u00e9e ou enregistr\u00e9e incorrectement. <\/li><\/ul>\n\n\n\n<p> Les valeurs d\u2019entropie fournissent une mesure de dissimilarit\u00e9 entre  polygones voisins. Dans la nature, vous vous attendez \u00e0 ce que les  choses plus rapproch\u00e9es soient plus\u00a0 semblables que des choses plus  \u00e9loign\u00e9es. Par cons\u00e9quent, les valeurs aberrantes locales peuvent \u00eatre  identifi\u00e9es par des zones d\u2019entropie \u00e9lev\u00e9e. <\/p>\n\n\n\n<p> La m\u00e9thode cluster identifie les polygones qui sont dissemblables \u00e0  leurs voisins environnants. Vous vous attendez \u00e0 ce que la valeur  enregistr\u00e9e dans un polygone particulier soit similaire \u00e0 au moins un de  ses voisins. Par cons\u00e9quent, cet outil peut \u00eatre utilis\u00e9 pour  identifier d\u2019\u00e9ventuels valeurs aberrantes locales.  Le cluster prend l\u2019ensemble des points et classe toutes les valeurs en cinq  classes. Pour chaque polygone on affiche sa classe, si et seulement si,  au moins un polygone voisin est de m\u00eame classe. Si tous les polygones  voisins sont de classe diff\u00e9rente, on affiche le polygone en gris. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cr\u00e9ation des polygones de Vorono\u00ef avec QGis 3.8<\/h2>\n\n\n\n<p>Dans les traitements de QGis 3.8 vous avez plusieurs algorithmes permettant de cr\u00e9er les polygones de Vorono\u00ef \u00e0 partir d&rsquo;une couche de points. Pour nos besoins, nous allons utiliser le traitement <strong>Polygones de Vorono\u00ef<\/strong> de la <strong>G\u00e9om\u00e9trie Vectoriell<\/strong>e de <strong>QGis<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"366\" height=\"300\" data-attachment-id=\"8955\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im1-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im1.png?fit=366%2C300&amp;ssl=1\" data-orig-size=\"366,300\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im1.png?fit=366%2C300&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im1.png?resize=366%2C300&#038;ssl=1\" alt=\"\" class=\"wp-image-8955\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im1.png?w=366&amp;ssl=1 366w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im1.png?resize=300%2C246&amp;ssl=1 300w\" sizes=\"auto, (max-width: 366px) 100vw, 366px\" \/><\/a><\/figure>\n\n\n\n<p>Cet outil permet d&rsquo;enregistrer la couche en sortie directement dans une base Postgresql\/Postgis.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"354\" data-attachment-id=\"8956\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im2-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?fit=1001%2C554&amp;ssl=1\" data-orig-size=\"1001,554\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?fit=640%2C354&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?resize=640%2C354&#038;ssl=1\" alt=\"\" class=\"wp-image-8956\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?w=1001&amp;ssl=1 1001w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?resize=300%2C166&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im2.png?resize=768%2C425&amp;ssl=1 768w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n\n\n\n<p>Le r\u00e9sultat du traitement s&rsquo;affiche dans QGis:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?ssl=1\"><img loading=\"lazy\" decoding=\"async\" width=\"2083\" height=\"1209\" data-attachment-id=\"8957\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im3-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?fit=2083%2C1209&amp;ssl=1\" data-orig-size=\"2083,1209\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?fit=640%2C371&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?fit=525%2C305&amp;ssl=1\" alt=\"\" class=\"wp-image-8957\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?w=2083&amp;ssl=1 2083w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?resize=300%2C174&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?resize=768%2C446&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?resize=1024%2C594&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?w=1280&amp;ssl=1 1280w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im3.jpg?w=1920&amp;ssl=1 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n\n\n\n<p>Avec PgAdmin vous pourrez voir la d\u00e9finition de la table cr\u00e9\u00e9e:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?ssl=1\"><img loading=\"lazy\" decoding=\"async\" width=\"1123\" height=\"901\" data-attachment-id=\"8958\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im4-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?fit=1123%2C901&amp;ssl=1\" data-orig-size=\"1123,901\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?fit=640%2C514&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?fit=525%2C421&amp;ssl=1\" alt=\"\" class=\"wp-image-8958\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?w=1123&amp;ssl=1 1123w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?resize=300%2C241&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?resize=768%2C616&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im4.png?resize=1024%2C822&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n\n\n\n<p>Vous aurez besoin des noms de champs correspondant :<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u00e0 l&rsquo;identifiant<\/li><li>\u00e0 la g\u00e9om\u00e9trie<\/li><li>au param\u00e8tre num\u00e9rique que vous voulez analyser<\/li><\/ul>\n\n\n\n<p>Attention aux noms des colonnes import\u00e9es \u00e0 partir de la table attributaire de la couche d&rsquo;origine. Remarquez que les noms sont compris entre guillemets. Ces guillemets font partie du nom. Vous devrez donc les ajouter dans l&rsquo;appel de la fonction:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im5.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"123\" data-attachment-id=\"8959\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im5-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im5.png?fit=607%2C123&amp;ssl=1\" data-orig-size=\"607,123\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im5.png?fit=607%2C123&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im5.png?resize=607%2C123&#038;ssl=1\" alt=\"\" class=\"wp-image-8959\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im5.png?w=607&amp;ssl=1 607w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im5.png?resize=300%2C61&amp;ssl=1 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/a><\/figure>\n\n\n\n<p>Dans cet exemple, si vous rentrez comme nom de l&rsquo;attribut &lsquo;DEBIT_MOY&rsquo; vous aurez une erreur disant que la relations DEBIT_MOY n&rsquo;existe pas.<\/p>\n\n\n\n<p>Il faut rentrer &lsquo; \u00a0\u00bb DEBIT_MOY \u00a0\u00bb &lsquo; pour que \u00e7a fonctionne.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">La fonction PL\/pgsql<\/h2>\n\n\n\n<p>La fonction ci-dessous prend une couche de polygones de Vorono\u00ef et calcule trois statistiques locales.<\/p>\n\n\n\n<p>Les quatre param\u00e8tres dans l&rsquo;appel de la fonction sont:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>le nom de la table contenant les polygones de Vorono\u00ef<\/li><li>le nom du champ identifiant de cette table<\/li><li>le nom de l&rsquo;attribut num\u00e9rique \u00e0 analyser<\/li><li>le nom du champ g\u00e9o\u00e9mtrie de cette table<\/li><\/ul>\n\n\n\n<p>\u00a0En retour, la fonction cr\u00e9e trois attributs:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>moyenne<\/strong>, qui contient la valeur de la moyenne locale (somme des valeurs des voisins et du polygone central, divis\u00e9e par le nombre de voisins +1)<\/li><li><strong>entrop<\/strong>, qui contient la valeur de l&rsquo;entropie calcul\u00e9e avec la formule (<a href=\"https:\/\/www.sigterritoires.fr\/index.php\/analyse-exploratoire-des-donnees-pour-la-geostatistiqueles-diagrammes-de-voronoi\/\">voir l&rsquo;article avec la description<\/a>)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i1.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2017\/01\/s3.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>cluster<\/strong>, qui contient la valeur 99 si aucun des voisins appartient \u00e0 la m\u00eame classe que le polygone central ou la valeur de classe du polygone central si cette valeur est pr\u00e9sente dans au moins un polygone voisin.<\/li><\/ul>\n\n\n\n<div class='stb-container stb-style-grey stb-caption-box stb-collapsed'><div class='stb-caption'><div class='stb-logo'><img class='stb-logo__image' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN\/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz\/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH\/w\/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA\/g88wAAKCRFRHgg\/P9eM4Ors7ONo62Dl8t6r8G\/yJiYuP+5c+rcEAAAOF0ftH+LC+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OrfKy4tvWPL1h3ZN06bQXNzI8FgiJk3zGLM2JGo1RqcTqfcvJCoqzuHz+ePzPrqjFt1Ou2OT5sjaVnqokCvHGohoEf2Qj7gAqwylEPOI1EUxSQgVr+7OQmoas+cEVKplABIe\/fukcLhMIDC4XCMvvOuJYq5X5vDiZOH8AdCGIxmotEQsWgIf1CBLTObFCkaG+s4deoUI0aMqNPptBc\/6xElLVs8LANcAE4Ce4Ed8vV94JIMefkU4JD3FQExlUqJslHS4XA4LRtvUCgUGltUmG91u1tpbr7E6Iqx5Lhy6PZ4qGtoI9M1kD5fmAMHDrF7zy5UKjXFJUUHN2x4p\/Gz5MjHYZXyD9AAesAsF8xsefaXPXTZO0a5+6GVp0reQ7isiEajUX377bdb9AaDsrioFHOGkcOHDmPQm5l38zzCsQDZmS6OHz+Gw5GJ290ZjEZD3\/nFo794SxTFz\/Wom5ZvnpItG5e95JHDTC9DWWQhyLgCVCuvq+SckmQ1TITD4axXXnllwn333ZdfPrKMynXr6OkL8M0pM9i4uZJeTy\/\/etcyTtW8z6KFd7KhqvL0unXrW+S9kp+3HSRdMa8Eisoe65Etrr5iauT3tJefRuXvxuVrARDzeDymdWvXOg1anbDg27fR7e6gpqaG225bxNGjx5g0cSrPrF4V3bRpY6fsUeHzhtYnVX6u2Fj42NrfM8TlG2YAo4GvARNXrVo1PJVMalrb2jSTJk0Rurs7EUWJ7du2uHfu2nkI2AjsAtzSVX705wX5JLArX0tXgfl47hlkOS\/Nzc0d0eV2Z40dNz6voCA\/c\/v27b12uz3a2Nh4GtgHnAO8H7XQJL4okGsZSvkclyELhEnOsdgV8t9zZRH8vwpytZIgXCUU+cwgX\/7z4UuQL0H++UD+awDc\/MMFLMO8WgAAAABJRU5ErkJggg==' alt='img'\/><\/div><div class='stb-caption-content'>Code de la fonction<\/div><div class='stb-tool'><\/div><\/div><div class='stb-content'>&#8211;Cette fonction s&rsquo;applique \u00e0 une table contenant d\u00e9j\u00e0 des polygones de voronoi et au moins un attribut num\u00e9rique &#8211;dont on souhaite analyser sa distribution spatiale &#8211;Le r\u00e9sultat sont trois colonnes permettant de repr\u00e9senter &#8212; voronoi moyenne -&gt; colonne \u00ab\u00a0moyenne\u00a0\u00bb &#8212; voronoi cluster -&gt; colonne \u00ab\u00a0cluster\u00a0\u00bb &#8212; voronoi entropie -&gt; colonne \u00ab\u00a0entrop\u00a0\u00bb &#8211;tablex est le nom de la table en entr\u00e9e &#8211;gid est le nom de la colonne identifiant de la table &#8211;attr est le nom de la colonne (obligatoirement num\u00e9rique) \u00e0 traiter &#8211;&lsquo;||geom||&rsquo; est le nom du cham g\u00e9om\u00e9trie de la table &#8211;* CREATE OR REPLACE FUNCTION public.af_voronoi(tablex character varying, gid character varying,attr character varying,geom character varying) &#8211;* RETURNS text LANGUAGE &lsquo;plpgsql&rsquo; &#8212; AS $BODY$ &#8212; DECLARE rec record; rec2 record; nb integer; L1 numeric; L2 numeric; L3 numeric; L4 numeric; L5 numeric; LL integer; Pi1 integer :=0; Pi2 integer:=0; Pi3 integer:=0; Pi4 integer:=0; Pi5 integer:=0; BEGIN &#8211;Cr\u00e9ation des colonnes de r\u00e9sultat et temporaires EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS smartcl&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column smartcl integer&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS entrop&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column entrop float&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS Nv&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column Nv integer&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P1&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column P1 integer&rsquo; ; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P2&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column P2 integer&rsquo; ; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P3&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column P3 integer &lsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P4&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column P4 integer&rsquo; ; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P5&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column P5 integer&rsquo; ; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS moyenne&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column moyenne float &lsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS cluster&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; add column cluster integer&rsquo; ; EXECUTE &lsquo;select count(*) as nb from &lsquo;||tablex||\u00a0\u00bb INTO rec; &#8212; &#8211;calcul du voronoi \u00ab\u00a0moyenne\u00a0\u00bb EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set moyenne= (SELECT (sum(a.&rsquo;||attr||&rsquo;)::real+b.&rsquo;||attr||&rsquo;::real)\/(count(a.&rsquo;||attr||&rsquo;)::real+1) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; group by b.&rsquo;||gid||&rsquo;)&rsquo;; &#8212; &#8211;classement de l&rsquo;attribut en cinq classes de m\u00eame nombre d&rsquo;\u00e9chantillons &#8212; calcul des limites des classes EXECUTE &lsquo;select max(&lsquo;||attr||&rsquo;) as L1 from (select &lsquo;||attr||&rsquo; from &lsquo;||tablex||&rsquo; order by &lsquo;||attr||&rsquo; asc limit ((2597\/5)*1)::int)as a&rsquo; INTO rec; L1:=rec.L1; &#8212; EXECUTE &lsquo;select max(&lsquo;||attr||&rsquo;) as L2 from (select &lsquo;||attr||&rsquo; from &lsquo;||tablex||&rsquo; order by &lsquo;||attr||&rsquo; asc limit ((2597\/5)*2)::int)as a&rsquo; INTO rec; L2:=rec.L2; &#8212; EXECUTE &lsquo;select max(&lsquo;||attr||&rsquo;)as L3 from (select &lsquo;||attr||&rsquo; from &lsquo;||tablex||&rsquo; order by &lsquo;||attr||&rsquo; asc limit ((2597\/5)*3)::int)as a&rsquo; INTO rec; L3:=rec.L3; &#8212; EXECUTE &lsquo;select max(&lsquo;||attr||&rsquo;)as L4 from (select &lsquo;||attr||&rsquo; from &lsquo;||tablex||&rsquo; order by &lsquo;||attr||&rsquo; asc limit ((2597\/5)*4)::int)as a&rsquo; INTO rec; L4:=rec.L4; &#8212; EXECUTE &lsquo;select max(&lsquo;||attr||&rsquo;)as L5 from (select &lsquo;||attr||&rsquo; from &lsquo;||tablex||&rsquo; order by &lsquo;||attr||&rsquo; asc limit ((2597\/5)*5)::int)as a&rsquo; INTO rec; L5:=rec.L5; &#8212; &#8211;affectation d&rsquo;une classe \u00e0 chaque enregistrement de la table FOR rec IN EXECUTE &lsquo;select &lsquo;||gid||&rsquo; as gid,&rsquo;||attr||&rsquo; as attr from &lsquo;||tablex||\u00a0\u00bb LOOP &#8212; CASE WHEN rec.attr &lt;=L1 THEN EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set smartcl=1 where &lsquo;||gid||&rsquo;=&rsquo;||rec.gid; WHEN rec.attr &lt;=L2 and rec.attr &gt; L1 THEN EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set smartcl=2 where &lsquo;||gid||&rsquo;=&rsquo;||rec.gid; WHEN rec.attr &lt;=L3 and rec.attr &gt; L2 THEN EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set smartcl=3 where &lsquo;||gid||&rsquo;=&rsquo;||rec.gid; WHEN rec.attr &lt;=L4 and rec.attr &gt; L3 THEN EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set smartcl=4 where &lsquo;||gid||&rsquo;=&rsquo;||rec.gid; ELSE EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set smartcl=5 where &lsquo;||gid||&rsquo;=&rsquo;||rec.gid; END CASE ; END LOOP; &#8211;* &#8211;calcul du voronoi \u00ab\u00a0entropie\u00a0\u00bb &#8211;* EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set Nv= (SELECT (count(a.smartcl)) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; group by b.&rsquo;||gid||&rsquo;)&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set P1= (SELECT (count(a.smartcl)) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; and a.smartcl=1 group by b.&rsquo;||gid||&rsquo;)&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set P2= (SELECT (count(a.smartcl)) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; and a.smartcl=2 group by b.&rsquo;||gid||&rsquo;)&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set P3= (SELECT (count(a.smartcl)) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; and a.smartcl=3 group by b.&rsquo;||gid||&rsquo;)&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set P4= (SELECT (count(a.smartcl)) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; and a.smartcl=4 group by b.&rsquo;||gid||&rsquo;)&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; vor set P5= (SELECT (count(a.smartcl)) FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; and a.smartcl=5 group by b.&rsquo;||gid||&rsquo;)&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop=0&prime;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop= entrop +((P1::real\/Nv::real)*(ln(P1::real\/Nv::real))) where P1 IS NOT NULL&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop= entrop+((P2::real\/Nv::real)*(ln(P2::real\/Nv::real))) where P2 IS NOT NULL&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop= entrop+((P3::real\/Nv::real)*(ln(P3::real\/Nv::real))) where P3 IS NOT NULL&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop= entrop+((P4::real\/Nv::real)*(ln(P4::real\/Nv::real))) where P4 IS NOT NULL&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop= entrop+((P5::real\/Nv::real)*(ln(P5::real\/Nv::real))) where P5 IS NOT NULL&rsquo;; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set entrop=entrop*(-1) where entrop &lt;&gt;0&prime;; &#8212; &#8211;calcul du voronoi \u00ab\u00a0cluster\u00a0\u00bb EXECUTE&rsquo;update &lsquo;||tablex||&rsquo; vor set cluster= (SELECT a.smartcl FROM &lsquo;||tablex||&rsquo; as a JOIN &lsquo;||tablex||&rsquo; as b ON st_touches(a.&rsquo;||geom||&rsquo;,b.&rsquo;||geom||&rsquo;) where b.&rsquo;||gid||&rsquo; =vor.&rsquo;||gid||&rsquo; and a.smartcl=b.smartcl group by b.&rsquo;||gid||&rsquo;,a.smartcl )&rsquo;; &#8212; EXECUTE &lsquo;update &lsquo;||tablex||&rsquo; set cluster=99 where cluster IS NULL&rsquo;; &#8212; &#8211;effacement des colonnes temporaires EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS Nv&rsquo;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P1&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P2&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P3&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P4&prime;; EXECUTE &lsquo;alter table &lsquo;||tablex||&rsquo; DROP COLUMN IF EXISTS P5&prime;; RETURN &lsquo;OK&rsquo;; END; $BODY$;<\/div><\/div>\n\n\n\n<p><p>Vous pouvez t\u00e9l\u00e9charger directement le fichier texte du code SQL en <a href=\"http:\/\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/06\/fonction_stats_voronoi.txt\">cliquant ici<\/a>.<\/p> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Repr\u00e9sentation \u00ab\u00a0standard\u00a0\u00bb<\/h2>\n\n\n\n<p>Pour avoir une repr\u00e9sentation de m\u00eame type que celle de Geostatistical Analyst d&rsquo;ArcGis, vous pouvez t\u00e9l\u00e9charger deux styles, un pour cluster et un autre pour l&rsquo;entropie, <strong><a href=\"http:\/\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/styles_voronoi.zip\">en cliquant ici<\/a><\/strong>.<\/p>\n\n\n\n<p>Vous aurez pour la variable cluster une repr\u00e9sentation de type:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?ssl=1\"><img loading=\"lazy\" decoding=\"async\" width=\"1801\" height=\"1055\" data-attachment-id=\"8964\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im6-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?fit=1801%2C1055&amp;ssl=1\" data-orig-size=\"1801,1055\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?fit=640%2C375&amp;ssl=1\" src=\"https:\/\/i2.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?fit=525%2C308&amp;ssl=1\" alt=\"\" class=\"wp-image-8964\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?w=1801&amp;ssl=1 1801w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?resize=300%2C176&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?resize=768%2C450&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?resize=1024%2C600&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im6.jpg?w=1280&amp;ssl=1 1280w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n\n\n\n<p>Et pour l&rsquo;entropie, de type:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?ssl=1\"><img loading=\"lazy\" decoding=\"async\" width=\"1829\" height=\"1079\" data-attachment-id=\"8965\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/une-fonction-pl-pgsql-pour-lanalyse-exploratoire-de-donnees-spatiales-avec-des-polygones-de-voronoi\/im7-5\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?fit=1829%2C1079&amp;ssl=1\" data-orig-size=\"1829,1079\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"im7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?fit=640%2C378&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?fit=525%2C310&amp;ssl=1\" alt=\"\" class=\"wp-image-8965\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?w=1829&amp;ssl=1 1829w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?resize=300%2C177&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?resize=768%2C453&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?resize=1024%2C604&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/07\/im7.jpg?w=1280&amp;ssl=1 1280w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>L&rsquo;analyse exploratoire des donn\u00e9es spatiales est une \u00e9tape incontournable dans les processus d&rsquo;analyse spatiale. Un des outils pour cette exploration est la construction des polygones de Vorono\u00ef. (Voir Analyse exploratoire des donn\u00e9es pour la g\u00e9ostatistique:les diagrammes&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"give_campaign_id":0,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[152,311,62],"tags":[363,227,312,364],"class_list":["post-8944","post","type-post","status-publish","format-standard","hentry","category-outils_divers","category-postgresql","category-qgis-2","tag-polygones","tag-postgis","tag-postgresql","tag-voronoi"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-2kg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/8944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/comments?post=8944"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/8944\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=8944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=8944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=8944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}