7 Replies Latest reply on Nov 1, 2013 6:50 AM by Matt Lutton

    Mapping with Custom Polygons

    Justin Smith

      Hi all,


      I'm hoping you smart guys out there with mapping can help me out. I may be outside the scope of Tableau, and if so, I'm hoping you can get me on track with some advice. I have the task of determining where addresses fall within Senate and House Districts. I have the shapefiles for both, and am ultimately going to use Richard Leekes shapetotab to important them into Tableau for some display of the data.


      The first goal is to get aggregations by district, and then later use Tableau to visualize it. I figure I will have to get a latitude and longitude for each address (I actually have that part figured out).


      My problem is, I do not know how to easily turn them into which corresponding district they belong to. Once I get the shapes into Tableau, can I then map each address, and somehow aggregate the data?


      I'm thinking I may have to use some geocoding software to determine what district each address falls within. Any suggestions, tutorials, volunteers to do it for me? (Just kidding - I really am interested in learning this stuff)


      Thanks in advance,

      Justin Smith

        • 1. Re: Mapping with Custom Polygons
          Shawn Wallwork

          Justin, I'm just stopping by for a quick Sunday Afternoon Fun Ride, but it seems to me I remember congressional districts were recently added to Tableau geography as a 'native' geography, back during the election -- I could be wrong on this.


          --Tableau Tableua (aka Shawn)

          1 of 1 people found this helpful
          • 2. Re: Mapping with Custom Polygons
            Stephanie May

            Hi Justin,


            If you already have the latitude and longitude of each address, it sounds like what you need to do is a spatial join, e.g. add the house and congressional districts as data columns. You can do this in Quantum GIS, an open source GIS software package. Here is a tutorial on how:


            QGIS Workshop - Spatial Join


            Warning: there are potential pitfalls


            ... the greatest being that your shapefiles need to be defined in the same projection in order for the operation to work. You can check this by opening the .prj file associated with each shapefile in a text editor and comparing the text. If they are NOT in the same projection, you will need to reproject one or both files.


            Good luck!

            • 3. Re: Mapping with Custom Polygons
              Justin Smith



              That may be how I solved the problem (although not knowing what I did or that it was called a spatial join.)


              So as not to be that person that solves a problem and doesn't share, I will explain what I did in non-technical terms (since I don't know what they are, and it has been a while since I did it) for future reference.


              I opened the shape files I obtained from one of the state legislative branches using Quantum GIS. Then, I added another layer with the lat/lon of the addresses I had making sure they were on the same projection (WSG84 for some reason is stuck in my head although the order of those letters may be off). Finally, I was able to extract which points fell into each district by exporting from QGIS (sorry don't remember exactly what I did). Finally, I fed that list into Tableau to aggregate by district, and ultimately make a really cool document with contact info, the picture of the congressman, and stats for the number of our students that were in each district.


              PS I did this only for the Oklahoma districts.

              • 4. Re: Mapping with Custom Polygons
                Stephanie May

                Ok cool! It sounds like you found a solution and I'm glad to hear it.

                • 5. Re: Mapping with Custom Polygons
                  Matt Lutton



                  Would you mind sharing this workbook with me?  My email address is mluttonATgoodwilleducationDOTorg; thanks!

                  • 6. Re: Mapping with Custom Polygons
                    Justin Smith



                    I wouldn't mind at all, except the Tableau part of it didn't have anything to do with the actual locating students within districts. Basically I used QGIS to add a district number onto each row of student lat/lon information. Then, QGIS generated a CSV that I fed to Tableau to count the number within districts based on that CSV.



                    • 7. Re: Mapping with Custom Polygons
                      Matt Lutton

                      That's OK, I'd just like to see it as an example.  Please email me at my address if you can.