KNOWLEDGE BASE

When adding a Geographical Value to a sheet an "Operand type clash: geometry is incompatible with geography" message is displayed


Published: 02 Nov 2018
Last Modified Date: 06 Nov 2019

Issue

When attempting to use Spatial data with Mixed Geometry Types adding a Geographical value to a sheet the following error may occur:

Bad Connection: Tableau could not connect to the data source.
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: geometry is incompatible with geography
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Statement(s) could not be prepared.

Environment

  • Tableau Desktop 2018.2.2
  • MS SQL Server Spatial data with Mixed Geometry Types

Resolution

As a possible workaround convert to Geography type using Well Known Text (WKT) or Well Known Binary (WKB). Following is an example of what the conversion might look like using both WKT and WKB: 

Move the Geometry data to Geography data in a sister table:
  1. Create table with Geography column
    CREATE TABLE gfoo (
     id   INTEGER,
     geog GEOGRAPHY);
  2. Convert from Geometry to Geography using Well Known Text
    INSERT INTO gfoo
     SELECT foo.id, GEOGRAPHY::STGeomFromText(foo.geom.STAsText(),4326)
     FROM foo;
  3. Convert from Geometry to Geography using Well Known Binary
    INSERT INTO gfoo
     SELECT foo.id, GEOGRAPHY::STGeomFromWKB(foo.geom.STAsBinary(),4326)
     FROM foo;

Cause

In current versions of Tableau, you can only connect to point geometries, linear geometries, or polygons. You cannot connect to mixed geometry types.

Did this article resolve the issue?