4 Replies Latest reply on Jul 5, 2018 9:42 AM by Sarah Battersby

    Spatial data from SQL Server not shown/recognized by Tableau Desktop

    Fred Verbeek

      Good afternoon,

       

      I tried several solutions found on the web and on the community pages, but I still don't manage to get the following work.

       

      I created a View in SQL Server 2008 R2. This view contains the following columns, and I've include one example record.

       

      KeyTravel DistancePolygonlatlon
      23298910POLYGON ((5.64306525023108 52.044234253021841, 5.6430582835821479 52.044179001503984, 5.6431052903604852 52.044131687622134, 5.6431886499322834 52.04411039997553, 5.6432763929143581 52.044123461034772, 5.6433347495623751 52.044165746824476, 5.64334171655102 52.044220998326026, 5.6432947099290383 52.044268312301945, 5.6432113501128134 52.044289600020122, 5.6431236068235791 52.044276538912584, 5.64306525023108 52.044234253021841))52,04420644583155,6431984186822

       

      The problem is that Tableau does not 'see' the column named 'Polygon'. Hence, I cannot use this data in my map. The column has the data type Geography (however, I also tried the data type Geometry).

       

      Still, Tableau does not recognize the column.

       

      Then, I tried to convert the data type to a string. Tableau then does 'see' the column, but does not treat the column as spatial data and by no means I can set the value to be recognized as spatial data.

       

      Strange enough: SQL Server has no problem interpreting his own spatial data (see attachment).

       

      I also tried the RAWSQL_SPATIAL function, by creating a calculated field from this field 'Polygon'. I'm getting an error in that scenario, which is not specified by Tableau.

       

      Does anyone know how to get this work? Of can anyone point me in the right direction?

       

      Thanks in advance,

       

      Fred

        • 1. Re: Spatial data from SQL Server not shown/recognized by Tableau Desktop
          Sarah Battersby

          At least in the table that you screen captured it looks like your Polygon column is WKT and not actually a geography data type. When I query a table in one of my SQL Server databases the geography column ends up looking something like this:

           

          • 0xE610000010405<blah blah blah more random letters and numbers>

           

          I think that you should be able to use RAWSQL to convert WKT to geography if that is the problem though.  What did your calculation look like for that? 

           

          -Sarah

          Tableau Research

          • 2. Re: Spatial data from SQL Server not shown/recognized by Tableau Desktop
            Sarah Battersby

            Fred Verbeek - I just tested out a RAWSQL query to convert WKT to geography to make sure it would work - it worked just fine.  My query looked like this:

             

            • RAWSQL_SPATIAL("geography::STGeomFromText(%1, 4326).MakeValid()", [WKT])

             

            "WKT" was my un-creative original field name containing the WKT string

            4326 was the EPSG code for the dataset I happened to use

             

            Let me know if this doesn't work for you and I'll see if I can dig in a bit more to help out.

             

            -Sarah.

            Tableau Research

            1 of 1 people found this helpful
            • 3. Re: Spatial data from SQL Server not shown/recognized by Tableau Desktop
              Fred Verbeek

              Thanks Sarah. I am going to try this.

               

              You are right that the polygon-column is shown as text. I also tried the geography data type which is shown as below, but that doesn't work either (Tableau does not show the field).

               

              I am going to try the RAWSQL_SPATIAL-solution, and I will inform you if it works!

               

              KeyTravel distancePolygonlatlon
              232989100xE610000001040B000000C00BCF77A9054A4006BF6BB27F921640955053A8A7054A40FEA0E5DE7D921640F5866D1BA6054A4075EE77318A92164079A7DA68A5054A405F78A20BA0921640BA106BD6A5054A408F6CF70BB7921640761B2339A7054A40C5003758C6921640AACD9E08A9054A40DFF4C22BC892164001CB8495AA054A40115733D9BB921640D6D11748AB054A40279A04FFA5921640084E87DAAA054A40105FAAFE8E921640C00BCF77A9054A4006BF6BB27F92164001000000020000000001000000FFFFFFFF000000000352,04420644583155,6431984186822
              • 4. Re: Spatial data from SQL Server not shown/recognized by Tableau Desktop
                Sarah Battersby

                So long as you're using Tableau 2018.1 or later, it should recognize a geography column from SQL Server...  One thing to check is that you are using one of the following SRIDs:

                • NAD83 (EPSG:4269)
                • ETRS89 (EPSG:4258)
                • WGS84 (EPSG:4326)

                 

                When you say that Tableau doesn't show the field are you saying that it doesn't even appear as a dimension or measure?  That would happen in versions earlier than 2018.1, but after 2018.1 you should see your geography column.

                 

                Connect to Spatial Data in Microsoft SQL Server

                 

                -Sarah.

                Tableau Research