13 Replies Latest reply on Jun 13, 2018 6:44 AM by naresh.suglani.0

    Create custom polygons in Tableau?


      Hi all, I have an existing polygon file as shown below which includes the Point ID, Polygon ID and Sub Polygon ID (highlighted in green) necessary to generate a polygon map in Tableau. This creates a map of 406 small UK regions (local authorities). I manually grouped these together into 11 large regions (highlighted in yellow).


      Polygon file.jpg


      When I select any of the new regions on the map it still highlights the smaller region selected.


      Can I modify the original polygon file using Tableau so the map only shows the new 11 regions or do I need to use some other software?


      If so what do I need to use?


      If anyone can do this for me with some bespoke software I can then use the custom regions for all future mapping work.

        • 1. Re: Create custom polygons in Tableau?
          Joe Macari

          Hi Naresh,


          Are you able to send a screen shot of your worksheet (including the marks card).


          I suspect you may have the local authority field on the detail where you only need the manual Region field.



          • 2. Re: Create custom polygons in Tableau?
            Simon Runc

            hi Naresh,


            What version of Tableau are you using? The reason I ask is that with the new shapefile support this is very possible, without too much work (and assuming you created this polygon file from an original shapefile, which you still have)


            In the attached I've loaded a shapefile, with 3 regions (Scotland, Wales and NI). I've then joined it to an Excel lookup table mapping those regions to a grouping




            I can then just use this field in the detail level.


            Within Tableau, and with custom polygons, I think the best you can do is set up a highlight action, which uses your new field (I've done this on the Original Tab), so the whole group is highlighted when any part is selected, but you'll constantly be fighting this (with regards calculations of values, which would need to be an LoD or Table Calculation)



            Outside Tableau. I'm no expert in this, but you can "merge" polygons in QGIS (they have a pretty good forum where I've seen step-by-step instructions to do this), but you'd probably need to do this via the original shape-file. If you are familiar with Python, I also think, this could be done with one of the geometric-libraries (I've found Geopandas, quite flexible), but again I'm no expert.


            Hope one these does the trick.

            • 3. Re: Create custom polygons in Tableau?

              Hi guy thanks for replying. I've attached my original polygon file and also a quick workbook showing the new regions on one tab as I want them displaying as just the 11 new regions (as separate polygons), and the way they show originally in the 406 individual local authorities.


              If my custom regions (Dignity regions) can be concerted and displayed as only 11 polygons that would be perfect.


              I've not used QGIS before and don't have access to it at work unfortunately to play with.


              I'm hoping someone can knock this up for me to use a custom polygon file to share amongst the wider business.

              • 4. Re: Create custom polygons in Tableau?
                Simon Runc

                hi Naresh,


                Do you have the original Shapefile? (or a link to it on the ONS Geography site, or where you found it)...and then I should be able to create the custom polygons, as per my method (I gave before)

                • 5. Re: Create custom polygons in Tableau?

                  Hi Simon, the problem is that this didn't originate from a shapefile - it came from a Tableau TDE from this website.......


                  [UK] Local Authority Districts « Tableau Mapping


                  I've attached it here too.


                  If it helps I can try and find a shapefile version of the local authorities and upload it here later on?

                  • 6. Re: Create custom polygons in Tableau?

                    Hi Simon,


                    Just found a shape file of the GB local authorities, which I'm hoping can be used as lookup to the LA's I've grouped in my polygon file to create my custom regions. I've attached the shapefiles here for you.


                    Hopefully you can work some magic on these for me.

                    • 7. Re: Create custom polygons in Tableau?
                      Simon Runc

                      So I need the full shapefile (the .shp is just one of the files in the set), but not to worry that was enough for me to find a version (on line)




                      So after downloading (and extracting) this I connected it to Tableau.


                      I then using your Excel, created a unique list of LA Names to Dignity Names (I just took your 2 columns and de-duped them)



                      I then added this as a data source and joined on the LA Name. I could only find a 2015 LA file, so you may need to do this with your 2017 version as any names that have chnaged (or been added) may not have a dignity mapping)



                      And then we can use the new Dignity level on the map (the NULLs are the unmapped ones)....but hopefully you get the idea.


                      • 8. Re: Create custom polygons in Tableau?

                        Many thanks for this Simon, this is a lot closer to what I'm trying to achieve. I also appreciate that I need a more updated file to cancel out those nulls. Luckily there are not too many.


                        If I click or hover over a custom region then that whole region is highlighted..........BUT all the individual LA's that make up that region are also highlighted which is a pain not what I'd like as it's not a "clean" look.


                        I'm guessing that in order to achieve that I'll need some more advanced mapping software?

                        • 9. Re: Create custom polygons in Tableau?
                          Simon Runc

                          So unfortunately we can't do much about those LA boundaries directly in Tableau. For their "generated" geometry (like State/City...etc.) we have the option to make out own custom geographies


                          So in the below I could create a new Geography called region, but "combining" the States, but we don't get this (currently) for shapefiles



                          So yes you'd need to do this outside Tableau (as you can imagine, it's reasonably complicated to create new boundary long/lats by merging low level polygons). QGIS has a "dissolve" function, where I could just say "Dissolve the LAs into the Dignity Field". Also if you have any python knowledge I'm pretty sure you can do this in GEOPanada (not done it myself, but it does have a dissolve function Aggregation with dissolve — GeoPandas 0.3.0 documentation )

                          • 10. Re: Create custom polygons in Tableau?

                            Thanks Simon I may try and get this done at home then in my own time by downloading QGIS. I do have MapInfo at home as well so will see if that has an option to dissolve polygons.


                            As my original polygon file was in Excel which I simply imported into Tableau I was hoping I could simply create the larger polygons by manipulating the LA ID numbers but that didn't work but I'm not giving up on this.


                            Maybe version 2018.1 will come with new toys to play with which we'll be getting eventually.

                            • 11. Re: Create custom polygons in Tableau?
                              Simon Runc



                              Just to help you conceptually...the Excel Polygon file is just a "text" version of what's in the shapefile. If you could "look" into one of those geometry objects you'd see something like this


                              POLYGON ((476152.2005908086 183567.8035180642,...


                              This is a list of Long/Lats that make up the polygon (the Excel version just has each of these in a new row) and the order of the array is the order in which to plot them. Also notice the double bracket start...this is because a single area can be made up of sub-polygons (think of Scotland, and it;s islands....you need the polygon to start again for each island, else it would connect it to the mainland!). If you want to "dissolve" several polygons into one, you need to remove the "interior" lines, but keep anything making up the extent of the boundaries. This is why it needs specialist software!


                              I've found QGIS pretty easy to use (it has a lot of very advanced features, which I know nothing about!, but jut for simple polygon manipulation it's quite straight forward. There is a great community, like here...where there are simple to follow solution for tasks like this one.


                              The bit's you'll need are...load your Shapefile into QGIS (this also loads an information table), you can then "join" your Dignity column (QGIS is basically a database which returns queries in maps/rendered-graphics and not tables)...you can find how to join data on the QGIS community/help pages. Then you can use the Dissolve tool



                              This brings up a dialogue box...just move your "Dignity" column into the selected box and hit go (you can then output this new shapefile, as a shapefile...and you can load directly into Tableau)



                              There's a bit more to it than that, so check the QGIS community for full instructions, but that's the basic idea.

                              • 12. Re: Create custom polygons in Tableau?

                                Thanks Simon, looks fairly straight forward - I'm trying to get QGIS installed here at work which is now in IT's hands to authorise. Failing that I'll get it installed at home and have a play.

                                • 13. Re: Create custom polygons in Tableau?

                                  Hi Simon, I managed to crack this today by using the website below.




                                  It allows you to upload your shapefile, export it as a CSV to add your custom regions in a separate column then re-import and use the online tools to merge the original polygon names into new region names, then use a dissolve command to create the new regions.


                                  You then export this in whatever format, in my case as a shapefile, and vola - I now have a custom shapefile of my bespoke GB regions!


                                  I'm one happy bunny!

                                  1 of 1 people found this helpful