1 2 Previous Next 16 Replies Latest reply on Nov 14, 2017 9:50 AM by John Trevino

    overlaying two sets of data points on the same map

    Zach Leber

      Is it possible to map two sets of data points onto the same map and display them as separate mark types so they can be separately formatted?  In the attached screenshots I have schools and votes and would like to put them on the same map.  I can't even figure out how to join the data sources which both have latitude and longitude for all their data points.  I've also attached the workbook.

        • 1. Re: overlaying two sets of data points on the same map
          Joe Mako

          Attached is not a perfect solution, but it is close.


          The issue with the attached is there are two extra marks in the center, not really visible because they are sized very small, but they are there, and I do not have a way a to hide or filter them.


          Your other option is a double dual axis with multiple mark types, but you would need to use a static background image instead of using Tableau's built-in map backgrounds.


          So, this is not a great solution, but may be good enough.

          • 2. Re: overlaying two sets of data points on the same map
            Joe Mako

            With a bit more time, I was able to find a way to filter it so there are only the 28 marks you want (without the extra two marks in my previous post).


            This creates a very interesting setup of a table calculation that uses addressing from the "All" Marks Card, and partition on dimensions that exist on each Marks card, that way the marks that we want to keep will have a partition size of 1. So this method would not work if you only had one school or one precinct.

            • 3. Re: overlaying two sets of data points on the same map
              Richard Leeke

              Here's another way of avoiding those extra marks (which are located at the average latitude and average longitude for the null school and null precinct created by joining the two data sets together).


              Instead of having AVG(Latitude) and AVG(Longitude) on the shelves I just turned them into dimensions.  T5his avoids the marks at the average locations for the nulls.


              This actually displays 2 marks at each point, one with the real value we want and one null value for the other type.


              I had to swap the order of the two instances of Latitude on Rows in order to get the circles (for which Joe chose pie charts) on top of the squares.  The null pie charts don't show, whereas if the null squares are on top they cause a small square to appear on top of the circles.


              The one downside I can see with this approach is that when you hover the mouse over a square mark it sometimes displays the tooltip for the invisible pie chart on top.


              I don't really understand why that doesn't also happen in Joe's version - but I'm sure Joe will explain shortly.

              • 4. Re: overlaying two sets of data points on the same map
                Richard Leeke

                Joe has just walked me through his second posting a bit more off-line.  His way definitely gives a much better outcome - no phantom marks which break tooltips, etc - but it took Joe a bit of head scratching.

                • 5. Re: overlaying two sets of data points on the same map
                  Joe Mako

                  Here are some additional details:


                  - data set starts out as 7 schools and 21 precincts

                  - union'ed the data together (could be done before Tableau with data transformation or when connecting with custom SQL)

                  - union'ing the data creates 28 rows of data for Tableau

                  - the Latitude and Longitude fields are assigned a geographic row and with both out you get Tableau's built-in map background

                  - when you bring out one of those pills again, and set it to a dual axis, you go from 28 marks to 56 marks

                  - with this dual axis, you can now have multiple mark types (you now have three Marks cards, "All", "Lat" and "Lat 2")

                  - the pills for Latitude and Longitude can either be all AVG() or all continuous dimensions, it does not have an effect because "Location ID" (a distinct value for each location) is on the Level of Detail shelf for the "All" marks card.

                  - because each Marks card has its own Level of Detail shelf, you can have the "School" dimension on one and the "Precinct" dimension on the other

                  - additionally with the multiple mark types, you can assign different formatting and mark types to schools and precincts

                  - then, with the custom table calc "SIZE()" on the "All" marks card, and its compute using set to "Location ID", it will count the number of distinct "Location ID"s in the partition

                  - the partitioning is the other dimension pills on the worksheet, and in this case, "School" and "Precinct" are each only on one marks card so for one mark type "School" will be used for partitioning, and on the other mark type "Precinct" will be used for partitioning.

                  - this combination causes the marks that we want to keep to have a SIZE() of 1, and the marks that we want to filter away to have a Size of either 7 or 21

                  - the filter keeps only when the Size is 1, so we only see and interact with the 28 marks we want.


                  Richard's option is easier to understand and use, but it has the extra 28 undesired marks. My first attempt, had averaged the locations of the extra 7 and extra 21 into just 2 extra marks and was not ideal either.


                  Setting the mark type to "Pie" instead of "Circle" gets you a smaller mark on the view, so it looks invisible, and then setting the z-order of the marks, by arranging the pill order in the Rows shelf, Richard go the square marks to be behind the pie/circle marks, and the pie marks seem invisible on top of the squares because they are so small. If you change the pie mark type to a circle mark type, you will see that the red circles show on top of the squares in Richard's.

                  • 6. Re: overlaying two sets of data points on the same map
                    Zach Leber

                    Thank you Richard and Joe for your exhaustive analysis and examples as usual.  A few things appear obvious.

                    1. This would be a very useful feature (lots of data exists with common coordinates but different structure).

                    2. It is much too hard to do currently (few could or would bother with the custom data joins).

                    3. The user interface would be straightforward (join any data using common coordinates and allow multiple mark types).

                    4. My town is divided over property taxes (see workbooks) despite an even distribution of public schools and attendance.

                    • 7. Re: overlaying two sets of data points on the same map
                      Ryan Chase

                      Joe Mako

                      What is the advantage of Union-ing the data?  I'm facing a similar issue where I want to map both distribution centers and stores, with the ability to increase the diameter of the distribution centers (i.e. increasing their "reach" or "coverage") and see how many stores these distribution center's circles overlap (is this even possible?)  Currently, I've just used data blending to combine the Distribution Centers and the Stores using the distribution center number.  Perhaps this is why when I'm adding the second instance of the "Latitude" field to the row shelf, it's creating two maps and not overlaying the map as I'm expecting?  I'm also having an issue with showing the individual stores in the second map.  I've attached a sample workbook.

                      Thank you so much.  Very much appreciated!

                      • 8. Re: overlaying two sets of data points on the same map
                        Ryan Chase

                        After some experimenting, I've learned that UNIONing the latitudes and longitudes for both the origin records and the target records (in my case distribution centers and stores...in the above example it was schools and voting precincts), in the same columns is important.  By Unioning these two sets of records, their latitudes line up in a single column and their longitudes line up in a single column.  This way, it can create a single map, allowing you to overlay the points (if that's what you want to do).  You don't have to overlay the points by creating the duel axis if you don't want to, however.  Here is an example of a workbook that doesn't make use of the overlay (and therefore doesn't have multiple marks cards): Distance Mapping with Radius Filter

                        • 9. Re: overlaying two sets of data points on the same map
                          Robert Sinclair

                          Joe -


                          I came across this thread from 2011 as I searched for a solution to a current problem. I have no idea what the version of Tableau was when this thread was written, but I am curious if 10.3 offers a way a more direct way to address plotting data from two different data sources (with no field to join on)  on the same map.


                          I have two disparate data sources, with no common join fields, and I need to plot information from each on the same map.


                          One contains US Census data and plots CBSA numbers (Metropolitan areas, which Tableau supports), the other table contains store locations with Lat/Long. - there is not a common field between them.  On two separate worksheets I can easily plot each, but I need to plot them both on the same map.


                          Having never run into this issue before, I assumed it would be a snap in Tableau, which I now see is not the case.  You and Ryan discuss workarounds in an old version of Tableau, My question is have you come across a more straightforward way of accomplishing this in version 10.3?




                          • 10. Re: overlaying two sets of data points on the same map
                            Sarah Battersby

                            Hi Robert Sinclair,


                            You should be able to use a dual axis map to join your Census data and your table with lat/lon values.  I wrote up a set of instructions for making dual axis maps with various data sources and the 'Spatial file + CSV' section in here should help you out: Dual Axis Mapping - Many Ways


                            Let me know if you have problems with this and I'll see if I can help out.



                            Tableau Research

                            • 11. Re: overlaying two sets of data points on the same map
                              Robert Sinclair

                              Hi Sarah -


                              Thank you for responding to my post and for the info on working with dual

                              axis maps.  Using your blog post as a guide,  I am still having trouble

                              with working with the CBSA geocode for metro areas and getting everything

                              converted to be lat/log (generated). I've attached the packaged workbook to

                              see if you could show me how to get these two maps to be on one, if it is






                              On Fri, Aug 18, 2017 at 8:52 AM, Sarah Battersby <

                              • 12. Re: overlaying two sets of data points on the same map
                                Sarah Battersby

                                Hi Robert,


                                I've attached a workbook that I think does what you need...


                                I unioned your two CSV files together (this is a better option that the full outer join that I do on the blog post, but doesn't work with spatial data files.  This only worked since you had two CSV files)


                                Made two new calculated fields lat zn and lon zn - these give me a lat/lon value for every point and CBSA.  The CBSAs end up with 0,0 - but that doesn't matter here, because Tableau will still draw them in the right place


                                mapped the data using lat zn and lon zn, then set the map type to filled polygon


                                dropped a new copy of lat zn on rows to make the dual axis map


                                changed the second marks card to be a point symbol, added store number to color then right clicked on the Null and selected 'hide', then took store number back off color so that they would all be the same color (I just wanted to get rid of the points that would fall at 0,0 because they were rows that we only use to draw the CSBAs)



                                I hope that this helps!



                                Tableau Research

                                2 of 2 people found this helpful
                                • 13. Re: overlaying two sets of data points on the same map
                                  Robert Sinclair

                                  Thanks Sarah!!!   I really appreciate your help.  Just one more request,

                                  there was no file attached, just the .PNG, can you please resend me the

                                  corrections you made to my workbook.







                                  While on the topic, however:

                                  Overlaying two, or more, unrelated layers of data on the same map seems

                                  like it would be a common need, so I was really surprised when I learned

                                  this is not a straightforward process in Tableau.  Do you know of any plans

                                  at Tableau to make adding multiple layers of data to the same map an easier



                                  On Sat, Aug 19, 2017 at 3:10 PM, Sarah Battersby <

                                  • 14. Re: overlaying two sets of data points on the same map
                                    Sarah Battersby

                                    Hi Robert,


                                    I see an attachment on the message - just look at the bottom of the message for the little box with a paperclip on it - looks like this:

                                    You should be able to just click on the 'stores_csba.twbx' text and the file should download.


                                    As for your comment on layers - yes, that would make this process much nicer.  We definitely have layering on our radar.



                                    1 2 Previous Next