Press "Enter" to skip to content

Category: Spatial

Native Spatial In SQL Server 2016

The CSS SQL Server Engineers team points out that spatial types will be a lot faster in the upcoming version of SQL Server:

The SQL Server development team was able to remove the PInvoke and PUnInvoke activities during T-SQL execution for many of the spatial methods.   A critical aspect of the change is that the change is fully compatible across the server and client scenarios. 

The same source code is used to build the managed C++ implementation and the unmanaged C++ implementation.   At the risk of understating this work the C++  managed code can be compiled with the C++ /CLI compiler, creating the managed assembly and a few, cleaver templates and macros bridge the native variations allowing C++ native compilation.  Any change to the code is made in one source file and built in two different ways.

They also have a couple of demos and point out that if you’re using a spatial index appropriately, the performance benefit from switching to 2016 is upwards of 3x.  A 3x performance improvement with no code changes is nothing to sneeze at.

Comments closed

Investigating Cleveland

Dave Mattingly goes spatial on Cleveland:

From here, we can:

  • zoom in for more detail

  • hover over a building, road, or other feature to see its name or other column

  • display a label on the results

  • apply filters to only show parts of the data

  • change the widths of the features by changing the STBuffer

  • do lots of other cool stuff

Spatial types and display in SQL Server has always been a weak point for me, so I enjoy seeing the fruits of somebody who is very good at it.

Comments closed

Spatial Data

Dave Mattingly has a multi-part series on spatial data.  This is part 5 (with links to the previous).

 

If you’re interested in spatial data, this looks like a fantastic set of blog posts which mesh well with Dave’s presentation on spatial data.

Comments closed

Using GeoJSON Data

Jovan Popovic shows how to use data in GeoJSON format.

First, building data in GeoJSON format from a spatial type:

In geometry object are placed type of the spatial data and coordinates. In “property” object can be placed various custom properties such as address line, town, postcode and other information that describe object. SQL Server stores spatial information as geometry or geography types, and also stores additional properties in standard table columns.

Since GeoJSON is JSON, it can be formatted using new FOR JSON clause in SQL Server.

In this example, we are going to format content of Person.Address table that has spatial column SpatialLocation in GeoJSON format using FOR JSON clause.

Then, converting GeoJSON to Geography types:

New OPENJSON function in SQL Server 2016 enables you to parse and load GeoJSON text into SQL Server spatial types.

In this example, I will load GeoJSON text that contains a set of bike share locations in Washington DC. GeoJSON sample is provided ESRI and it can be found in https://github.com/Esri/geojson-layer-js/blob/master/data/dc-bike-share.json

Check them out.

Comments closed