
WHERE F.geom.STGeometryType() = 'MultiPolygon' OR F.geom.STGeometryType() = 'Polygon' SELECT *, F.geom.STGeometryType() as geomtype FROM. If you get an error about mixed data types You can reverse the winding order with the SQL Server function ReorientObject(). counter-clockwise) determines which set of points you get. The winding order of the polygon points (clockwise vs.

Or, rather than a point and radius, a rectangle can be used. The radius can be a parameter, like the parameter used in the first example. This example query limits data to 1000 meters around the POINT. If you only want data around a certain point Using the parameter, you can adjust the relationship between schools and public spaces dynamically.įor more information, see Use parameters in a custom SQL query. Note: This example references a parameter named "Radius." It measures distance (meters) and has the following settings: The result of the query looks like this in the data grid: This example query will produce a row for each case where a public space polyogn is within Radius distance (meters) from a school. as PubSpaceName, S.geog_schools.STBuffer() as Geog_School, P.geog_pub_space as Geog_Pub_Space FROM _public_schools S LEFT JOIN _pub_space P ON S.geog_schools.STBuffer(). If your data has two sets of points, such as schools and parks, and you want to show where they intersect: Note that Custom SQL queries will vary from data source to data source. For examples of Custom SQL you can use with spatial data, see Custom SQL query examples.įor more information, see Connect to a Custom SQL Query Custom SQL query examples Type or paste your query into the Edit Custom SQL dialog box that appears. On the Data Source page, in the left pane, drag New Custom SQL onto the canvas.

#Postgresql vs mysql for spatial data how to
For more information on how to create maps from spatial files, see Build a map view from spatial data. You're now ready to build a map in Tableau using spatial data. Spatial columns will display the same name they have in your database. On the Data Source page, in the left pane under Table, drag a table that contains spatial data onto the canvas. Connect to spatial columnsįor more information on how to connect to data using supported connectors, see the Microsoft SQL Server, PostgreSQL, Oracle, Pivotal Greenplum Database or Snowflake connector examples. Tableau supports both live and extract connections using these connectors. In PostgreSQL + PostGIS, SRID always defaults to WGS84 (EPSG:4326). The following SRIDs are supported by these connectors: Note: In PostgreSQL + PostGIS, you can connect to tables with both mixed geometry types (points, lines, and polygons), but Tableau will not render these simultaneously. Geography fields must specify the geo-type to be recognized. Geometry fields must specify the geo-type (for example, POINT, LINESTRING) and SRID to be recognized as a spatial field. PostgreSQL + PostGIS, Oracle, and Pivotal Greenplum + PostGIS support Geography- and Geometry-type fields.

Supported spatial data and SRIDsįor Microsoft SQL Server, only Geography-type spatial data is supported. Tableau supports direct connections to spatial data using these connectors:įor information on using these connectors, see the Microsoft SQL Server, PostgreSQL, Pivotal Greenplum Database, Oracle, or Snowflake connector examples.

You can connect to supported spatial data sources and build visualizations with them to analyze spatial data, or you can connect to custom SQL or RAWSQL queries to perform advanced spatial analysis. You can use spatial columns stored in your database to build map visualizations in Tableau.
