Questions tagged [sqlgeography]

The MS SQL Server SqlGeography type represents data in a geodetic (round earth) coordinate system.

240 questions
25
votes
2 answers

EntityType 'DbGeography' has no key defined

Long time listener, first time caller (finally made an account here!)... I am using Visual Studio 2013 with .NET 4.5.1 and Entity Framework 6 (final releases, not RC or beta). When trying to add a DbGeography property to my entity, I get this error…
Jeff Guillaume
  • 1,581
  • 3
  • 16
  • 29
18
votes
3 answers

How to find intersecting geographies between two tables recursively

I'm running Postgres 9.6.1 and PostGIS 2.3.0 r15146 and have two tables. geographies may have 150,000,000 rows, paths may have 10,000,000 rows: CREATE TABLE paths (id uuid NOT NULL, path path NOT NULL, PRIMARY KEY (id)) CREATE TABLE geographies (id…
David Murdoch
  • 82,194
  • 38
  • 141
  • 186
16
votes
3 answers

Google Maps and SQL Server LINESTRING length inconsistent

Google Maps and MSSQL seem to disagree on how to calculate the distance/length of a polyline/linestring using SRID 4326. MSSQL: SELECT geography::STGeomFromText('LINESTRING(-98.78 39.63,2.98 27.52)', 4326).STLength() Result: 9030715.95721209 Then…
ParoX
  • 4,850
  • 19
  • 72
  • 138
14
votes
1 answer

Convert SQL geography to C#

What is the C# equivalent of this geospatial T-SQL code? DECLARE @g geography; DECLARE @h geography; SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326); SET @h =…
Unforgiven
  • 1,719
  • 5
  • 18
  • 18
12
votes
1 answer

Why does SQL Server GEOGRAPHY allow longitudes between -15069° and +15069°? Why ±15069°?

I am using the Microsoft.SqlServer.Types DLL in my projects for validating Latitudes and Longitudes. The Library validates longitude values between -15069 and 15069 degrees instead from -180 to 180. Can anybody explain what is the significance or…
11
votes
2 answers

Enter data in geography column in SQL Server management studio

I've created a new table in SQL Server Management Studio, which includes a Geography column. Now, I'm trying to enter data in this column using the SSMS UI, but I just can't find the right way of doing it. So, how can that be done?
ml123
  • 907
  • 2
  • 9
  • 20
11
votes
3 answers

Mapping SqlGeography with Dapper

I have entity "Point", that contains Id, Text and geography coordinates. CREATE TABLE [Point] ( [Id] INT IDENTITY CONSTRAINT [PK_Point_Id] PRIMARY KEY, [Coords] GEOGRAPHY NOT NULL, [Text] NVARCHAR(32) NOT NULL, [CreationDate]…
lenden
  • 740
  • 1
  • 12
  • 36
10
votes
2 answers

Is it possible to use SqlGeography with Linq to Sql?

I've been having quite a few problems trying to use Microsoft.SqlServer.Types.SqlGeography. I know full well that support for this in Linq to Sql is not great. I've tried numerous ways, beginning with what would the expected way (Database type of…
cofiem
  • 1,374
  • 1
  • 16
  • 28
10
votes
2 answers

What is the right way to insert DBGeography type via ado.net

I am trying to insert DBGeography type via ado.net but no luck. This is the errors that I am getting: No mapping exists from object type System.Data.Entity.Spatial.DbGeography to a known managed provider native type. or: Specified type is not…
1110
  • 7,801
  • 45
  • 156
  • 303
10
votes
2 answers

How do I select Lat & Long coordinates back out of SQL Server Geography data type field

Considering the SQL Server 'geography' data type... I can enter an array of latitude and longitude (btw is that the correct order to do so or should it be longitude latitude?) points into the field as follows: INSERT INTO SpatialZonePolygons…
ChrisCurrie
  • 1,419
  • 5
  • 15
  • 31
10
votes
1 answer

Create a SqlGeography polygon-circle from a center and radius

I would like to save a circle in a sql-server 2008 geography field, using c#. In c# I have a latitude, a longitude and a radius but I just can't find a way to calculate the polygon that would represent the circle and create a SqlGeography from it. I…
Johann
  • 11,420
  • 10
  • 56
  • 82
9
votes
6 answers

Reformat SQLGeography polygons to JSON

I am building a web service that serves geographic boundary data in JSON format. The geographic data is stored in an SQL Server 2008 R2 database using the geography type in a table. I use [ColumnName].ToString() method to return the polygon data as…
James
  • 898
  • 3
  • 9
  • 23
9
votes
1 answer

Is there a way to declare a Spatial Index with EntityFrameworkCore 2.2?

I am using Entity Framework Core 2.2 with NetTopologySuite 1.15.1 and SQL Server 2016. Having a column of type IPoint works great to the point I want to create an index on it. I have this table public class Location { public int Id { get; set;…
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
8
votes
3 answers

LINQ to SQL Designer and the Geography datatype

I am having a few problems loading a table into the designer. I get the following error. One or more selected items contain a data type that is not supported by the designer Would I be correct in assuming it is the geography type used in the table…
Chin
  • 11,899
  • 35
  • 98
  • 151
1
2 3
15 16