Create mosaic like Voronoi Diagram from disjoint polygons Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Separate polygons based on intersection using PostGISSimplifying polygons to linestring?How to use ST_DelaunayTriangles to construct a Voronoi diagram?Constructing Voronoi diagram in PostGISCreate voronoi diagram from line segmentsHow to create random points in a polygon in PostGISCalculating Voronoi Diagrams for polygonsPoint sampling along a pole-wrapping coastline with PostGISCreating voronoi polygons from polygons?Create Voronoi/Thiessen polygons in QGIS around 3 pointsCreate voronoi diagram from line segmentsWhat is the correct cartographic projection to calculate a Voronoi tesselation?Constructing Voronoi diagram in PostGISCreating voronoi polygons from polygons?How to Create Voronoi Polygon Diagram within surrounding polygon?Calculating Voronoi Diagrams for polygonsNo Voronoi polygons createdPostGIS global Voronoi Thiessen Diagram PolygonHow to generate a Global Voronoi diagram?

What is the electric potential inside a point charge?

How can I protect witches in combat who wear limited clothing?

Interesting examples of non-locally compact topological groups

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Can the prologue be the backstory of your main character?

How many spell slots should a Fighter 11/Ranger 9 have?

What's the point in a preamp?

Fishing simulator

Problem when applying foreach loop

I'm thinking of a number

Who can trigger ship-wide alerts in Star Trek?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

If I can make up priors, why can't I make up posteriors?

I'm having difficulty getting my players to do stuff in a sandbox campaign

Am I ethically obligated to go into work on an off day if the reason is sudden?

How are presidential pardons supposed to be used?

What do you call a plan that's an alternative plan in case your initial plan fails?

Why did AF447 never return to normal law?

What's the difference between (size_t)-1 and ~0?

Need a suitable toxic chemical for a murder plot in my novel

Limit for e and 1/e

What was Bilhah and Zilpah's ancestry?

What is the largest species of polychaete?

Did the new image of black hole confirm the general theory of relativity?



Create mosaic like Voronoi Diagram from disjoint polygons



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Separate polygons based on intersection using PostGISSimplifying polygons to linestring?How to use ST_DelaunayTriangles to construct a Voronoi diagram?Constructing Voronoi diagram in PostGISCreate voronoi diagram from line segmentsHow to create random points in a polygon in PostGISCalculating Voronoi Diagrams for polygonsPoint sampling along a pole-wrapping coastline with PostGISCreating voronoi polygons from polygons?Create Voronoi/Thiessen polygons in QGIS around 3 pointsCreate voronoi diagram from line segmentsWhat is the correct cartographic projection to calculate a Voronoi tesselation?Constructing Voronoi diagram in PostGISCreating voronoi polygons from polygons?How to Create Voronoi Polygon Diagram within surrounding polygon?Calculating Voronoi Diagrams for polygonsNo Voronoi polygons createdPostGIS global Voronoi Thiessen Diagram PolygonHow to generate a Global Voronoi diagram?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








11















The illustration below shows the problem:



enter image description here



as in (a) I have a set of disjoint polygons, as geometries in PostGIS. I need something like (b), the "mosaic" of this set of polygons, building it by a "influence region" criteria... Is like a Voronoi construction (illustrated by (c)): in fact, if the polygons was points, the influence regions are Voronoi.



Summarizing: I need a SQL algorithm (or some specific for PostGIS) that generates the "mosaic" of a set of disjoint polygons.
(perhaps a loop of little ST_Buffer and ST_Difference operations)



PS: I need, like Voronoi's, that space delimitation (a squared frame in (b)) is ignored.




This problem is similar to this other about lines.



EDIT (after @FelixIP comment)



I preffer to stay in vector universe, to not lost precision (ex. using ST_DelaunayTriangles and adding and subtracting interiors by the original polygons, them adapting a dual graph solution)... Some simple and automatic packages like pprepair (assisted like QGIS topological tools are not automatic).
But raster is perhaps simpler and less CPU-consuming.



This "GRID process" illustration is also valid as solution, assuming that it can allowing same precision and "euclidean influence region growing".



enter image description here



In ARCGIS exists a spatial analysis tool known as Euclidean Allocation, so, perhaps there are a PostGIS similar solution, starting with the set of polygons (classifying, rasterizing and making-back the polygons).










share|improve this question
























  • Thanks @Nir, sorry the confusion with points, I am not using points, only polygons as items (a) and (b) of the illustration... Do you have a link of your clue about solution?

    – Peter Krauss
    Oct 11 '15 at 20:22












  • In arcgis there is a raster solution called eucledean allocation or proximity

    – FelixIP
    Oct 12 '15 at 5:10











  • Thanks @FelixIP, I edited to "well come raster solutions" ;-)

    – Peter Krauss
    Oct 13 '15 at 14:47











  • If you erase your polygons from their extent.aspolygon, you'll be left with polygon. Skeleton of it gis.stackexchange.com/questions/177/… is what you need I guess. Implementation is a biggie though

    – FelixIP
    Oct 22 '15 at 2:02












  • Not answers to you problem but probably interesting gis.stackexchange.com/questions/104631/… and voronoi.com/wiki/images/7/76/….

    – user30184
    Dec 1 '16 at 9:04

















11















The illustration below shows the problem:



enter image description here



as in (a) I have a set of disjoint polygons, as geometries in PostGIS. I need something like (b), the "mosaic" of this set of polygons, building it by a "influence region" criteria... Is like a Voronoi construction (illustrated by (c)): in fact, if the polygons was points, the influence regions are Voronoi.



Summarizing: I need a SQL algorithm (or some specific for PostGIS) that generates the "mosaic" of a set of disjoint polygons.
(perhaps a loop of little ST_Buffer and ST_Difference operations)



PS: I need, like Voronoi's, that space delimitation (a squared frame in (b)) is ignored.




This problem is similar to this other about lines.



EDIT (after @FelixIP comment)



I preffer to stay in vector universe, to not lost precision (ex. using ST_DelaunayTriangles and adding and subtracting interiors by the original polygons, them adapting a dual graph solution)... Some simple and automatic packages like pprepair (assisted like QGIS topological tools are not automatic).
But raster is perhaps simpler and less CPU-consuming.



This "GRID process" illustration is also valid as solution, assuming that it can allowing same precision and "euclidean influence region growing".



enter image description here



In ARCGIS exists a spatial analysis tool known as Euclidean Allocation, so, perhaps there are a PostGIS similar solution, starting with the set of polygons (classifying, rasterizing and making-back the polygons).










