{"id":2007,"date":"2016-05-12T15:07:00","date_gmt":"2016-05-12T20:07:00","guid":{"rendered":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/?p=2007"},"modified":"2017-05-26T15:03:10","modified_gmt":"2017-05-26T20:03:10","slug":"creating-a-custom-polygon-map-for-connecticut-towns-in-tableau","status":"publish","type":"post","link":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/2016\/05\/12\/creating-a-custom-polygon-map-for-connecticut-towns-in-tableau\/","title":{"rendered":"Creating a custom polygon map for Connecticut towns in Tableau"},"content":{"rendered":"<p>This is the first\u00a0in a series of posts on using <a href=\"http:\/\/get.tableau.com\/trial\/data-analysis-software.html?cid=701600000005cS4&amp;ls=Paid%20Search&amp;lsd=Google%20AdWords%20-%20Tableau%20-%20Free%20Trial&amp;adgroup=Tableau%20-%20Analytics&amp;kw=tableau%20data%20analysis&amp;adused=98805906975&amp;distribution=search&amp;kcid=29f0d3e2-a43b-4600-a907-4ef474b003e6&amp;gclid=CMjEm-qDrc0CFU07gQodBLYK5g\" target=\"_blank\">Tableau Desktop<\/a> or <a href=\"https:\/\/public.tableau.com\/s\/\" target=\"_blank\">Tableau Desktop Public Edition<\/a> to\u00a0visualize\u00a0Connecticut data\u00a0with\u00a0custom polygons, which let Tableau\u00a0create filled maps for\u00a0geographic entities not recognized innately in the software&#8217;s mapping functionality. See these other posts for more information on\u00a0creating\u00a0choropleth\/filled maps for\u00a0Connecticut Census Tracts and school districts in Tableau:<\/p>\n<ul>\n<li><a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/2016\/06\/10\/mapping-connecticut-census-tract-data-in-tableau\/\" target=\"_blank\">Mapping Connecticut Census Tract data in Tableau<\/a><\/li>\n<li><a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/2016\/06\/16\/mapping-connecticut-school-district-data-in-tableau\/\">Mapping Connecticut School District Data in Tableau<\/a><\/li>\n<\/ul>\n<p>Tableau can instantly recognize and map the boundaries of many types of geographic entities (e.g. states, counties, countries) &#8211;\u00a0 but for states like Connecticut with town-based governments, displaying town-level data on a map in Tableau isn&#8217;t quite as easy. Fortunately, a workaround exists that allows Tableau users of town-level data to create custom polygons maps to represent these areas. Tableau support documentation on this feature includes <a href=\"http:\/\/kb.tableau.com\/articles\/knowledgebase\/tableau-polygons-arcgis-shapefiles\" target=\"_blank\">instructions on converting ArcGIS shape files<\/a> into spreadsheet files that Tableau can use to <a href=\"http:\/\/kb.tableau.com\/articles\/knowledgebase\/polygon-shaded-maps\" target=\"_blank\">construct custom polygon maps<\/a>.<\/p>\n<p>The Connecticut State Data Center has converted a number of <a href=\"http:\/\/www.census.gov\/geo\/maps-data\/data\/tiger-line.html\" target=\"_blank\">U.S. Census Bureau TIGER\/Line shape files<\/a> into polygon data files for use in Tableau, including polygon\u00a0 files for Connecticut towns, school district, Census tracts, and legislative district boundaries. If you would like to visualize Connecticut town-level data on a map (<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/2016\/05\/11\/educational-attainment-and-earnings-in-connecticut-towns\/\" target=\"_blank\">as in this dashboard<\/a>) in Tableau, this Excel workbook of Connecticut town polygons:<\/p>\n<p style=\"text-align: center\"><a href=\"https:\/\/drive.google.com\/file\/d\/0By5Y7_XnHrPtYnVHQU5TN3Q5c1k\/view?usp=sharing\"><strong>CT_Town_Polygons_for_Tableau.xlsx<\/strong><\/a><\/p>\n<p>contains a Polygon spreadsheet that will render a map of Connecticut towns in Tableau, and an additional sheet of town tax mill rate data that you can link with the polygon map (following the steps below, to create a choropleth map like this (click image to see full size):<\/p>\n<p style=\"padding-left: 30px\"><a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/8.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2038 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/8-300x190.jpg\" alt=\"8\" width=\"300\" height=\"190\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/8-300x190.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/8-1024x648.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/8-474x300.jpg 474w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/8.jpg 1308w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Each row of the Excel <strong>Polygon<\/strong> sheet describes a single point on the outline of a single Connecticut town\u2019s boundaries, with a field for longitude and latitude of the point. Another field for each row is Point Order, which tells Tableau in which order to \u2018connect the dots\u2019 to form each town\u2019s boundaries on the map. For example, Mansfield\u2019s shape has 208 points in the data set. Tableau draws each polygon by starting with the latitude and longitude of point 1, then continues drawing the shape until it gets to point 208, completing the outline of the town. The software does this for all 16,000+ points on the map instantly, whether in Tableau Desktop or Public, and map tools seem to work as quickly with a polygon map published to Tableau Public as any boundaries innately recognized in Tableau. Amazing, and really useful, functionality!<\/p>\n<h2><strong>Setting up the polygon map:<\/strong><\/h2>\n<ol>\n<li>Save a copy of the Excel workbook of Connecticut town polygons locally. In Tableau Public or Desktop, from the <strong>Data<\/strong> menu navigate to the workbook and drag the<strong> Polygons<\/strong> sheet into the data space. Click <strong>Go to Worksheet<\/strong> or open a new New Sheet on the task bar.<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2032 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/1-300x255.jpg\" alt=\"1\" width=\"300\" height=\"255\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/1-300x255.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/1-1024x870.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/1-353x300.jpg 353w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/1.jpg 1037w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Under <strong>Measures<\/strong> in the Data pane, drag <strong>Lo<\/strong><strong>ngitude<\/strong> to the <strong>Columns<\/strong> shelf. Note that the Aggregation for this pill should be <em>average<\/em>; i.e. the pill should say <strong>AVG(Longitude)<\/strong>. Aggregations can be changed if necessary (e.g. from Sum to Average) from the carrot menu for the measure in the rows or columns shelf.<\/li>\n<li>Drag <strong>Latitude<\/strong> to the<strong> Rows<\/strong> shelf. The aggregation should also be average (AVG) in the pill.<\/li>\n<li>In the<strong> Marks<\/strong> card, change the view type menu from <strong>Automatic<\/strong> to <strong>Polygon<\/strong><\/li>\n<li>If <strong>Pointorder<\/strong> appears in the <strong>M<\/strong><strong>easures<\/strong> pane, it must be converted to a Dimension &#8211; simply drag it from Measures to <strong>Dimensions<\/strong>. Then, drag <strong>Pointorder<\/strong> to <strong>Path<\/strong> on the <strong>Marks<\/strong> card. (Don&#8217;t panic, it is normal to see a strange Rorschach test-like image on the map at this stage! Until we tell Tableau that we want Town to be the level of detail, it&#8217;s plotting the average latitude\/longitude of each Pointorder value for all the rows in the data set, resulting in a bizarre polygon approximately where Madison is).<\/li>\n<li>Drag <strong>Town<\/strong> from <strong>Dimensions<\/strong> and place it on <strong>Color<\/strong> on the Marks card. (Select <strong>Add all members<\/strong> in the dialog window).<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2048 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/2-300x190.jpg\" alt=\"2\" width=\"300\" height=\"190\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/2-300x190.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/2-1024x649.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/2-474x300.jpg 474w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/2.jpg 1361w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>You should now see the outlines of all 169 Connecticut towns (click the image above to see the full view) and you can now\u00a0 link or join this base map to other data following steps in either Option 1 or Option 2 below.<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<p><!--more--><\/p>\n<p><!--more--><\/p>\n<p><!--more--><\/p>\n<h2><strong>Linking the custom polygon map to town-level data<\/strong><\/h2>\n<h4><strong>Option 1 \u2013 connecting separately to the data source<br \/>\n<\/strong><\/h4>\n<ol>\n<li>From the Data menu, <strong>New Data Source<\/strong><\/li>\n<li>Navigate again to the\u00a0 to the CT_Town_Polygons_for_Tableau.xlsx workbook. Drag the <strong>Sample data<\/strong> sheet into the data area. Then return to the sheet on the taskbar in Tableau where you created the map.<\/li>\n<li>Because the Sample data sheet has a <strong>Town<\/strong> column, Tableau should indicate that the new data sheet has been joined to the Polygon sheet by the common Town field (with the chain icon as in the Dimension pane below). If your data source has a variation on this field label (e.g. <em>County Subdivision <\/em>instead of Town)\u00a0 from the Data menu go to Edit Relationships and add a custom join based on the common fields)<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2049 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/3-300x189.jpg\" alt=\"3\" width=\"300\" height=\"189\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/3-300x189.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/3-1024x644.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/3-477x300.jpg 477w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/3.jpg 1372w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>\u00a0 In the map above, Town is on Color on the Marks card. We want to create a choropleth map based on the Millrate measure, but we want to keep Town in the visualization, letting Tableau that town is the unit of analysis or \u201clevel of detail\u201d. Move<strong> Town <\/strong>from<strong> Color <\/strong>onto<strong> Detail<\/strong> on the <strong>Marks<\/strong> card. You should see a the outline of the state but the state is changed to a solid color.<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2050 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/4-300x186.jpg\" alt=\"4\" width=\"300\" height=\"186\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/4-300x186.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/4-1024x636.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/4-483x300.jpg 483w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/4.jpg 1391w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>(If you like, you can show the borders of the towns as in the image above by selecting a Border color from the Color menu on the Marks card: Click Color, then under Effects change Border from Automatic to a color. This step isn\u2019t necessary, but illustrates that Tableau really is showing the individual towns at this point)<\/li>\n<li>Now drag the measure you want to show on the map, e.g.<strong> Millrate<\/strong> if you\u2019re using the Sample data, to <strong>Color <\/strong>on the Marks card.<strong><br \/>\n<\/strong><\/li>\n<\/ol>\n<p style=\"padding-left: 30px\"><a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2051 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/5-300x191.jpg\" alt=\"5\" width=\"300\" height=\"191\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/5-300x191.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/5-1024x651.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/5-472x300.jpg 472w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/5.jpg 1358w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Option 2 &#8211; join the polygon sheet with the data sheet<\/strong><\/p>\n<p>Joining the Polygon sheet with the data sheet is what Tableau recommends in its support pages and may improve performance with some data sets. (It may not be the best option if your data sheet includes data for multiple years for each town.)<\/p>\n<ol>\n<li>Drag down on the Data menu, and from the carrot menu for the <strong>Polygons (CT_Town_Polygons_for_Tableau)<\/strong> data source select Edit Data Source. Drag the <strong>Sample data<\/strong> sheet into the data workspace.<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/6.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2034 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/6-300x208.jpg\" alt=\"6\" width=\"300\" height=\"208\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/6-300x208.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/6-1024x709.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/6-433x300.jpg 433w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/6.jpg 1176w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Normally you will want to join the Polygon sheet with your data sheet using a Left join. Click on the venn diagram in the data workspace to bring up the Join dialog box. Click on the image illustrating Left join. The Polygon Data Source sheet should be joined to the Sample data sheet with the join clause <strong>Town = Town (Sample data)<\/strong>:<a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/71.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-2036 aligncenter\" src=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/71-300x211.jpg\" alt=\"7\" width=\"300\" height=\"211\" srcset=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/71-300x211.jpg 300w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/71-1024x720.jpg 1024w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/71-426x300.jpg 426w, https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/files\/2016\/05\/71.jpg 1184w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Hope these instructions are helpful \u2013 your comments, corrections or suggestions are welcomed!<\/p>\n<p>Steve Batt<br \/>\nsteven.batt@uconn.edu<\/p>\n<p>&nbsp;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>This is the first\u00a0in a series of posts on using Tableau Desktop or Tableau Desktop Public Edition to\u00a0visualize\u00a0Connecticut data\u00a0with\u00a0custom polygons, which let Tableau\u00a0create filled maps for\u00a0geographic entities not recognized innately in the software&#8217;s mapping functionality. See these other posts for &hellip; <a href=\"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/2016\/05\/12\/creating-a-custom-polygon-map-for-connecticut-towns-in-tableau\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":74,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/posts\/2007"}],"collection":[{"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/users\/74"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/comments?post=2007"}],"version-history":[{"count":4,"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/posts\/2007\/revisions"}],"predecessor-version":[{"id":2337,"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/posts\/2007\/revisions\/2337"}],"wp:attachment":[{"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/media?parent=2007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/categories?post=2007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs-dev.lib.uconn.edu\/outsidetheneatline\/wp-json\/wp\/v2\/tags?post=2007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}