5 Replies Latest reply on Nov 16, 2014 3:47 AM by Michael Crow

    Creating Polygon Map Donut Holes for Inner Polygons

    Michael Crow

      I'm trying to create a polygon map in Tableau out of a shapefile that has many polygons and many inner polygons. I understand from a post by Richard Leeke that the outer polygon needs to be drawn to create a kind of doughnut, so there's a hole in the middle. I understand how to do that manually. Trouble is, I haven't found an automated way to connect the point order for the outer and inner polygons so that Tableau can draw the doughnut.


      Based on my understanding/reading of the forum, it's not automated in @Richard Leeke's  Shape to Polygon tool, nor in @Mary Solbrig's R shapefile conversion tool. And, I don't have access to Alteryx. Someone who has ESRI and ET Geowizard (the free download) has tried to create a file to help me, but it does not deal with the inner polygon issue. I'm reluctant to go the route of setting up my own WMS or using Richard's TabGeoHack tool, at least at this point.


      I feel like I saw a post where @Allan Walker  indicated that ESRI and ET Geowizard combined can produce a file that handles this issue. Unfortunately, I can't find the post again. Does anyone know if this is true and, if so, how to do it? Alternately, does anyone know of another, automated way to create a polygon that accounts for the donut hole in the middle?

      Thanks in advance for any insights you can lend.

        • 1. Re: Creating Polygon Map Donut Holes for Inner Polygons
          Richard Leeke

          Hi Michael


          The issue is that the Tableau polygon mark type doesn't support inner polygons - all you can do is define a single closed loop, which will be filled. You can't get around that with any other tools.


          There are three approaches I've used for this, each with distinct drawbacks:


          1) Draw your inner polygons on top of your outer polygons in a different colour. That looks fairly ugly and it can be hard to layer all the polygons in the right order if there are many inner rings.

          2) Draw a single polygon where the boundary follows the outer boundary right around, but then before closing the loop cuts inside and traces the boundary of the inner ring in the opposite direction and then back out again to finish off. That looks a bit ugly with the "bridge" across to the inner ring (though with careful choice of colours you can pretty much hide that) and it can get extremely difficult to choose where to join to the inner rings. I really don't think this is a practical option if there is any complexity to the shapes.

          3) Use tabgeohack to take advantage of the fact that Tableau's geocoding does know about inner rings. Big downside there is that it is unsupported - and a recent update on Tableau Public which broke things is a timely reminder of why I generally advise against going this route.


          The third tab in the viz embedded at the top of my "Grow Your Own Filled Maps" thread demonstrates options 1) and 3). Here it is again. Note that the 1st 2 tabs in that viz are currently broken by the change I mentioned on Tableau Public, but for some reason I don't understand the 3rd tab is still working.



          I also demonstrated how to do approach 2) in this old thread which discusses some of the challenges with that approach in a bit more detail.

          1 of 1 people found this helpful
          • 2. Re: Creating Polygon Map Donut Holes for Inner Polygons
            Michael Crow

            Hi Richard,


            Thank you very much for the thorough reply. It appears that my hope for an automated solution for drawing those bridges  that you described in #2 of your post above is not yet solved. I think I will need to do it manually or sort the inner rings to the top, which is working okay but has drawbacks (as you have mentioned). (By the way, I believe I found an R script that will convert the shapefile into a Tableau-friendly format for drawing polygons, with a field that flags which polygons are "plugs" or "donut holes." This enables sorting the polygons on the map by that field, so that the holes are always on top, which makes the process a bit easier. I need to sort out and confirm the details a little bit more, but plan on posting info about that on the thread Mary has related to polygon mapping and R. I can cross reference here once I've done that.)


            I did consider using TabGeoHack, but I am very wary of its unsupported nature and the possibility that it might break at a very inopportune time. Still might go that route, but exploring other possibilities first. It's wonderful that you've made the tool available for us, though.


            Thanks again.



            • 3. Re: Creating Polygon Map Donut Holes for Inner Polygons
              Richard Leeke

              I realised I didn't explicitly mention the '--keepinner' flag on shapetotab. That includes separate polygons for each of the 'holes', along with an extra column which lets you identify which are outer and which are inner rings, which for simple shapes can give the sort order you need. It sounds as if that does pretty much the same as the R utility you mentioned.


              The reason I said that it isn't always possible to get the sort order right automatically is that for some shape files you will find that there are multiple levels of containership. Think of some land (outer ring) with a lake (inner ring) with an island (outer ring) on the lake with a lake on the island (inner ring) ... Simply sorting inner on top of outer means that you would hide the island underneath the lake.


              That type of scenario happens surprisingly often - though it all depends on the location and the level of detail you are mapping - may simply not be an issue for you.

              1 of 1 people found this helpful
              • 4. Re: Creating Polygon Map Donut Holes for Inner Polygons

                Hi Michael,


                As Richard alludes to, working with inner and outer rings is difficult.  But it's not impossible.  I (usually) export polygons using Richard's tool, but frequently I'll pre-process in ESRI/ET Wizards to give path order etc and then import into PostGIS.  A page worth browsing for handling complex polygons in PostGIS: http://www.spatialdbadvisor.com/postgis_tips_tricks/92/filtering-rings-in-polygon-postgis


                This topic is also hot sauce in D3: Polygon with inner ring plots without hole · Issue #1526 · mbostock/d3 · GitHub


                The main issue here is Tableau doesn't support "layering" (of foreground objects): you can "layer" two polygons using dual-axis for example, and you could use transparency and a color ramp; but:


                Tableau is now using leaflet.js for its rendering of background map objects (and you could always build your own custom TMS server). Vector support (i.e. Filled Maps) is really the way to go, but you are deep into tabgeohack for that if it really has to be in the foreground.



                1 of 1 people found this helpful
                • 5. Re: Creating Polygon Map Donut Holes for Inner Polygons
                  Michael Crow

                  Thanks, Richard for your follow-up reply. Luckily, I don't have multiple nested inner rings (I think), so at least the level of complexity is a bit easier.

                  And thanks, Allan for your extra suggestions and the links you sent. Sorry about my delay in replying – work got busy last week.