share|improve this question
























  • Thanks @Nir, sorry the confusion with points, I am not using points, only polygons as items (a) and (b) of the illustration... Do you have a link of your clue about solution?

    – Peter Krauss
    Oct 11 '15 at 20:22












  • In arcgis there is a raster solution called eucledean allocation or proximity

    – FelixIP
    Oct 12 '15 at 5:10











  • Thanks @FelixIP, I edited to "well come raster solutions" ;-)

    – Peter Krauss
    Oct 13 '15 at 14:47











  • If you erase your polygons from their extent.aspolygon, you'll be left with polygon. Skeleton of it gis.stackexchange.com/questions/177/… is what you need I guess. Implementation is a biggie though

    – FelixIP
    Oct 22 '15 at 2:02












  • Not answers to you problem but probably interesting gis.stackexchange.com/questions/104631/… and voronoi.com/wiki/images/7/76/….

    – user30184
    Dec 1 '16 at 9:04













11












11








11


8






The illustration below shows the problem:



enter image description here



as in (a) I have a set of disjoint polygons, as geometries in PostGIS. I need something like (b), the "mosaic" of this set of polygons, building it by a "influence region" criteria... Is like a Voronoi construction (illustrated by (c)): in fact, if the polygons was points, the influence regions are Voronoi.



Summarizing: I need a SQL algorithm (or some specific for PostGIS) that generates the "mosaic" of a set of disjoint polygons.
(perhaps a loop of little ST_Buffer and ST_Difference operations)



PS: I need, like Voronoi's, that space delimitation (a squared frame in (b)) is ignored.




This problem is similar to this other about lines.



EDIT (after @FelixIP comment)



I preffer to stay in vector universe, to not lost precision (ex. using ST_DelaunayTriangles and adding and subtracting interiors by the original polygons, them adapting a dual graph solution)... Some simple and automatic packages like pprepair (assisted like QGIS topological tools are not automatic).
But raster is perhaps simpler and less CPU-consuming.



This "GRID process" illustration is also valid as solution, assuming that it can allowing same precision and "euclidean influence region growing".



enter image description here



In ARCGIS exists a spatial analysis tool known as Euclidean Allocation, so, perhaps there are a PostGIS similar solution, starting with the set of polygons (classifying, rasterizing and making-back the polygons).










share|improve this question
















The illustration below shows the problem:



enter image description here



as in (a) I have a set of disjoint polygons, as geometries in PostGIS. I need something like (b), the "mosaic" of this set of polygons, building it by a "influence region" criteria... Is like a Voronoi construction (illustrated by (c)): in fact, if the polygons was points, the influence regions are Voronoi.



Summarizing: I need a SQL algorithm (or some specific for PostGIS) that generates the "mosaic" of a set of disjoint polygons.
(perhaps a loop of little ST_Buffer and ST_Difference operations)



PS: I need, like Voronoi's, that space delimitation (a squared frame in (b)) is ignored.




This problem is similar to this other about lines.



EDIT (after @FelixIP comment)



I preffer to stay in vector universe, to not lost precision (ex. using ST_DelaunayTriangles and adding and subtracting interiors by the original polygons, them adapting a dual graph solution)... Some simple and automatic packages like pprepair (assisted like QGIS topological tools are not automatic).
But raster is perhaps simpler and less CPU-consuming.



This "GRID process" illustration is also valid as solution, assuming that it can allowing same precision and "euclidean influence region growing".



enter image description here



In ARCGIS exists a spatial analysis tool known as Euclidean Allocation, so, perhaps there are a PostGIS similar solution, starting with the set of polygons (classifying, rasterizing and making-back the polygons).







polygon-creation voronoi-thiessen






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:33









Community

1




1










asked Oct 11 '15 at 16:14









Peter KraussPeter Krauss

1,1241435




1,1241435












  • Thanks @Nir, sorry the confusion with points, I am not using points, only polygons as items (a) and (b) of the illustration... Do you have a link of your clue about solution?

    – Peter Krauss
    Oct 11 '15 at 20:22












  • In arcgis there is a raster solution called eucledean allocation or proximity

    – FelixIP
    Oct 12 '15 at 5:10











  • Thanks @FelixIP, I edited to "well come raster solutions" ;-)

    – Peter Krauss
    Oct 13 '15 at 14:47











  • If you erase your polygons from their extent.aspolygon, you'll be left with polygon. Skeleton of it gis.stackexchange.com/questions/177/… is what you need I guess. Implementation is a biggie though

    – FelixIP
    Oct 22 '15 at 2:02












  • Not answers to you problem but probably interesting gis.stackexchange.com/questions/104631/… and voronoi.com/wiki/images/7/76/….

    – user30184
    Dec 1 '16 at 9:04

















  • Thanks @Nir, sorry the confusion with points, I am not using points, only polygons as items (a) and (b) of the illustration... Do you have a link of your clue about solution?

    – Peter Krauss
    Oct 11 '15 at 20:22












  • In arcgis there is a raster solution called eucledean allocation or proximity

    – FelixIP
    Oct 12 '15 at 5:10











  • Thanks @FelixIP, I edited to "well come raster solutions" ;-)

    – Peter Krauss
    Oct 13 '15 at 14:47











  • If you erase your polygons from their extent.aspolygon, you'll be left with polygon. Skeleton of it gis.stackexchange.com/questions/177/… is what you need I guess. Implementation is a biggie though

    – FelixIP
    Oct 22 '15 at 2:02












  • Not answers to you problem but probably interesting gis.stackexchange.com/questions/104631/… and voronoi.com/wiki/images/7/76/….

    – user30184
    Dec 1 '16 at 9:04
















Thanks @Nir, sorry the confusion with points, I am not using points, only polygons as items (a) and (b) of the illustration... Do you have a link of your clue about solution?

– Peter Krauss
Oct 11 '15 at 20:22






Thanks @Nir, sorry the confusion with points, I am not using points, only polygons as items (a) and (b) of the illustration... Do you have a link of your clue about solution?

– Peter Krauss
Oct 11 '15 at 20:22














In arcgis there is a raster solution called eucledean allocation or proximity

– FelixIP
Oct 12 '15 at 5:10





In arcgis there is a raster solution called eucledean allocation or proximity

– FelixIP
Oct 12 '15 at 5:10













Thanks @FelixIP, I edited to "well come raster solutions" ;-)

– Peter Krauss
Oct 13 '15 at 14:47





Thanks @FelixIP, I edited to "well come raster solutions" ;-)

– Peter Krauss
Oct 13 '15 at 14:47













If you erase your polygons from their extent.aspolygon, you'll be left with polygon. Skeleton of it gis.stackexchange.com/questions/177/… is what you need I guess. Implementation is a biggie though

– FelixIP
Oct 22 '15 at 2:02






If you erase your polygons from their extent.aspolygon, you'll be left with polygon. Skeleton of it gis.stackexchange.com/questions/177/… is what you need I guess. Implementation is a biggie though

