Questions tagged [sqlgeography]

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

264 questions
3
votes
1 answer

How to use the dbGeography spacial data type of EFv5 with a WCF RIA domain service class

I am using EFv5 which now has the geography data type. So i have an entity called Place and it has a property called geoLocation that is of type geography. VS 2012 has automatically created the code for this entity and the property type for this…
3
votes
1 answer

GML to SQL Geography - 24200: The specified input does not represent a valid geography instance

I am currently in the process of integrating Google Maps into one of our applications. One of the requirements is to store a user defined area into the database. To do this I have been using the Geography type in SQL Server 2008. While I have got it…
Wizardskills
  • 155
  • 1
  • 12
3
votes
1 answer

Search nearby points from a geography column

I have a geography typed column in my table with spatial index. How can I select the top N rows that is within X meters of a given Latitude/Longitude while making use of the index to improve performance?
Bahamut
  • 1,929
  • 8
  • 29
  • 51
2
votes
1 answer

Selecting from two tables into an XML

I'm trying to execute the following SQL: SELECT * FROM Table2 INNER JOIN (SELECT * FROM Table1 INNER JOIN (SELECT MAX(DateTime) AS LastMeasurement, MeasurementId as LastMeasurementId FROM Table1 GROUP BY MeasurementId) as…
toy4fun
  • 839
  • 2
  • 14
  • 33
2
votes
1 answer

SQL Query to return Geography type as XML

I'm trying to return an XML from a table which holds a Geography type. SQL query: SELECT * From Events ORDER BY HydrantId ASC FOR XML RAW ('Event'), ROOT ('Events'), ELEMENTS XSINIL; I'm getting the following error: FOR XML does not support CLR…
toy4fun
  • 839
  • 2
  • 14
  • 33
2
votes
2 answers

Calculating short distances between lat/long points

I have a MySQL table with Spatial Points, and need to calculate distances. I found lots of material on doing this using the Haversine formula, however all of these assume a large distance between points. In my case, I only care about short distances…
Vlad
  • 475
  • 5
  • 9
2
votes
0 answers

Return percentage of LINESTRING (SQL Server 2008 Geography)

I want to create a function in SQL 2008 R2 that, given 3 parameters (@path geography, @start_pct float, @end_pct float), will return a linestring based on percentage of length of @path. For example when @start_pct = 0 and @end_pct = 0.5, it will…
Peter Hill
  • 138
  • 7
2
votes
1 answer

Sql DbGeography Issues

Please help me I have the following sql code DECLARE @polygon geography SET @polygon = 'POLYGON((-73.6965649914466 41.4459906683457,-73.6688781089674 41.4399017487713,-73.6969460096452 41.4295218755254,-73.6965649914466 41.4459906683457))' SELECT…
2
votes
2 answers

Slow performance of Latitude/Longitude conversion in query

I have a performance problem with a SQL query running on SQL Server 2019 that returns the lat/long from a geography column. My query is as follows and it takes around 5 seconds to return 553 rows: SELECT ActivityLocations.ID,…
Stephen
  • 33
  • 4
2
votes
0 answers

Any way to get an accurate ST_MinimumBoundingCircle calculation on a geography?

ST_MinimumBoundingCircle accepts the geometry type, i.e. planar geometry. Is there any way to get the minimum bounding circle of a geography collection using PostGIS? That is, the minimum bounding circle of a collection of features on the sphere.…
Dan
  • 744
  • 1
  • 8
  • 23
2
votes
2 answers

Ms SQL geography.STDistance returns wrong distance

I'm trying to query any locations within a specified distance from another location. The query is not the problem, but the distance returned by geography.STDistance is. It seems STDistance makes fairly accurate calculations on locations close to the…
Mikael
  • 21
  • 3
2
votes
1 answer

SQL: MakeValid() not working on type SqlGeography

I'm trying to get the SQL MakeValid() function to work on a geography type but am getting the following error: Could not find method 'MakeValid' for type 'Microsoft.SqlServer.Types.SqlGeography' in assembly…
NickyLarson
  • 127
  • 1
  • 1
  • 12
2
votes
1 answer

SQL Geography.STContains returns false values

I am creating several geography variables and I want to check if a set of coordinates exists inside the location. I use STContains to determine that. For most of the variables this seems to be working but I cannot understand some cases like the…
Manos
  • 77
  • 1
  • 10
2
votes
1 answer

Error accessing Geometry column from Azure SQL in Azure Function

I have an Azure Function that accesses an Azure SQL database. The 42nd column in the database is of the Geography datatype (this is where the problem lies). Here is the code I am running: // var datatable = DataTable(); // Filled 'datatable' from a…
Joshua
  • 617
  • 9
  • 23
2
votes
0 answers

Geography and projection in .NET Core

I'm looking for an alternative to SqlServer.Types capabilities for .NET Core. I need methods like Buffer(), Intersects(), Distance() using both geography (on spherical Earth) and geometry objects. Furthermore, I need to project these objects from/to…
Lodeli
  • 43
  • 6