span8
span4
span8
span4
Density Maps are a great way to visualize data quickly.In this exercise we will go over how to create three different kinds of density maps;HexBin,Grid,and Dot Grid.All three of these map styles combine similar points into a bin.We will create all three maps in one workspace using bookmarks to toggle each 亚搏在线workflow on and off.
Source data:business-licenses.csv
Complete workspace:exercise4-densitymaps.fmwt
Tableau templates:exercise4-tableau.zip
Add a CSV reader with the following input:
Reader Format: | CSV (Comma Separated Value) |
Reader Dataset: | ...\business_licenses.csv |
Click parameters,change AttributeDefinition to manual,set the Longitude to the x_coord and the Latitude to the y_coord.Click ok,then set the Coord.System to LL84.Click ok to add the reader to the workspace.
Add a Reprojector transformer,and set the Destination Coordinate System: to UTM83-10.Connect it to the CSV Reader.
Add the GeometryFilter to remove any points that do not have a latitude and longitude.Set the Geometries Types to Filter to Point.Connect this to the Reprojector.
TheHexBinnertransformer is a custom transformer.It creates hexagonal features that enclose point feature input.They aggregate data into a grid and can be used for further analysis.
We are going to create a HexBin that is one kilometer in size.Add the HexBinner to the workspace,you will notice that it is green,while the other transformers we've seen before have been blue.When a transformer is green it means it is a custom transformer.In the parameters for the HexBinner,change the Tile Size to 1,并确保单位将公里。Connect the Input port to the Point Output port on the GeometryFilter.
Set the Tile Size to 1 and ensure the units are set to Kilometers
Connect an Inspector to the Output port on the HexBinner.In the Data Inspector,you should see a grid of hexagons.Clicking on a hexagon,you can see how many business licenses are in each section.
Inspect the HexBinner Transformer in the Data Inspector.All the points appear grouped in hexagons
We would like to determine which businesses are in each bin,not just a count.To do this we will add the Counter transformer.For the Count Output Attribute,name it HexBinId,then accept the defaults for the rest of the parameters.Click ok.Connect the Counter to the HexBinner Output port.
Now add the PointOnAreaOverlayer to add the HexBinId to each of the points.Connect the Counter Output port to the Area Input port on the PointOnAreaOverlayer.Then Connect the GeometryFilter Point Output port to the PointOnAreaOverlayer Point Input port.
Add a Tableau Data Extract (TDE) writer and set it to your Outputs folder,also set the Feature Type Definition to Automatic...
Change the Feature Type properties,name the table HexBins,and the Geometry to tde_polygon.Click ok.
Connect this writer to the Output port on the Counter Transformer.
Then right click on the canvas click "Insert Writer Feature Type...".Add another writer for the point data.Name this one Businesses and change the geometry to tde_point.Connect this writer feature type to the PointOnAreaOverlayer Point port.Finally,to tidy up the workspace and allow us to enable/disable this translation,add a bookmark from Hexbinner onwards.To create a bookmark,select everything you would like to add to the bookmark and then right click on the workspace and click Insert Bookmark.
Final translation layout,ensure your writers are pointed to the correct output ports
While running the translation,if you encounter a Rejected Error,either connect a logger to each Rejection Output port,or in the Navigator > Workspace Parameters > Translation > Rejected Feature Handling,set it to Continue Translation.
In Tableau,join together both the HexBins and Businesses tables.In your sheet,double click on the geometry measure from the HexBins extract.Then drag _numPoints to Color to color the HexBins by the number of businesses in each.
A hex bin map completed and styled in tableau.
Right click on the Hexbinner bookmark and click disable.Now when we run our new translation,this translation branch won't run.
Add the 2DGridAccumulator to the Point Output port on the GeometryFilter.In the parameters set both the Column Width (ground units) and Row Height (ground units) to 500.This will be the size of our grid.If you have time,try setting it to 250 or 750 just to see what the results look like.Then set the Type of Grid to Create to Polygons.This will create a square grid with lines.Again if you have time,experiment with Points (Corners) and Points (Centers).Once you have set your values,accept the defaults for everything else,and click ok.
Set Column Width and Row Height to 500,and set the Type of Grid to Created to Polygons
Connect an inspector to the Grid Output port to view the results.In the Data Inspector under the Display Control,click the properties for the 2DGridAccumulator_Grid.Then change the Fill Opacity to 0,and increase the Pen Width to 3.Click ok.If you would like to add a background map,click on Tools > FME Options...Then under Background Map,change the Background Format to Stamen Maps.This is the free background map service that comes with FME.Then click on Parameters...to set the Map List.The example is using Terrain,but you can use the one you like the best.Click ok.
Zoom in to see the background map inside each of the individual squares of the grid.
Inspect the 2DGridAccumulator in the Data Inspector.Change the drawing styles to view the background map
Change the Pen Width to 3,and the Fill Opacity to 0
Now we need to determine how many of our business license points fall within each grid square.To do this we will add the PointOnAreaOverlayer.
Open up the parameters,let's change the name of Overlap Count Attribute to NumPoints.Click ok.Connect the Area Input port to the Grid Output port,and the Point Input port to the Point Output port on the GeometryFilter.
We are only interested in the attribute NumPoints,so we will add the AttributeKeeper transformer to the Area Output port on the second PointOnAreaOverlayer.The AttributeKeeper works just like the AttributeManager,but it is more efficient if you only want to keep certain attributes.Open up the AttributeKeeper parameters,then under Attributes to Keep,select NumPoints.
Only keep the NumPoints attribute
It is a good idea to double check your results after adding or subtracting attributes to ensure that the data you want is present and you've removed the data you don't want.Add an Inspector to the Output port on the AttributeKeeper.Confirm in the Table View,that the only attribute is NumPoint and that it has values.You might have to scroll to see values other than 0 since our grid covers ocean,there will be a lot of zeros.
As you can see,there are a lot of zeros.We have no need to display those,so let's remove them to tidy up our grid.Add a Tester transformer to the Output port of the AttributeKeeper.Then set it to Numpoints > 0.Now our grid will only display squares with values other than 0.
Finally,we need to write our grid to Tableau.Right click on the workspace canvas and click Insert Writer Feature Type,then change the Table Name to GridMap,and set the Geometry to tde_polygon.Finally,connect it to the Passed Output port on the Tester transformer and run the translation.
For this branch of the translation,we will only bookmark our writer called GridMap,this is because we will reuse all of the other transformers for the Dot Grid Map translation.Select the writer and either right click on the canvas to add the bookmark or use the keyboard shortcut ctrl-B .
Open up GridMap.tde in Tableau.In a new sheet,double-click on the geometry Measure to show the polygons in a map.Then drag NumPoints to Color to show the density of businesses in the area .
Grid Map styled in Tableau
For the final map,we will be reusing all of our transformers that are not already in a bookmark.Ensure all the other bookmarks are disabled.
To create the Dot Grid Map,we only need to add a couple of things to our previous translation.Add a CenterPointReplacer transformer to the Passed Output port on the Tester.This will find the center point of the polygon square we created with the 2DGridAccumulator and turn it into a point.
Complete translation for the Dot Grid Map.Add the CenterPointReplacer after the Tester
Right click on the canvas to Insert Writer Feature Type,then change the Table Name to DotMap,and then change the Geometry to tde_point.Click ok and run the translation.Add another bookmark containing the CenterPointReplacer and the DotMap writer.
Open up GridMap.tde in Tableau.In a new sheet,double-click on the geometry to create a map.Add NumPoints to Size.On the sidebar,a legend with the sizes appears.Double-click it to open the size properties,increase the minimum and maximum dot size to increase the exaggeration.To change the appearance of the Dot Map,create a color grouping for NumPoints then add it to Colors.
Dot Grid map styled in Tableau.Map shows both the color and size scale for the number of businesses
How to Write Spatial Data into Tableau with FME
Reprojection and Spatial Overlay with FME
Creating Spider Diagrams with FME for Tableau
Tutorial: Preparing Data in FME for Tableau
How to Prepare Data for Tableau with FME (Processing Spreadsheets)
How to Prepare Data for Tableau with FME (Merging Multiple Spreadsheets)
Tutorial: GIS and Business Intelligence Data Wrangling
Blocking Transformers and the Flow of Features
Dynamic 亚搏在线Workflows: Destination Schema is Derived from an External Dataset
©2019安全亚搏在线软件公司|Legal