﻿{"id":6196,"date":"2018-08-31T07:33:02","date_gmt":"2018-08-31T05:33:02","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=6196"},"modified":"2018-10-17T12:05:09","modified_gmt":"2018-10-17T10:05:09","slug":"spatial-analysis-with-sql-5-aggregation-function-arcgis-union","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/","title":{"rendered":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)"},"content":{"rendered":"\r\n<p class=\"wp-block-paragraph\">In Article previous we have discussed some <a href=\"https:\/\/translate.google.com\/translate?hl=en&amp;prev=_t&amp;sl=auto&amp;tl=en&amp;u=https:\/\/www.sigterritoires.fr\/index.php\/lanalyse-spatiale-avec-sql-4-fonctions-de-traitement-spatial\">SQL functions for spatial processing<\/a> . In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called <strong><em>Union<\/em><\/strong> in ArcGis. The purpose of the operation is to obtain a layer with all the intersections of the entities of the two original layers, and, also, all non-intersecting entities.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Let\u2019s use the following example. We have a first layer \u201crectangles\u201d<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"487\" data-attachment-id=\"6197\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/51\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/51.png?fit=684%2C521&amp;ssl=1\" data-orig-size=\"684,521\" 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=\"51\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/51.png?fit=640%2C487&amp;ssl=1\" class=\"wp-image-6197\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/51.png?resize=640%2C487&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/51.png?w=684&amp;ssl=1 684w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/51.png?resize=300%2C229&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">A second layer \u201ccircles\u201d<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"532\" height=\"495\" data-attachment-id=\"6198\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/52\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/52.png?fit=532%2C495&amp;ssl=1\" data-orig-size=\"532,495\" 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=\"52\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/52.png?fit=532%2C495&amp;ssl=1\" class=\"wp-image-6198\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/52.png?resize=532%2C495&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/52.png?w=532&amp;ssl=1 532w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/52.png?resize=300%2C279&amp;ssl=1 300w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">That overlaps spatially:<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"530\" data-attachment-id=\"6199\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/53\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/53.png?fit=709%2C587&amp;ssl=1\" data-orig-size=\"709,587\" 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=\"53\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/53.png?fit=640%2C530&amp;ssl=1\" class=\"wp-image-6199\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/53.png?resize=640%2C530&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/53.png?w=709&amp;ssl=1 709w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/53.png?resize=300%2C248&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">What we want to obtain is a layer containing all the polygons of both layers but creating polygons to overlay areas:<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"533\" data-attachment-id=\"6200\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/54\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/54.png?fit=685%2C570&amp;ssl=1\" data-orig-size=\"685,570\" 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=\"54\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/54.png?fit=640%2C533&amp;ssl=1\" class=\"wp-image-6200\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/54.png?resize=640%2C533&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/54.png?w=685&amp;ssl=1 685w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/54.png?resize=300%2C250&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">We will proceed by following the same method used in the previous article, i.e. by developing an SQL query including several sub queries.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">In the first place, we will develop a query that will build the polygons of the overlapping areas (the intersections) of both layers. These polygons appear in yellow in the next picture.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"550\" data-attachment-id=\"6201\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/55\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/55.png?fit=663%2C570&amp;ssl=1\" data-orig-size=\"663,570\" 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=\"55\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/55.png?fit=640%2C550&amp;ssl=1\" class=\"wp-image-6201\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/55.png?resize=640%2C550&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/55.png?w=663&amp;ssl=1 663w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/55.png?resize=300%2C258&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">We will resume the request used in the previous article:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"50\" data-attachment-id=\"6208\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/tuerca-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-3.png?fit=50%2C50&amp;ssl=1\" data-orig-size=\"50,50\" 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=\"tuerca-3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-3.png?fit=50%2C50&amp;ssl=1\" class=\"wp-image-6208\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-3.png?resize=50%2C50&#038;ssl=1\" alt=\"\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\"><strong><em>select<\/em><\/strong> <strong><em>circle.id as id1, rectangles.id as<\/em><\/strong> <strong><em>id2<\/em><\/strong>, <strong><em>st_intersection<\/em><\/strong> <strong><em>(<\/em><\/strong><strong>circle.geom<em>, rectangles.geom<\/em><\/strong> <strong><em>) as<\/em><\/strong> <strong><em>the_geom<\/em><\/strong> <br \/><strong><em>from<\/em><\/strong> <strong><em>circle, rectangles<\/em><\/strong> <br \/><strong><em>where<\/em><\/strong> <strong><em><a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/postgis-st-intersects-vs-st-within\/\">st_intersects<\/a><\/em><\/strong> <strong><em>(<\/em><\/strong> <strong><em>circle.geom, rectangles.geom<\/em><\/strong> <strong><em>)<\/em><\/strong> <br \/><strong><em>group by<\/em><\/strong> <strong><em>circle.id, rectangles.id<\/em><\/strong><\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">You will notice that the select is built not just to retrieve intersected geometries, but also the identifiers of the original entities (<strong><em>circle.id<\/em><\/strong> <strong>and<\/strong> <strong><em>rectangles.id)<\/em><\/strong>. Of course, you can recover other attributes, or all by changing this part of the request.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">To these polygons, we will add the rest of the areas occupied by the rectangle layer (in yellow in the following picture)<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"541\" data-attachment-id=\"6202\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/57\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/57.png?fit=670%2C566&amp;ssl=1\" data-orig-size=\"670,566\" 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=\"57\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/57.png?fit=640%2C541&amp;ssl=1\" class=\"wp-image-6202\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/57.png?resize=640%2C541&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/57.png?w=670&amp;ssl=1 670w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/57.png?resize=300%2C253&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"50\" data-attachment-id=\"6207\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/tuerca-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-2.png?fit=50%2C50&amp;ssl=1\" data-orig-size=\"50,50\" 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=\"tuerca-2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-2.png?fit=50%2C50&amp;ssl=1\" class=\"wp-image-6207\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-2.png?resize=50%2C50&#038;ssl=1\" alt=\"\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\"><strong>select<\/strong> <strong><em>0 as id1, rectangles.id as<\/em><\/strong> <strong>id2<\/strong>, <strong>st_difference<\/strong> <strong>(<\/strong> <strong><em>rectangles.geom<\/em><\/strong>,<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\"><strong>(select<\/strong> <strong>multi<\/strong> <strong>ST_<\/strong> <strong>(ST_Union<\/strong> <strong>(the_geom)) as<\/strong> <strong>the_geom<\/strong> <strong>from (<\/strong><br \/><strong>select<\/strong> <strong>st_intersection<\/strong> <strong>(<\/strong>circle.geom<strong><em>, rectangles.geom<\/em><\/strong> <strong>) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong><em>circle, rectangles<\/em><\/strong> <br \/><strong>where<\/strong> <strong>st_intersects<\/strong> <strong>(<\/strong> <strong><em>circle.geom, rectangles.geom<\/em><\/strong> <strong>))<\/strong> <br \/><strong>as<\/strong> <strong>the_geom<\/strong>)<strong>)<\/strong> <strong>as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from rectangles<\/strong><\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">What we get to do with this request is to extract all the intersection areas (as in the previous query) and convert them in a single multi-polygon. The request removes the difference of this multi- polygon with the layer of rectangles.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Finally, these polygons, we are going to add the rest of the areas occupied by the layer circles to these polygons (yellow in the following image)<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"526\" data-attachment-id=\"6203\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/58\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/58.png?fit=708%2C582&amp;ssl=1\" data-orig-size=\"708,582\" 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=\"58\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/58.png?fit=640%2C526&amp;ssl=1\" class=\"wp-image-6203\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/58.png?resize=640%2C526&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/58.png?w=708&amp;ssl=1 708w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/58.png?resize=300%2C247&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">We will proceed likewise the rectangles, by using a multi- polygon of intersection areas and calculating the difference with the layer circles:<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"50\" data-attachment-id=\"6206\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/tuerca-1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-1.png?fit=50%2C50&amp;ssl=1\" data-orig-size=\"50,50\" 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=\"tuerca-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-1.png?fit=50%2C50&amp;ssl=1\" class=\"wp-image-6206\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca-1.png?resize=50%2C50&#038;ssl=1\" alt=\"\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\"><strong>select<\/strong> <strong><em>circle.id as id1, 0 as<\/em><\/strong> <strong>id2<\/strong> <strong><em>,<\/em><\/strong> <strong>st_difference (<\/strong> <strong><em>circle.geom<\/em><\/strong> <strong>, (<\/strong> <br \/><strong>select<\/strong> <strong>st_multi<\/strong> <strong>(<\/strong> <strong>st_union<\/strong> <strong>(<\/strong> <strong>the_geom<\/strong> <strong>)) as<\/strong> <strong>the_geom<\/strong> <strong>from (<\/strong> <br \/><strong>select<\/strong> <strong>st_intersection<\/strong> <strong>(<\/strong> <strong><em>circle.geom, rectangles.geom<\/em><\/strong> <strong>) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong><em>circle, rectangles<\/em><\/strong> <br \/><strong>where<\/strong> <strong>st_intersects<\/strong> <strong>(<\/strong> <strong><em>circle.geom, rectangles.geom<\/em><\/strong> <strong>))<\/strong> <br \/><strong>as<\/strong> <strong>the_geom<\/strong> <strong>)) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong>circle<\/strong><\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">The union of these three requests produces the outcome layer we expected :<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"50\" data-attachment-id=\"6205\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/tuerca\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca.png?fit=50%2C50&amp;ssl=1\" data-orig-size=\"50,50\" 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=\"tuerca\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca.png?fit=50%2C50&amp;ssl=1\" class=\"wp-image-6205\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/tuerca.png?resize=50%2C50&#038;ssl=1\" alt=\"\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\"><strong>select *<\/strong> <br \/><strong>from<\/strong> <br \/><strong>(select circle.id as id1, rectangles.id<\/strong> <strong>as<\/strong> <strong>id2, st_intersection (<\/strong> <strong>circle.geom, rectangles.geom<\/strong> <strong>) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong>circle, rectangles<\/strong> <br \/><strong>where<\/strong> <strong>st_intersects<\/strong> <strong>(<\/strong> <strong>circle.geom, rectangles.geom<\/strong> <strong>)<\/strong> <br \/><strong>group by<\/strong> <strong>circle.id, rectangles.id<\/strong> <br \/><strong>union all<\/strong> <br \/><strong>select 0 as id1, rectangles.id as id2, st_difference (<\/strong> <strong>rectangles.geom<\/strong> <strong>, (<\/strong> <br \/><strong>select<\/strong> <strong>st_multi<\/strong> <strong>(<\/strong> <strong>st_union<\/strong> <strong>(<\/strong> <strong>the_geom<\/strong> <strong>)) as<\/strong> <strong>the_geom<\/strong> <strong>from (<\/strong> <br \/><strong>select<\/strong> <strong>st_intersection<\/strong> <strong>(<\/strong> <strong>circle.geom, rectangles.geom<\/strong> <strong>) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong>circle, rectangles<\/strong> <br \/><strong>where<\/strong> <strong>st_intersects<\/strong> <strong>(<\/strong> <strong>circle.geom, rectangles.geom<\/strong> <strong>))<\/strong> <br \/><strong>as<\/strong> <strong>the_geom<\/strong> <strong>)) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from rectangles<\/strong> <br \/><strong>union all<\/strong> <br \/><strong>select circle.id as id1, 0 as id2, st_difference (<\/strong> <strong>circle.geom<\/strong> <strong>, (<\/strong> <br \/><strong>select<\/strong> <strong>st_multi<\/strong> <strong>(<\/strong> <strong>st_union<\/strong> <strong>(<\/strong> <strong>the_geom<\/strong> <strong>)) as<\/strong> <strong>the_geom<\/strong> <strong>from (<\/strong> <br \/><strong>select<\/strong> <strong>st_intersection<\/strong> <strong>(<\/strong> <strong>circle.geom, rectangles.geom<\/strong> <strong>) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong>circle, rectangles<\/strong> <br \/><strong>where<\/strong> <strong>st_intersects<\/strong> <strong>(<\/strong> <strong>circle.geom, rectangles.geom<\/strong> <strong>))<\/strong> <br \/><strong>as<\/strong> <strong>the_geom<\/strong> <strong>)) as<\/strong> <strong>the_geom<\/strong> <br \/><strong>from<\/strong> <strong>circle<\/strong> <br \/><strong>) as T1<\/strong> \u00a0<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"534\" data-attachment-id=\"6204\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/attachment\/59\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/59.png?fit=684%2C571&amp;ssl=1\" data-orig-size=\"684,571\" 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=\"59\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/59.png?fit=640%2C534&amp;ssl=1\" class=\"wp-image-6204\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/59.png?resize=640%2C534&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/59.png?w=684&amp;ssl=1 684w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/59.png?resize=300%2C250&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\r\n","protected":false},"excerpt":{"rendered":"<p>In Article previous we have discussed some SQL functions for spatial processing . In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_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_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1296,1338],"tags":[1443,1351,1386,1404,1353,1445],"class_list":["post-6196","post","type-post","status-publish","format-standard","hentry","category-posts-en","category-postgresql-en","tag-aggregation","tag-postgresql-en","tag-qgis-en","tag-spatial-analyzis","tag-sql-en","tag-union-en"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Atilio Francois\"\/>\n\t<meta name=\"google-site-verification\" content=\"ByXHZUbGNn7RNv-Xk5A-ysTZrM65VLIO2RxfSJ2nIEQ\" \/>\n\t<meta name=\"keywords\" content=\"qgis,postgresql,sql,spatial analysis,union,aggregation,spatial analyzis\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"fr_FR\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Blog SIG &amp; Territoires | le portail des professionnels du SIG\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG &amp; Territoires\" \/>\n\t\t<meta property=\"og:description\" content=\"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-08-31T05:33:02+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-10-17T10:05:09+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/atilio.francois\/\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@SigTerritoires\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG &amp; Territoires\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@SigTerritoires\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#article\",\"name\":\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG & Territoires\",\"headline\":\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)\",\"author\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.sigterritoires.fr\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/51.png?fit=684%2C521&ssl=1\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#articleImage\",\"width\":684,\"height\":521},\"datePublished\":\"2018-08-31T07:33:02+02:00\",\"dateModified\":\"2018-10-17T12:05:09+02:00\",\"inLanguage\":\"fr-FR\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#webpage\"},\"articleSection\":\"english posts, PostgreSQL, aggregation, postgresql, qgis, spatial analyzis, sql, union, English\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sigterritoires.fr\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/#listItem\",\"name\":\"Database\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/#listItem\",\"position\":2,\"name\":\"Database\",\"item\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/postgresql-en\\\/#listItem\",\"name\":\"PostgreSQL\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/postgresql-en\\\/#listItem\",\"position\":3,\"name\":\"PostgreSQL\",\"item\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/postgresql-en\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#listItem\",\"name\":\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/#listItem\",\"name\":\"Database\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#listItem\",\"position\":4,\"name\":\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/database\\\/postgresql-en\\\/#listItem\",\"name\":\"PostgreSQL\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#person\",\"name\":\"Atilio Francois\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Atilio Francois\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/\",\"name\":\"Atilio Francois\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Atilio Francois\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#webpage\",\"url\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/\",\"name\":\"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG & Territoires\",\"description\":\"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.\",\"inLanguage\":\"fr-FR\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2018-08-31T07:33:02+02:00\",\"dateModified\":\"2018-10-17T12:05:09+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#website\",\"url\":\"https:\\\/\\\/www.sigterritoires.fr\\\/\",\"name\":\"Blog SIG & Territoires\",\"description\":\"le portail des professionnels du SIG\",\"inLanguage\":\"fr-FR\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG & Territoires","description":"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.","canonical_url":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/","robots":"max-image-preview:large","keywords":"qgis,postgresql,sql,spatial analysis,union,aggregation,spatial analyzis","webmasterTools":{"google-site-verification":"ByXHZUbGNn7RNv-Xk5A-ysTZrM65VLIO2RxfSJ2nIEQ","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#article","name":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG & Territoires","headline":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)","author":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/www.sigterritoires.fr\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2018\/08\/51.png?fit=684%2C521&ssl=1","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#articleImage","width":684,"height":521},"datePublished":"2018-08-31T07:33:02+02:00","dateModified":"2018-10-17T12:05:09+02:00","inLanguage":"fr-FR","mainEntityOfPage":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#webpage"},"isPartOf":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#webpage"},"articleSection":"english posts, PostgreSQL, aggregation, postgresql, qgis, spatial analyzis, sql, union, English"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr#listItem","position":1,"name":"Home","item":"https:\/\/www.sigterritoires.fr","nextItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/#listItem","name":"Database"}},{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/#listItem","position":2,"name":"Database","item":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/postgresql-en\/#listItem","name":"PostgreSQL"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/postgresql-en\/#listItem","position":3,"name":"PostgreSQL","item":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/postgresql-en\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#listItem","name":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/#listItem","name":"Database"}},{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#listItem","position":4,"name":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)","previousItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/postgresql-en\/#listItem","name":"PostgreSQL"}}]},{"@type":"Person","@id":"https:\/\/www.sigterritoires.fr\/#person","name":"Atilio Francois","image":{"@type":"ImageObject","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g","width":96,"height":96,"caption":"Atilio Francois"}},{"@type":"Person","@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author","url":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/","name":"Atilio Francois","image":{"@type":"ImageObject","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g","width":96,"height":96,"caption":"Atilio Francois"}},{"@type":"WebPage","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#webpage","url":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/","name":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG & Territoires","description":"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.","inLanguage":"fr-FR","isPartOf":{"@id":"https:\/\/www.sigterritoires.fr\/#website"},"breadcrumb":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/#breadcrumblist"},"author":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author"},"creator":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author"},"datePublished":"2018-08-31T07:33:02+02:00","dateModified":"2018-10-17T12:05:09+02:00"},{"@type":"WebSite","@id":"https:\/\/www.sigterritoires.fr\/#website","url":"https:\/\/www.sigterritoires.fr\/","name":"Blog SIG & Territoires","description":"le portail des professionnels du SIG","inLanguage":"fr-FR","publisher":{"@id":"https:\/\/www.sigterritoires.fr\/#person"}}]},"og:locale":"fr_FR","og:site_name":"Blog SIG &amp; Territoires | le portail des professionnels du SIG","og:type":"article","og:title":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG &amp; Territoires","og:description":"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.","og:url":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/","article:published_time":"2018-08-31T05:33:02+00:00","article:modified_time":"2018-10-17T10:05:09+00:00","article:publisher":"https:\/\/www.facebook.com\/atilio.francois\/","twitter:card":"summary","twitter:site":"@SigTerritoires","twitter:title":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | Blog SIG &amp; Territoires","twitter:description":"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.","twitter:creator":"@SigTerritoires"},"aioseo_meta_data":{"post_id":"6196","title":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union) | #site_title","description":"In this article we will see a function a little more complicated to put at work: the aggregation function for two layers of polygons. This operation is the one called Union in ArcGis.","keywords":[{"label":"qgis","value":"qgis"},{"label":"postgresql","value":"postgresql"},{"label":"sql","value":"sql"},{"label":"spatial analysis","value":"spatial analysis"},{"label":"union","value":"union"},{"label":"aggregation","value":"aggregation"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 13:58:08","updated":"2025-06-04 16:38:40","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.sigterritoires.fr\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/\" title=\"Database\">Database<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/postgresql-en\/\" title=\"PostgreSQL\">PostgreSQL<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tSpatial analysis with SQL: 5- aggregation function (ArcGis Union)\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.sigterritoires.fr"},{"label":"Database","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/"},{"label":"PostgreSQL","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/database\/postgresql-en\/"},{"label":"Spatial analysis with SQL: 5- aggregation function (ArcGis Union)","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/spatial-analysis-with-sql-5-aggregation-function-arcgis-union\/"}],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-1BW","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/6196","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=6196"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/6196\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=6196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=6196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=6196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}