Join Spatial Files in Tableau
You can use spatial data to create maps or other chart types in Tableau. If you have two spatial data sources, you can join them using their spatial features (geography or geometry). You can either join two spatial files together or use a spatial calculation to join a spatial file with non-spatial data that includes latitude and longitude fields.
Tableau supports connection to the following spatial data sources:
- MapInfo tables
- Keyhole Markup Language (KML) files
- GeoJSON files
- TopoJSON files
- Esri File Geodatabases
If you have WKT (well known text) in a CSV or Excel file, you can import the data and then translate it to spatial data on the Data Source page. You can also use MAKEPOINT to convert data that has latitude and longitude coordinates into spatial data. See Create a spatial data source using MAKEPOINT.
For more information on the types of spatial files you can connect to in Tableau, and how to connect to them, see the Spatial File connector example.
Important note: In Tableau 2021.3 or later, you can create spatial joins between point/polygon, polygon/line, polygon/polygon, and line/polygon features. In Tableau 2021.2 and earlier versions, you can only create spatial joins between points and polygons.
Tip: To create, edit, or view spatial joins, you must first open a logical table in the relationship canvas—the area you see when you first open or create a data source—and access the join canvas.
Open Tableau and connect to the first spatial data source.
Open the join canvas for your data source by double-clicking the table on the canvas to open the join canvas (physical layer).
On the upper-left side of the Data Source page, under Connections, click Add.
In the Add a Connection menu that appears, connect to your second data source. Drag the second data source onto the join canvas.
Click the Join icon.
In the Join dialog box that appears, do the following:
Select a join type.
For more information about each of these types, see Join Your Data.
Under Data Source, select a spatial field to join by.
Note: Geometry is the default field name for spatial file sources except in SQL Server, where users create field names. Spatial fields have a globe icon next to them.
For the second data source, select another spatial field. If your second data source isn't a spatial file and contains latitude and longitude fields, select Create Join Calculation as the join clause so that your data can be used in a spatial join. For more information, see Spatial Functions.
Click the = sign and then select Intersects from the drop-down menu. You can only intersect two spatial fields.
When finished, close the Join dialog box.
The map updates to show the count of waterfowl sightings in each basin, and you’re ready to start analyzing your spatial data.
For more information on building different chart types, see Build Charts and Analyze Data.
SQL Server error: Geometry is incompatible with geography
Although SQL Server supports both a geography and a geometry data type, Tableau only supports geography data type from SQL Server from the following geographies: EPSG:WGS84 = 4326, EPSG:NAD83 = 4269, EPSG:ETRS89=4258. If you try to add a different geography, or a geometry field from SQL Server to your analysis, you’ll receive an error.
Different spatial systems may order their vertices differently. If two spatial files contain two different vertex orders, it may cause problems with your analysis. Tableau interprets ordering specification according to the order of the spatial data source.
For more information, see Spatial Join Slow and Returns Inverted Results Using KML or SQL Spatial Data Imported from Shapefile or GeoJSON and Supporting advanced spatial analytics with changes to lines and polygon edges in Tableau in the Tableau Knowledge Base.