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?
1 of 1 people found this helpful
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.
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!
Key Travel distance Polygon lat lon 232989 10 0xE610000001040B000000C00BCF77A9054A4006BF6BB27F921640955053A8A7054A40FEA0E5DE7D921640F5866D1BA6054A4075EE77318A92164079A7DA68A5054A405F78A20BA0921640BA106BD6A5054A408F6CF70BB7921640761B2339A7054A40C5003758C6921640AACD9E08A9054A40DFF4C22BC892164001CB8495AA054A40115733D9BB921640D6D11748AB054A40279A04FFA5921640084E87DAAA054A40105FAAFE8E921640C00BCF77A9054A4006BF6BB27F92164001000000020000000001000000FFFFFFFF0000000003 52,0442064458315 5,6431984186822
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.
Thanks for your help, and I apologize for not getting back to you sooner.
Unfortunately, it still does not work. Indeed, the field does not appear as a dimension or measure.
SQL Server itself even shows a tab named "Spatial results" for this column, but Tableau totally ignores it.
Using RAWSQL_SPATIAL does not work either (see screenshot below).
My WKT-column is named "Cirkels3" and I created a calculated field named "Cirkels4" with the calculation:
RAWSQL_SPATIAL("geography::STGeomFromText(%1, 4326).MakeValid()", [Cirkels3])
Tableau shows an error dialog, but does not show any error details as you can see below (which is a problem of its own I think).
Do you have any idea what goes wrong here?
Thanks in advance.
P.S. I am using Tableau 2018.2.
I solved this myself.
This is what I did:
I converted the field data at the side of the SQL Server from "geography" to a varchar, so that Tableau 2018.x recognizes the field. In my case, Tableau does not show the field if it has the geography data type.
Then, I created a calculated field in Tableau which simply converts it back to geography: RAWSQL_SPATIAL("CONVERT(geography,[Cirkels3])")
Even though the calculated field shows an "earth"-icon, I still had to set the mark to "Map" though, but then it works!