

In this case we need to open json in two steps:ġ. Polygon can also have more than one line string (each line string is represented with a separate line string in the $.coordinates array): Results are shown in the following table: $.coordinates) and open all (x,y) points in this array: In this case, we will reference first element in the $.coordinates array (i.e. OPENJSON enables you to find coordinates of points that belong to polygon. ,, ,, ]įormat is same as in the line string however, in polygons we assume that first and last points are the same. In the simplest case we can have only one line string in the set: Polygon represents a set of independent line strings. In this example we are converting coordinates to int type. In order to fetch coordinates of points you should take elements 0 and 1 from the array using paths $ and $. We can seek into the array of coordinates (on path $.coordinates), and return (x,y) pairs of each point: Each coordinate is represented as a two-number array, as it is shown in the following example: Line strings are represented as an array of 2D coordinates. Goal of this post is not only to show how to parse GeoJSON, but also to see how you can parse some real-world nested JSON structures. GeoJSON types that will be described here are: In this post we will see how you can parse various types of GeoJSON objects and extract their coordinates.

Sql Server 2016 enables you to parse GeoJson format using OPENJSON function. GeoJSON is commonly used format for representing various geo-objects such as lines, polygons, etc. Parsing GeoJSON format in Sql Server 2016