– FelixIP
Oct 22 '15 at 2:02














Not answers to you problem but probably interesting gis.stackexchange.com/questions/104631/… and voronoi.com/wiki/images/7/76/….

– user30184
Dec 1 '16 at 9:04





Not answers to you problem but probably interesting gis.stackexchange.com/questions/104631/… and voronoi.com/wiki/images/7/76/….

– user30184
Dec 1 '16 at 9:04










4 Answers
4






active

oldest

votes


















1














So, I will prepare a cake for you - fruit platter, using PostGis tools, as you requested, if I correctly understood the question, and as I mentioned, the responsibility for the operation of the PostGis oven is borne by her creative team.



I will ask not to be offended by anyone in my humorous style and to understand it as a game!



The original file is sliced fruit and simple shapes (hereinafter referred to as fruit), see Figure 1 below.



enter image description here



Here is my recipe, and I will be helped in this by dear programmers, whom you will learn about later.
Let's begin, and for this we will create a dough in which our fruits will be laid, for which run the script:



create table poly_extent as
SELECT st_setsrid(ST_Buffer(ST_Envelope(ST_Extent(geom)),0.05),4326) as geom from poly;



See the result in Figure 2 below



enter image description here



Now, if there are few fruits, like in my picture, create the border of the external buffer on the fruit, or if there are many fruits, create the border of the negative buffer, for which run the script:



create table poly_buff_dump as
SELECT ((ST_Dump(ST_Boundary(ST_Union(ST_Buffer((geom),0.01, 'join=mitre mitre_limit=5.0'))))).geom) geom from poly;



And slice the buffer lines around each fruit



update poly_buff_dump SET geom=ST_RemovePoint(geom, ST_NPoints(geom)-1)
WHERE ST_IsClosed(geom)=true;

See the result in Figure 3 below



enter image description here



(Actually, I thought that as a result I would get broken lines (such as in a circle), but if the figures are difficult, sometimes breaks are obtained, incorrect ones, for example, one side of the rectangle fell off, etc.)



Then you need to divide the obtained lines in a convenient way for you into equal segments and extract points from them




create table poly_buff_dump_pt as
SELECT (ST_DumpPoints((geom))).geom geom from poly_buff_segm;

Result, see Figure 4 below



enter image description here



Now run the Voronoi tool, in this place I used the tool suggested by the link MickyT :https://gis.stackexchange.com/a/172246/120129
, as a result of which you will have created tables with the name “voronoi” for the fact that “my first assistant” is separate from the chef thanks from the chef! :-).



The second way in this step is to run the ST_VoronoiPolygons function.



Result, see Figure 5 below



enter image description here



Now, cut off the extra parts by running the script:



create table poly_voronoi_cut as
SELECT ST_Intersection (a.geom, b.geom) geom
from voronoi a INNER JOIN poly_extent b ON ST_Intersects (a.geom,b.geom);

Result, see Figure 6 below.



enter image description here



Now run the script in order to align the geodata type in LineString:



create table poly_voronoi_dump as
SELECT
(ST_Dump(geom)).geom as geom
FROM
poly_voronoi_cut;

And now I will ask "my second mate" to take up my duties and mix the cake wel (Jeff - https://gis.stackexchange.com/a/785/120129), leveling it in a single layer, and for that, thanks to me for it!



CREATE TABLE poly_overlay_cut AS
SELECT geom FROM ST_Dump((
SELECT ST_Polygonize(geom) AS geom FROM (
SELECT ST_Union(geom) AS geom FROM (
SELECT ST_ExteriorRing(geom) AS geom FROM poly_voronoi_dump) AS lines
) AS noded_lines
)
);

Now it’s time for me to get to work, for which I run the script:



create table poly_voronoi_union as
SELECT b.id, (ST_ConvexHull(ST_Union(a.geom, b.geom))) geom
from poly_overlay_cut a INNER JOIN poly_buff_dump b ON ST_Intersects(a.geom,b.geom)
group by b.id, a.geom, b.geom;

and another script:



create table poly_voronoi_union_area as
SELECT ST_Union(ST_ConvexHull(ST_BuildArea(geom))) as geom from poly_voronoi_union
group by id;

see figure 7 below



enter image description here



As you can see in the picture, our cuts have small layers, which can be removed, as an option using ST_SnapToGrid (or in another way):



And finally, we will cut out our baked fruit from our pie, I even got a little tired standing by the oven, :-)



create table polygon_voronoi_result as
SELECT
(ST_Dump(ST_Difference(a.geom, b.geom))).geom as geom
FROM poly_voronoi_union_area_snap as a JOIN poly b ON ST_Intersects(a.geom, b.geom);

Result see figure 8
enter image description here



Everything from this day, now everyone will learn to bake delicious pies - fruit platter. Help yourself All, and choose the pieces you, likeenough for everyone.



(P.S. It’s a pity that I really can’t feed all people, not with electronic cakes, but with real cakes, perhaps hunger would end on Earth ...)



With you was Mr. good and fair Baker, thank you all and good luck, :-)... OS.






share|improve this answer

























  • Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

    – Peter Krauss
    Apr 9 at 10:47











  • 1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

    – Cyril
    Apr 9 at 11:45












  • Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

    – Cyril
    Apr 9 at 12:08











  • By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

    – Cyril
    Apr 9 at 16:17











  • Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

    – Peter Krauss
    Apr 10 at 20:08


















5














Postgis do not have a dedicated function for voronoi, but Qgis contains vornoi function which could make voronoi polygons from points, so using qgis i've followed the following steps to have these result:



-make points from polygons using extract nodes functions.



-make vornoi polygons using voroi functions in Qgis.



-make a spatial join in Qgis.



-dissolve results.



enter image description here






share|improve this answer

























  • Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

    – Peter Krauss
    Oct 27 '15 at 17:50












  • I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

    – FelixIP
    Dec 1 '16 at 21:39


















2





+50









OK - Thought about this a little and found it was like something I have been looking at lately.



Take your starting polys:



enter image description here



Generate a new attribute with a number (100 in my case)
Use the Vector-> Research tools -> Random points inside polygons tool
this will generate (100) points inside each polygon:
enter image description here



Then Vector-> Geometry tools -> Voronoi to generate polys based upon that point layer.



enter image description here



Now, you can use the Vector -> Spatial Query tool:
Select the points that belong to one polygon (or one of the polygons)
Use the spatial query tool to generate a selection of your voronoi polygons which apply to that polygon.
Add an attribute to the voroni polygon which corresponds to the polygon of interest. (I just used 1,2,3,4)



Now you can Vector-> Geoprocessing Tools-> dissolve based upon your new attribute.



enter image description here






