The SqlGeometry class in MSSQL Server API representing data in a Euclidean (flat) coordinate system.
Questions tagged [sqlgeometry]
68 questions
12
votes
1 answer
Microsoft.SqlServer.Types incompatible with .NET Standard
I'm attempting to convert all of our C# class libraries from .NET Framework to .NET Standard projects, as we are starting to leverage .NET Core so need these to be consumable by both .NET Core and .NET Framework apps (with the latter being ported…

Justin
- 17,670
- 38
- 132
- 201
12
votes
2 answers
Is the SQL Server 2012 version of Microsoft.SqlServer.Types' geometry UDT backward compatible with SQL Server 2008?
If I had both SQL Server 2008 and SQL Server 2012 installed locally, I would simply try this for myself; however I only have the newer version installed and would like to keep it that way.
SQL Server 2008 comes with an assembly…

stakx - no longer contributing
- 83,039
- 20
- 168
- 268
10
votes
3 answers
Convert between SqlGeometry and DbGeometry
Is there a simple way to convert between SqlGeometry and DbGeometry?
I'm using a popular sql spatial helper library and all of the functions in there expect SqlGeometry. But when i use Entity Framework against an ESRI ArcSDE feature class the Shape…

VBAHole
- 1,508
- 2
- 24
- 38
8
votes
2 answers
SqlBulkCopy DataTable with WellKnownText spatial data column
I'm trying to bulk copy a DataTable which has the following columns:
"ID" - System.Int32
"Geom" - System.String
Into a SQL database with the following columns:
"Id" - int
"Shape" - geometry
Can anyone advise on the best way to do this?
Some…

mortware
- 1,910
- 1
- 20
- 35
6
votes
0 answers
SQL Server Geography datatype with .Net Core 2.1
I understand that the SQL Server geography and geometry datatypes are not currently supported in .Net EF Core, but I'd still like to use them in standard .Net Core 2.1. The Microsoft.SqlServer.Types package does not seem to work in Core, at least…

Connie DeCinko
- 802
- 2
- 15
- 32
5
votes
1 answer
Postgres / postgis - ensure all polygons are closed
I am needing to write a query which finds any unclosed polygons and closes them by copying the first point and creating an additional end point.
I am able to select the invalid rows:
SELECT delivery_zone_id, polygon from delivery_zone WHERE…

Ryan Wheale
- 26,022
- 8
- 76
- 96
4
votes
1 answer
Group by value and create geography polyline from points (latitude and longitude) for each group in T-SQL
A similar question has been asked here:
Create geography polyline from points in T-SQL
Taking that question further, I have a table schema that looks like this:
CREATE TABLE [dbo].[LongAndLats](
[Longitude] [float] NULL,
[Latitude] [float]…

user3799279
- 143
- 1
- 11
4
votes
1 answer
Sql geometry polygon direction and crossing the International Date Line (IDL)
As you can see in the following, the result of the geography polygon is different from the geometry polygon. What I want is the yellow square, but what I'm getting is the green square. Is there any way to achieve this?
If I create a geography…

Azadeh Khojandi
- 3,806
- 1
- 30
- 32
3
votes
1 answer
STDistance() return weird result
I am finding the distance between two points of geometries and following is my query
DECLARE @g geometry;
SET @g = geometry::STPolyFromText('POLYGON ((5.177074447274207 60.32819571126778,
5.177074447274207 60.32533671620816,
5.172660537064075 …

sandip
- 165
- 1
- 11
3
votes
4 answers
Divide the coordinates into X and Y coordinates from a table having geometry data in SQL Server 2012
I have a table with a column Shape of geometry datatype.
This is the data in Shape :
POLYGON ((565542.98375 2127263.4997410, 565538.48450 2127261.3187302, 565541.96658 2127254.1162, 565546.465835 2127256.297297, 565542.9837…

zico barretto
- 33
- 5
3
votes
0 answers
DbGeometry vs DbGeography difference
DbGeometry provides a base class for objects that define geometric shapes.
DbGeography represents data in a geodetic (round earth) coordinate system.
But these classes has similar static methods. For example:
DbGeometry.FromText("POINT(12.803099…

barteloma
- 6,403
- 14
- 79
- 173
3
votes
1 answer
Getting a Random Point within a Geometry area
STPointOnSurface() seems to always return the same point. How can I generate a random point located within the interior of geometry in SQL Server?

bre
- 63
- 4
2
votes
1 answer
SQL - Compare route coordinates
I have route's longitudes and latitudes and there is a table(route_info) which has columns as feature_id, route_id, coordinates, region
feature_id
route_id
coordinates
region
43829103
5467
[[long,lat],[long,lat]....[long,lat]]
NA
Now I…

L Lawliet
- 419
- 1
- 7
- 20
2
votes
1 answer
SQL statement including MakeValid() crushing the server
I think this is an interesting bug with MakeValid() in SQL Server I have tried it in SQL Server 2016 and 2019. The following SQL will crush your SQL Server and you'll have to kill the SQL Server Service. There is nothing special about this geometry.…

Kosta B
- 21
- 1
2
votes
2 answers
SQL Server - Linestring from Points Geometry
Is there an easy way to create a LineString out of a column of Points in SQL?
For example I have a query:
SELECT Geom FROM api.Table WHERE WellId = 'XYZ1234' ORDER BY MeasuredDepth ASC;
that returns 186 points as…

steven hurwitt
- 183
- 2
- 15