Questions tagged [sqlgeometry]

The SqlGeometry class in MSSQL Server API representing data in a Euclidean (flat) coordinate system.

67 questions
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…
9
votes
2 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,308
  • 2
  • 19
  • 32
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,868
  • 1
  • 18
  • 31
8
votes
0 answers

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
  • 15,926
  • 28
  • 119
  • 175
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
  • 487
  • 1
  • 3
  • 17
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
  • 18,754
  • 5
  • 58
  • 83
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,110
  • 24
  • 31
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
  • 9
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…
3
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
  • 133
  • 1
  • 11
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
  • 5,342
  • 7
  • 55
  • 126
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
  • 53
  • 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
  • 298
  • 3
  • 12
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…
1
2 3 4 5