share|improve this answer























  • Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

    – Peter Krauss
    Nov 30 '16 at 15:41











  • @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

    – Phil G
    Dec 1 '16 at 12:52












  • My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

    – Peter Krauss
    Dec 7 '16 at 13:42











  • Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

    – A.A
    Dec 7 '16 at 18:27


















1














Random points are a good idea to generate a voronoi polygon from polygons, it works pretty well, but it's pretty bad for polygons close to each other:
enter image description hereenter image description here



ST_ApproximateMedialAxis is another good alternative if using PostGIS:
Calculating Voronoi Diagrams for polygons






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "79"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f166143%2fcreate-mosaic-like-voronoi-diagram-from-disjoint-polygons%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    So, I will prepare a cake for you - fruit platter, using PostGis tools, as you requested, if I correctly understood the question, and as I mentioned, the responsibility for the operation of the PostGis oven is borne by her creative team.



    I will ask not to be offended by anyone in my humorous style and to understand it as a game!



    The original file is sliced fruit and simple shapes (hereinafter referred to as fruit), see Figure 1 below.



    enter image description here



    Here is my recipe, and I will be helped in this by dear programmers, whom you will learn about later.
    Let's begin, and for this we will create a dough in which our fruits will be laid, for which run the script:



    create table poly_extent as
    SELECT st_setsrid(ST_Buffer(ST_Envelope(ST_Extent(geom)),0.05),4326) as geom from poly;



    See the result in Figure 2 below



    enter image description here



    Now, if there are few fruits, like in my picture, create the border of the external buffer on the fruit, or if there are many fruits, create the border of the negative buffer, for which run the script:



    create table poly_buff_dump as
    SELECT ((ST_Dump(ST_Boundary(ST_Union(ST_Buffer((geom),0.01, 'join=mitre mitre_limit=5.0'))))).geom) geom from poly;



    And slice the buffer lines around each fruit



    update poly_buff_dump SET geom=ST_RemovePoint(geom, ST_NPoints(geom)-1)
    WHERE ST_IsClosed(geom)=true;

    See the result in Figure 3 below



    enter image description here



    (Actually, I thought that as a result I would get broken lines (such as in a circle), but if the figures are difficult, sometimes breaks are obtained, incorrect ones, for example, one side of the rectangle fell off, etc.)



    Then you need to divide the obtained lines in a convenient way for you into equal segments and extract points from them




    create table poly_buff_dump_pt as
    SELECT (ST_DumpPoints((geom))).geom geom from poly_buff_segm;

    Result, see Figure 4 below



    enter image description here



    Now run the Voronoi tool, in this place I used the tool suggested by the link MickyT :https://gis.stackexchange.com/a/172246/120129
    , as a result of which you will have created tables with the name “voronoi” for the fact that “my first assistant” is separate from the chef thanks from the chef! :-).



    The second way in this step is to run the ST_VoronoiPolygons function.



    Result, see Figure 5 below



    enter image description here



    Now, cut off the extra parts by running the script:



    create table poly_voronoi_cut as
    SELECT ST_Intersection (a.geom, b.geom) geom
    from voronoi a INNER JOIN poly_extent b ON ST_Intersects (a.geom,b.geom);

    Result, see Figure 6 below.



    enter image description here



    Now run the script in order to align the geodata type in LineString:



    create table poly_voronoi_dump as
    SELECT
    (ST_Dump(geom)).geom as geom
    FROM
    poly_voronoi_cut;

    And now I will ask "my second mate" to take up my duties and mix the cake wel (Jeff - https://gis.stackexchange.com/a/785/120129), leveling it in a single layer, and for that, thanks to me for it!



    CREATE TABLE poly_overlay_cut AS
    SELECT geom FROM ST_Dump((
    SELECT ST_Polygonize(geom) AS geom FROM (
    SELECT ST_Union(geom) AS geom FROM (
    SELECT ST_ExteriorRing(geom) AS geom FROM poly_voronoi_dump) AS lines
    ) AS noded_lines
    )
    );

    Now it’s time for me to get to work, for which I run the script:



    create table poly_voronoi_union as
    SELECT b.id, (ST_ConvexHull(ST_Union(a.geom, b.geom))) geom
    from poly_overlay_cut a INNER JOIN poly_buff_dump b ON ST_Intersects(a.geom,b.geom)
    group by b.id, a.geom, b.geom;

    and another script:



    create table poly_voronoi_union_area as
    SELECT ST_Union(ST_ConvexHull(ST_BuildArea(geom))) as geom from poly_voronoi_union
    group by id;

    see figure 7 below



    enter image description here



    As you can see in the picture, our cuts have small layers, which can be removed, as an option using ST_SnapToGrid (or in another way):



    And finally, we will cut out our baked fruit from our pie, I even got a little tired standing by the oven, :-)



    create table polygon_voronoi_result as
    SELECT
    (ST_Dump(ST_Difference(a.geom, b.geom))).geom as geom
    FROM poly_voronoi_union_area_snap as a JOIN poly b ON ST_Intersects(a.geom, b.geom);

    Result see figure 8
    enter image description here



    Everything from this day, now everyone will learn to bake delicious pies - fruit platter. Help yourself All, and choose the pieces you, likeenough for everyone.



    (P.S. It’s a pity that I really can’t feed all people, not with electronic cakes, but with real cakes, perhaps hunger would end on Earth ...)



    With you was Mr. good and fair Baker, thank you all and good luck, :-)... OS.






    share|improve this answer

























    • Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

      – Peter Krauss
      Apr 9 at 10:47











    • 1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

      – Cyril
      Apr 9 at 11:45












    • Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

      – Cyril
      Apr 9 at 12:08











    • By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

      – Cyril
      Apr 9 at 16:17











    • Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

      – Peter Krauss
      Apr 10 at 20:08















    1














    So, I will prepare a cake for you - fruit platter, using PostGis tools, as you requested, if I correctly understood the question, and as I mentioned, the responsibility for the operation of the PostGis oven is borne by her creative team.



    I will ask not to be offended by anyone in my humorous style and to understand it as a game!



    The original file is sliced fruit and simple shapes (hereinafter referred to as fruit), see Figure 1 below.



    enter image description here



    Here is my recipe, and I will be helped in this by dear programmers, whom you will learn about later.
    Let's begin, and for this we will create a dough in which our fruits will be laid, for which run the script:



    create table poly_extent as
    SELECT st_setsrid(ST_Buffer(ST_Envelope(ST_Extent(geom)),0.05),4326) as geom from poly;



    See the result in Figure 2 below



    enter image description here



    Now, if there are few fruits, like in my picture, create the border of the external buffer on the fruit, or if there are many fruits, create the border of the negative buffer, for which run the script:



    create table poly_buff_dump as
    SELECT ((ST_Dump(ST_Boundary(ST_Union(ST_Buffer((geom),0.01, 'join=mitre mitre_limit=5.0'))))).geom) geom from poly;



    And slice the buffer lines around each fruit



    update poly_buff_dump SET geom=ST_RemovePoint(geom, ST_NPoints(geom)-1)
    WHERE ST_IsClosed(geom)=true;

    See the result in Figure 3 below



    enter image description here



    (Actually, I thought that as a result I would get broken lines (such as in a circle), but if the figures are difficult, sometimes breaks are obtained, incorrect ones, for example, one side of the rectangle fell off, etc.)



    Then you need to divide the obtained lines in a convenient way for you into equal segments and extract points from them




    create table poly_buff_dump_pt as
    SELECT (ST_DumpPoints((geom))).geom geom from poly_buff_segm;

    Result, see Figure 4 below



    enter image description here



    Now run the Voronoi tool, in this place I used the tool suggested by the link MickyT :https://gis.stackexchange.com/a/172246/120129
    , as a result of which you will have created tables with the name “voronoi” for the fact that “my first assistant” is separate from the chef thanks from the chef! :-).



    The second way in this step is to run the ST_VoronoiPolygons function.



    Result, see Figure 5 below



    enter image description here



    Now, cut off the extra parts by running the script:



    create table poly_voronoi_cut as
    SELECT ST_Intersection (a.geom, b.geom) geom
    from voronoi a INNER JOIN poly_extent b ON ST_Intersects (a.geom,b.geom);

    Result, see Figure 6 below.



    enter image description here



    Now run the script in order to align the geodata type in LineString:



    create table poly_voronoi_dump as
    SELECT
    (ST_Dump(geom)).geom as geom
    FROM
    poly_voronoi_cut;

    And now I will ask "my second mate" to take up my duties and mix the cake wel (Jeff - https://gis.stackexchange.com/a/785/120129), leveling it in a single layer, and for that, thanks to me for it!



    CREATE TABLE poly_overlay_cut AS
    SELECT geom FROM ST_Dump((
    SELECT ST_Polygonize(geom) AS geom FROM (
    SELECT ST_Union(geom) AS geom FROM (
    SELECT ST_ExteriorRing(geom) AS geom FROM poly_voronoi_dump) AS lines
    ) AS noded_lines
    )
    );

    Now it’s time for me to get to work, for which I run the script:



    create table poly_voronoi_union as
    SELECT b.id, (ST_ConvexHull(ST_Union(a.geom, b.geom))) geom
    from poly_overlay_cut a INNER JOIN poly_buff_dump b ON ST_Intersects(a.geom,b.geom)
    group by b.id, a.geom, b.geom;

    and another script:



    create table poly_voronoi_union_area as
    SELECT ST_Union(ST_ConvexHull(ST_BuildArea(geom))) as geom from poly_voronoi_union
    group by id;

    see figure 7 below



    enter image description here



    As you can see in the picture, our cuts have small layers, which can be removed, as an option using ST_SnapToGrid (or in another way):



    And finally, we will cut out our baked fruit from our pie, I even got a little tired standing by the oven, :-)



    create table polygon_voronoi_result as
    SELECT
    (ST_Dump(ST_Difference(a.geom, b.geom))).geom as geom
    FROM poly_voronoi_union_area_snap as a JOIN poly b ON ST_Intersects(a.geom, b.geom);

    Result see figure 8
    enter image description here



    Everything from this day, now everyone will learn to bake delicious pies - fruit platter. Help yourself All, and choose the pieces you, likeenough for everyone.



    (P.S. It’s a pity that I really can’t feed all people, not with electronic cakes, but with real cakes, perhaps hunger would end on Earth ...)



    With you was Mr. good and fair Baker, thank you all and good luck, :-)... OS.






    share|improve this answer

























    • Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

      – Peter Krauss
      Apr 9 at 10:47











    • 1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

      – Cyril
      Apr 9 at 11:45












    • Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

      – Cyril
      Apr 9 at 12:08











    • By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

      – Cyril
      Apr 9 at 16:17











    • Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

      – Peter Krauss
      Apr 10 at 20:08













    1












    1








    1







    So, I will prepare a cake for you - fruit platter, using PostGis tools, as you requested, if I correctly understood the question, and as I mentioned, the responsibility for the operation of the PostGis oven is borne by her creative team.



    I will ask not to be offended by anyone in my humorous style and to understand it as a game!



    The original file is sliced fruit and simple shapes (hereinafter referred to as fruit), see Figure 1 below.



    enter image description here



    Here is my recipe, and I will be helped in this by dear programmers, whom you will learn about later.
    Let's begin, and for this we will create a dough in which our fruits will be laid, for which run the script:



    create table poly_extent as
    SELECT st_setsrid(ST_Buffer(ST_Envelope(ST_Extent(geom)),0.05),4326) as geom from poly;



    See the result in Figure 2 below



    enter image description here



    Now, if there are few fruits, like in my picture, create the border of the external buffer on the fruit, or if there are many fruits, create the border of the negative buffer, for which run the script:



    create table poly_buff_dump as
    SELECT ((ST_Dump(ST_Boundary(ST_Union(ST_Buffer((geom),0.01, 'join=mitre mitre_limit=5.0'))))).geom) geom from poly;



    And slice the buffer lines around each fruit



    update poly_buff_dump SET geom=ST_RemovePoint(geom, ST_NPoints(geom)-1)
    WHERE ST_IsClosed(geom)=true;

    See the result in Figure 3 below



    enter image description here



    (Actually, I thought that as a result I would get broken lines (such as in a circle), but if the figures are difficult, sometimes breaks are obtained, incorrect ones, for example, one side of the rectangle fell off, etc.)



    Then you need to divide the obtained lines in a convenient way for you into equal segments and extract points from them




    create table poly_buff_dump_pt as
    SELECT (ST_DumpPoints((geom))).geom geom from poly_buff_segm;

    Result, see Figure 4 below



    enter image description here



    Now run the Voronoi tool, in this place I used the tool suggested by the link MickyT :https://gis.stackexchange.com/a/172246/120129
    , as a result of which you will have created tables with the name “voronoi” for the fact that “my first assistant” is separate from the chef thanks from the chef! :-).



    The second way in this step is to run the ST_VoronoiPolygons function.



    Result, see Figure 5 below



    enter image description here



    Now, cut off the extra parts by running the script:



    create table poly_voronoi_cut as
    SELECT ST_Intersection (a.geom, b.geom) geom
    from voronoi a INNER JOIN poly_extent b ON ST_Intersects (a.geom,b.geom);

    Result, see Figure 6 below.



    enter image description here



    Now run the script in order to align the geodata type in LineString:



    create table poly_voronoi_dump as
    SELECT
    (ST_Dump(geom)).geom as geom
    FROM
    poly_voronoi_cut;

    And now I will ask "my second mate" to take up my duties and mix the cake wel (Jeff - https://gis.stackexchange.com/a/785/120129), leveling it in a single layer, and for that, thanks to me for it!



    CREATE TABLE poly_overlay_cut AS
    SELECT geom FROM ST_Dump((
    SELECT ST_Polygonize(geom) AS geom FROM (
    SELECT ST_Union(geom) AS geom FROM (
    SELECT ST_ExteriorRing(geom) AS geom FROM poly_voronoi_dump) AS lines
    ) AS noded_lines
    )
    );

    Now it’s time for me to get to work, for which I run the script:



    create table poly_voronoi_union as
    SELECT b.id, (ST_ConvexHull(ST_Union(a.geom, b.geom))) geom
    from poly_overlay_cut a INNER JOIN poly_buff_dump b ON ST_Intersects(a.geom,b.geom)
    group by b.id, a.geom, b.geom;

    and another script:



    create table poly_voronoi_union_area as
    SELECT ST_Union(ST_ConvexHull(ST_BuildArea(geom))) as geom from poly_voronoi_union
    group by id;

    see figure 7 below



    enter image description here



    As you can see in the picture, our cuts have small layers, which can be removed, as an option using ST_SnapToGrid (or in another way):



    And finally, we will cut out our baked fruit from our pie, I even got a little tired standing by the oven, :-)



    create table polygon_voronoi_result as
    SELECT
    (ST_Dump(ST_Difference(a.geom, b.geom))).geom as geom
    FROM poly_voronoi_union_area_snap as a JOIN poly b ON ST_Intersects(a.geom, b.geom);

    Result see figure 8
    enter image description here



    Everything from this day, now everyone will learn to bake delicious pies - fruit platter. Help yourself All, and choose the pieces you, likeenough for everyone.



    (P.S. It’s a pity that I really can’t feed all people, not with electronic cakes, but with real cakes, perhaps hunger would end on Earth ...)



    With you was Mr. good and fair Baker, thank you all and good luck, :-)... OS.






    share|improve this answer















    So, I will prepare a cake for you - fruit platter, using PostGis tools, as you requested, if I correctly understood the question, and as I mentioned, the responsibility for the operation of the PostGis oven is borne by her creative team.



    I will ask not to be offended by anyone in my humorous style and to understand it as a game!



    The original file is sliced fruit and simple shapes (hereinafter referred to as fruit), see Figure 1 below.



    enter image description here



    Here is my recipe, and I will be helped in this by dear programmers, whom you will learn about later.
    Let's begin, and for this we will create a dough in which our fruits will be laid, for which run the script:



    create table poly_extent as
    SELECT st_setsrid(ST_Buffer(ST_Envelope(ST_Extent(geom)),0.05),4326) as geom from poly;



    See the result in Figure 2 below



    enter image description here



    Now, if there are few fruits, like in my picture, create the border of the external buffer on the fruit, or if there are many fruits, create the border of the negative buffer, for which run the script:



    create table poly_buff_dump as
    SELECT ((ST_Dump(ST_Boundary(ST_Union(ST_Buffer((geom),0.01, 'join=mitre mitre_limit=5.0'))))).geom) geom from poly;



    And slice the buffer lines around each fruit



    update poly_buff_dump SET geom=ST_RemovePoint(geom, ST_NPoints(geom)-1)
    WHERE ST_IsClosed(geom)=true;

    See the result in Figure 3 below



    enter image description here



    (Actually, I thought that as a result I would get broken lines (such as in a circle), but if the figures are difficult, sometimes breaks are obtained, incorrect ones, for example, one side of the rectangle fell off, etc.)



    Then you need to divide the obtained lines in a convenient way for you into equal segments and extract points from them




    create table poly_buff_dump_pt as
    SELECT (ST_DumpPoints((geom))).geom geom from poly_buff_segm;

    Result, see Figure 4 below



    enter image description here



    Now run the Voronoi tool, in this place I used the tool suggested by the link MickyT :https://gis.stackexchange.com/a/172246/120129
    , as a result of which you will have created tables with the name “voronoi” for the fact that “my first assistant” is separate from the chef thanks from the chef! :-).



    The second way in this step is to run the ST_VoronoiPolygons function.



    Result, see Figure 5 below



    enter image description here



    Now, cut off the extra parts by running the script:



    create table poly_voronoi_cut as
    SELECT ST_Intersection (a.geom, b.geom) geom
    from voronoi a INNER JOIN poly_extent b ON ST_Intersects (a.geom,b.geom);

    Result, see Figure 6 below.



    enter image description here



    Now run the script in order to align the geodata type in LineString:



    create table poly_voronoi_dump as
    SELECT
    (ST_Dump(geom)).geom as geom
    FROM
    poly_voronoi_cut;

    And now I will ask "my second mate" to take up my duties and mix the cake wel (Jeff - https://gis.stackexchange.com/a/785/120129), leveling it in a single layer, and for that, thanks to me for it!



    CREATE TABLE poly_overlay_cut AS
    SELECT geom FROM ST_Dump((
    SELECT ST_Polygonize(geom) AS geom FROM (
    SELECT ST_Union(geom) AS geom FROM (
    SELECT ST_ExteriorRing(geom) AS geom FROM poly_voronoi_dump) AS lines
    ) AS noded_lines
    )
    );

    Now it’s time for me to get to work, for which I run the script:



    create table poly_voronoi_union as
    SELECT b.id, (ST_ConvexHull(ST_Union(a.geom, b.geom))) geom
    from poly_overlay_cut a INNER JOIN poly_buff_dump b ON ST_Intersects(a.geom,b.geom)
    group by b.id, a.geom, b.geom;

    and another script:



    create table poly_voronoi_union_area as
    SELECT ST_Union(ST_ConvexHull(ST_BuildArea(geom))) as geom from poly_voronoi_union
    group by id;

    see figure 7 below



    enter image description here



    As you can see in the picture, our cuts have small layers, which can be removed, as an option using ST_SnapToGrid (or in another way):



    And finally, we will cut out our baked fruit from our pie, I even got a little tired standing by the oven, :-)



    create table polygon_voronoi_result as
    SELECT
    (ST_Dump(ST_Difference(a.geom, b.geom))).geom as geom
    FROM poly_voronoi_union_area_snap as a JOIN poly b ON ST_Intersects(a.geom, b.geom);

    Result see figure 8
    enter image description here



    Everything from this day, now everyone will learn to bake delicious pies - fruit platter. Help yourself All, and choose the pieces you, likeenough for everyone.



    (P.S. It’s a pity that I really can’t feed all people, not with electronic cakes, but with real cakes, perhaps hunger would end on Earth ...)



    With you was Mr. good and fair Baker, thank you all and good luck, :-)... OS.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 9 at 8:26

























    answered Apr 8 at 11:35









    CyrilCyril

    1,1521216




    1,1521216












    • Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

      – Peter Krauss
      Apr 9 at 10:47











    • 1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

      – Cyril
      Apr 9 at 11:45












    • Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

      – Cyril
      Apr 9 at 12:08











    • By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

      – Cyril
      Apr 9 at 16:17











    • Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

      – Peter Krauss
      Apr 10 at 20:08

















    • Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

      – Peter Krauss
      Apr 9 at 10:47











    • 1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

      – Cyril
      Apr 9 at 11:45












    • Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

      – Cyril
      Apr 9 at 12:08











    • By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

      – Cyril
      Apr 9 at 16:17











    • Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

      – Peter Krauss
      Apr 10 at 20:08
















    Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

    – Peter Krauss
    Apr 9 at 10:47





    Hi, good illustrations, and seems good result (!). Suggestion to a brief discussion, see @geogeek solution, the steps in QGis seems the main steps of PostGIS here... Why e need ST_Buffer and ST_ConvexHull? There are an alternative algorithm?

    – Peter Krauss
    Apr 9 at 10:47













    1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

    – Cyril
    Apr 9 at 11:45






    1) See, ST_Buffer and on polygons are created in order to reduce the separation lines between the original figures during the application of the Voronoi function, therefore, the larger the buffer size you can specify, the more smoothly the separation lines will be built as a Voronoi function ... 2) ST_ConvexHull from the multitude of figures on each polygon, the polygon we need ... 3) Today, this is my vision of solving your question, I don’t know what will happen to all of us and our decisions in the future ...

    – Cyril
    Apr 9 at 11:45














    Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

    – Cyril
    Apr 9 at 12:08





    Another important value of the buffer lines is that they will help us select fragments from the result of the function of the Voronoi to create combined polygons for each shape ...

    – Cyril
    Apr 9 at 12:08













    By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

    – Cyril
    Apr 9 at 16:17





    By the way, I welcome the improvement of the code and approach, so that they do not worsen the result ...

    – Cyril
    Apr 9 at 16:17













    Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

    – Peter Krauss
    Apr 10 at 20:08





    Hi Cyril, I agree that ST_Buffer is a good option to normalize the contour lines, perfect (!). About ST_ConvexHull, is only a curiosity, what kind of results we can obtain after Figure 6, poly_voronoi_union without ST_ConvexHull.

    – Peter Krauss
    Apr 10 at 20:08













    5














    Postgis do not have a dedicated function for voronoi, but Qgis contains vornoi function which could make voronoi polygons from points, so using qgis i've followed the following steps to have these result:



    -make points from polygons using extract nodes functions.



    -make vornoi polygons using voroi functions in Qgis.



    -make a spatial join in Qgis.



    -dissolve results.



    enter image description here






    share|improve this answer

























    • Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

      – Peter Krauss
      Oct 27 '15 at 17:50












    • I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

      – FelixIP
      Dec 1 '16 at 21:39















    5














    Postgis do not have a dedicated function for voronoi, but Qgis contains vornoi function which could make voronoi polygons from points, so using qgis i've followed the following steps to have these result:



    -make points from polygons using extract nodes functions.



    -make vornoi polygons using voroi functions in Qgis.



    -make a spatial join in Qgis.



    -dissolve results.



    enter image description here






    share|improve this answer

























    • Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

      – Peter Krauss
      Oct 27 '15 at 17:50












    • I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

      – FelixIP
      Dec 1 '16 at 21:39













    5












    5








    5







    Postgis do not have a dedicated function for voronoi, but Qgis contains vornoi function which could make voronoi polygons from points, so using qgis i've followed the following steps to have these result:



    -make points from polygons using extract nodes functions.



    -make vornoi polygons using voroi functions in Qgis.



    -make a spatial join in Qgis.



    -dissolve results.



    enter image description here






    share|improve this answer















    Postgis do not have a dedicated function for voronoi, but Qgis contains vornoi function which could make voronoi polygons from points, so using qgis i've followed the following steps to have these result:



    -make points from polygons using extract nodes functions.



    -make vornoi polygons using voroi functions in Qgis.



    -make a spatial join in Qgis.



    -dissolve results.



    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 27 '15 at 14:23

























    answered Oct 27 '15 at 9:20









    geogeekgeogeek

    3,04232672




    3,04232672












    • Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

      – Peter Krauss
      Oct 27 '15 at 17:50












    • I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

      – FelixIP
      Dec 1 '16 at 21:39

















    • Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

      – Peter Krauss
      Oct 27 '15 at 17:50












    • I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

      – FelixIP
      Dec 1 '16 at 21:39
















    Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

    – Peter Krauss
    Oct 27 '15 at 17:50






    Nice solution (!), and thanks the illustration. Can you enhance it? See the left rectangle below, it was 4 points at Voronoi, and the center of rectangle have no representantion, distorting its region (losting are to the triangle)... Perhaps enhance is possible doing a regular sampling of each polygon... and perhaps also some interior points.

    – Peter Krauss
    Oct 27 '15 at 17:50














    I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

    – FelixIP
    Dec 1 '16 at 21:39





    I use densify tool in ArcGIS. This significantly improves proximity polygons. +1

    – FelixIP
    Dec 1 '16 at 21:39











    2





    +50









    OK - Thought about this a little and found it was like something I have been looking at lately.



    Take your starting polys:



    enter image description here



    Generate a new attribute with a number (100 in my case)
    Use the Vector-> Research tools -> Random points inside polygons tool
    this will generate (100) points inside each polygon:
    enter image description here



    Then Vector-> Geometry tools -> Voronoi to generate polys based upon that point layer.



    enter image description here



    Now, you can use the Vector -> Spatial Query tool:
    Select the points that belong to one polygon (or one of the polygons)
    Use the spatial query tool to generate a selection of your voronoi polygons which apply to that polygon.
    Add an attribute to the voroni polygon which corresponds to the polygon of interest. (I just used 1,2,3,4)



    Now you can Vector-> Geoprocessing Tools-> dissolve based upon your new attribute.



    enter image description here






    share|improve this answer























    • Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

      – Peter Krauss
      Nov 30 '16 at 15:41











    • @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

      – Phil G
      Dec 1 '16 at 12:52












    • My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

      – Peter Krauss
      Dec 7 '16 at 13:42











    • Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

      – A.A
      Dec 7 '16 at 18:27















    2





    +50









    OK - Thought about this a little and found it was like something I have been looking at lately.



    Take your starting polys:



    enter image description here



    Generate a new attribute with a number (100 in my case)
    Use the Vector-> Research tools -> Random points inside polygons tool
    this will generate (100) points inside each polygon:
    enter image description here



    Then Vector-> Geometry tools -> Voronoi to generate polys based upon that point layer.



    enter image description here



    Now, you can use the Vector -> Spatial Query tool:
    Select the points that belong to one polygon (or one of the polygons)
    Use the spatial query tool to generate a selection of your voronoi polygons which apply to that polygon.
    Add an attribute to the voroni polygon which corresponds to the polygon of interest. (I just used 1,2,3,4)



    Now you can Vector-> Geoprocessing Tools-> dissolve based upon your new attribute.



    enter image description here






    share|improve this answer























    • Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

      – Peter Krauss
      Nov 30 '16 at 15:41











    • @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

      – Phil G
      Dec 1 '16 at 12:52












    • My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

      – Peter Krauss
      Dec 7 '16 at 13:42











    • Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

      – A.A
      Dec 7 '16 at 18:27













    2





    +50







    2





    +50



    2




    +50





    OK - Thought about this a little and found it was like something I have been looking at lately.



    Take your starting polys:



    enter image description here



    Generate a new attribute with a number (100 in my case)
    Use the Vector-> Research tools -> Random points inside polygons tool
    this will generate (100) points inside each polygon:
    enter image description here



    Then Vector-> Geometry tools -> Voronoi to generate polys based upon that point layer.



    enter image description here



    Now, you can use the Vector -> Spatial Query tool:
    Select the points that belong to one polygon (or one of the polygons)
    Use the spatial query tool to generate a selection of your voronoi polygons which apply to that polygon.
    Add an attribute to the voroni polygon which corresponds to the polygon of interest. (I just used 1,2,3,4)



    Now you can Vector-> Geoprocessing Tools-> dissolve based upon your new attribute.



    enter image description here






    share|improve this answer













    OK - Thought about this a little and found it was like something I have been looking at lately.



    Take your starting polys:



    enter image description here



    Generate a new attribute with a number (100 in my case)
    Use the Vector-> Research tools -> Random points inside polygons tool
    this will generate (100) points inside each polygon:
    enter image description here



    Then Vector-> Geometry tools -> Voronoi to generate polys based upon that point layer.



    enter image description here



    Now, you can use the Vector -> Spatial Query tool:
    Select the points that belong to one polygon (or one of the polygons)
    Use the spatial query tool to generate a selection of your voronoi polygons which apply to that polygon.
    Add an attribute to the voroni polygon which corresponds to the polygon of interest. (I just used 1,2,3,4)



    Now you can Vector-> Geoprocessing Tools-> dissolve based upon your new attribute.



    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 30 '16 at 2:58









    A.AA.A

    318111




    318111












    • Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

      – Peter Krauss
      Nov 30 '16 at 15:41











    • @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

      – Phil G
      Dec 1 '16 at 12:52












    • My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

      – Peter Krauss
      Dec 7 '16 at 13:42











    • Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

      – A.A
      Dec 7 '16 at 18:27

















    • Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

      – Peter Krauss
      Nov 30 '16 at 15:41











    • @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

      – Phil G
      Dec 1 '16 at 12:52












    • My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

      – Peter Krauss
      Dec 7 '16 at 13:42











    • Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

      – A.A
      Dec 7 '16 at 18:27
















    Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

    – Peter Krauss
    Nov 30 '16 at 15:41





    Thanks @AAmes (!), the illustrations are good, and the method is a good alternative... But the question is about "a SQL algorithm (or some specific for PostGIS)" and now, the bounty about the use of the function ST_VoronoiPolygons(), that perhaps solve all problem in one click ;-)

    – Peter Krauss
    Nov 30 '16 at 15:41













    @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

    – Phil G
    Dec 1 '16 at 12:52






    @AAmes A quick search reveals that this method can indeed be used in PostGIS as well. How to create random points in a polygon in postgis explains the point creation from polygons and from there it should be fairly straight forward.

    – Phil G
    Dec 1 '16 at 12:52














    My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

    – Peter Krauss
    Dec 7 '16 at 13:42





    My bounty was to you, as incentive (welcome here!), but THIS ANSEWER IS WORNG for the question and bounty requirements.

    – Peter Krauss
    Dec 7 '16 at 13:42













    Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

    – A.A
    Dec 7 '16 at 18:27





    Thanks Peter, I saw your notes but unfortunately I have not had the opportunity to come back and address it. I don't have any experience in PostGIS yet and it would have taken me more time than I had available to give any kind of good response. I hope that our exploration of this space is helpful to people in the future, maybe If I get a crack at PostGIS soon I will come back and take another whack at it for practice!

    – A.A
    Dec 7 '16 at 18:27











    1














    Random points are a good idea to generate a voronoi polygon from polygons, it works pretty well, but it's pretty bad for polygons close to each other:
    enter image description hereenter image description here



    ST_ApproximateMedialAxis is another good alternative if using PostGIS:
    Calculating Voronoi Diagrams for polygons






    share|improve this answer



























      1














      Random points are a good idea to generate a voronoi polygon from polygons, it works pretty well, but it's pretty bad for polygons close to each other:
      enter image description hereenter image description here



      ST_ApproximateMedialAxis is another good alternative if using PostGIS:
      Calculating Voronoi Diagrams for polygons






      share|improve this answer

























        1












        1








        1







        Random points are a good idea to generate a voronoi polygon from polygons, it works pretty well, but it's pretty bad for polygons close to each other:
        enter image description hereenter image description here



        ST_ApproximateMedialAxis is another good alternative if using PostGIS:
        Calculating Voronoi Diagrams for polygons






        share|improve this answer













        Random points are a good idea to generate a voronoi polygon from polygons, it works pretty well, but it's pretty bad for polygons close to each other:
        enter image description hereenter image description here



        ST_ApproximateMedialAxis is another good alternative if using PostGIS:
        Calculating Voronoi Diagrams for polygons







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 17 '18 at 4:00









        LeoLeo

        1579




        1579



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f166143%2fcreate-mosaic-like-voronoi-diagram-from-disjoint-polygons%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221

            Creating closest line along the point''s azimuth using PostgreSQL Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Drawing line between points at specific distance in PostGIS?How to efficiently find the closest point over the dateline?How to find the nearest point by using PostGIS function?PostGIS nearest point with LATERAL JOIN in PostgreSQL 9.3+Creating a table and inserting selected streets using plpgsql functionsCreating a table that stores Distances and other columnSaving select query results (year wise) from PostgreSQL/PostGIS to text filesWhat is the information behind this geometry?How to give start and end vertex ids dynamically in pgr_dijkstra?Point to Polygon nearest distance DS_distance is not using geography index & knn <-> or <#> does not give result in orderLine to point conversion with start point and end point detection?

            Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given