
Hello,
we have data that contais WKT strings with Polygon data. We were able to convert the WKT to Polygon use rawsql_spatial function in Tableau 2018.2. Is there a way to find a polygon's centroid using Tableau from the raw_sql function? That would convert this to Geometry Point?
we're trying to find how many points are within a zip code region. The zip code region is on a separate spatial shapefile.
Thank You
Marina
It sounds like you have your dataset in a SQL Server database, so you could try:
Calculate the Envelope Center on the polygon (geography data type) - the raqsql would look something like this (I'm not sure how the envelope center will compare to the centroid calculated on the geometry, but it sounded sort of in the ballpark...):
- RAWSQL_SPATIAL("%1.EnvelopeCenter()", [Ogr Geography])
- EnvelopeCenter (geography Data Type ) - SQL Server | Microsoft Docs
Or, if you have a geometry data type as well, you could use the STCentroid() function:
- RAWSQL_SPATIAL("%1.STCentroid()", [Ogr Geometry])
- STCentroid (geometry Data Type) - SQL Server | Microsoft Docs
Or, you could convert your geography to geometry, calculate the centroid using STCentroid, and then cast back to geography.
-Sarah
Tableau Research