Results from STAsText() being truncated
Does SQL 2012 or 2014 support raster data
How to speed up SQL spatial query (spatial index error)
Hi,
Im trying to split polylines by points which have a small buffer around them. Currently i have over 370,000 lines and 320,000 nodes and the query is running really slowly (ive left it for 3 days and it still hasnt completed). I have tried forcing a spatial index using with (Index(SI_tempPD)) but i get the following error:
"The query processor could not produce a query plan for a query with a spatial index hint. Reason: Could not find required binary spatial method in a condition. Try removing the index hints or removing SET FORCEPLAN."
below is the snippet of code that im trying to run when i get the error:
BEGIN INSERT INTO TempLines ( [linenum] ,[ogr_geometry] )
SELECT lines.[linenum] ,lines.[ogr_geometry].STDifference(points.[ogr_geometry].STBuffer(0.005))
AS ogr_geometry FROM dbo.TemplineData AS lines with(Index(SI_tempPD)) INNER JOIN dbo.[TemplineNodes]
AS points ON lines.[ogr_geometry].STIntersection(points.[ogr_geometry]).STDistance(points.[ogr_geometry]) < 1
WHERE (lines.[linenum] <> points.[linenum]) END
is there anyway i can speed up the query? (I also have a clustered primary key) the execution plan shows that a filter takes up 36% of the cost and the insert takes up 64%
Any help would be greatly appreciated! (im using SQL Server 2008 (SQL server Management studio 10.50.1600.1))
Help needed in Geography datatype
Hi, using sqlserver 2008 R2 db
below is my ZipCodes table schema
Create table ZipCodes(ID bigint primary key identity(1,1),ZipCode varchar(10), Address varchar(4000), city varchar(50),state varchar(50),Latitude float,Longitude float)
trying to add new column to hold geography datatype to calculate distance using sqlserver geography function.
alter table ZipCodes add Coordinates geography null update ZipCodes set Coordinates = 'geography::STGeomFromText(''POINT(' + Latitude + ',' + Longitude + ', 4326))'
getting error as below,
Msg 6522, Level 16, State 1, Line 1 A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": System.FormatException: 24114: The label geography::STGeomFro in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, or GEOMETRYCOLLECTION. System.FormatException: at Microsoft.SqlServer.Types.OpenGisWktReader.ParseTaggedText(OpenGisType type) at Microsoft.SqlServer.Types.OpenGisWktReader.Read(OpenGisType type, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(Openplease help me to resolve this issue
loving dotnet
Bing Maps: distance between two locations including country borders info, to calculate distance travelled in each country individually
Hi Everyone !
I want to develop a desktop application in C# (preferably WinForm) which will give me the distance travelled within a country through Bing Maps i.e. if the route crosses a country border then I want to know the real distance in each country.
I am trying to find any solution that can calculate distance between point A and point B, but including information about country’s border. I need this information in order to calculate the price of trip, as price per km in one country might be different from price per km in other country.
I want to calculate the number of miles a vehicles travel in each country over a period of time. For trips taken over the period, the user will create routes on the map, and the program should be able to generate some output like: Country A: 100 miles, Country B: 200 miles and Country C: 150 miles etc.
I did some search in https://social.msdn.microsoft.com and found very useful stuff but not exactly what I am looking for.
I am newbie to Bing Maps, could you please help me. Could you please point to a working sample app (sample might be Silverlight, WPF etc)?
Would it be required to add a SQL database with the outlines of country borders (example of source:http://www.diva-gis.org/Data)
Thanks in advance
Shakeel
Servers software for receiving data from gps trackers
Heard that there is exist server software for receiving data from various GPS trackers. Can someone share the link. Need not ready software for GPS monitoring operators, but some system that receives the data from trackes of various types or some API to receive data in order to write it to mssql database.
Fastest way to compare polygon geometry types
We have two tables which has polygon geometry stored in them. I would like to fetch the polygons present in one table and not present in another table.. As of now I am doing a left outer join and using STAsText() but it is taking lot of time.. FYI,We have 120 million polygons in both the tables. Is there a fast way of fetching? (may be using the spatial indexing, I am not aware of this).
FYI, I am using SQL Server 2012.
There are no indexes on this table. This is the command I am using for comparision.
select newPolygon.* from table1 newPolygon left join table2 oldPolygon on newPolygon.Shape.STAsText() = oldPolygon.Shape.STAsText() where oldPolygon.Shape is null
Thanks for your help in advance !!
How to get the spatial results, and how to export it to a Mapinfo Table?
Hi all,
I made a view in SQL Server, and got about 6000 items in the result. Now I am trying to get the spatial results and then I want to export it to a Mapinfo Table. Will you pls tell me what I should do?
Thanks a lot
Address calculation based on Latitude and Longitude
We are using SQL Server 2008 web edition. We have a table named "tbl_geodata" which has address and latitude and longitude values. We also have a "History" table which has only latitude and longitude values including other informations. What we need is like following...
We get a set of records based on a query from "Histroy" (lat long values), say 5000 records
Now we are using the following formula to calculate address from the "tbl_geodata" for each row (5000 rows).
SELECT top 1 geo_street,geo_town,geo_country,( 3959 acos( cos( radians(History.lat) ) cos( radians( gps_latitude ) ) cos( radians( gps_longitude ) - radians(History.long) ) + sin( radians(History.lat) ) sin( radians( gps_latitude ) ) ) ) AS distance FROM tbl_geodata ORDER BY distance
What would be better way to handle this?
Trouble importing some shapefile data and Not converting with Planner Geometry
Hello,
We have a Small shapefile projected in EPSG:4326 which are clipped from a BIG shapefile by QGIS.
But this Small shapefile not converting into SQL by Shape2Sql with planner geometry, while converting with Geography option.
Note: BIG Shapefile converting correctly!
Please assist us asap, so that we can move further in our project.
Thanks in advance!
Dissolve/aggregate line segments
I have a polyline layer of segmented roads. There is a unique identifier for the road segments (Road_ID). I would like to 'dissolve' based on this unique id, to make one continuous line for each group of segments with a common ID. From what i have read, the unionaggregate method would do something comparable, but works on the entire shape column.
instead of going through each one as below, is there a way to unionaggregate base on the Road_ID ? There are hundreds of roads in my source data. I am on SS 2012.
SELECT geometry::UnionAggregate(shape) FROM pubgis.dbo.Trans_GravelRoads WHERE Road_ID = 'Main St.'Thanks.
Can't connect to SQL Server 2014 new install
Dim LocalName = "MyHostPcName" 'Public SQLcon As New SqlConnection With {.ConnectionString = "Server=" & LocalName & "\SQLEXPRESS;Database=FilesDbSQL;Trusted_Connection=Yes;"} Public SQLcon As New SqlConnection With {.ConnectionString = "Server=" & LocalName & "\MSSQLSERVER;Database=tmsisDbSql;Trusted_Connection=Yes;"}
I am using a Visual Basic Console application to connect to the SQL Server.
I am just removed the express version and installed the SQL Server 2014 Standard Edition (Evaluation version).
In the example above I have two connections the first one is commented out but it was working fine with SQLEXPRESS now that I have installed the 2014 Standard Edition (evaluation version) I can't make a connection from Visual Basic.
When Installing I took the default Server name and the default INSTANCE name which is supposed to be "MSSQLSERVER" and seems to be the correct instance name by looking at the SQL Server configurations Manager where I can see: SQL Server (MSSQLSERVER), I can also see the same thing under the "MSC" services screen.
I have also checked SQL Management Studio (server properties\Connections) and the check box for: "Allow remote connections to this server" is checked.
Can someone tell me what or how I need to set my connection string?.
App Domain is marked for unload due to memory pressure
I have a SQL Server 2008 R2 64 bit running on a Windows Server 2012 Server. The box has 48 gigs of memory for SQL Server to run. That is the only thing running on that server.
I am seeing the error log full of messages saying that the App Domain (xxx) is marked for unload due to memory pressure. I have done some research, and it seems to be related to using CLR code. I am not using any CLR code other than the SQL Server Spacial objects. I believe the server has plenty of memory to use, so I am not sure what is going on.
I am also getting the error message "The app domain with specified version id (%d) was unloaded due to memory pressure and could not be found." in my applications.
From what I can see, this seems to be related to SQL Server running in 32 bit mode and not having enough memory, but I am running the 64 bit version.
I wonder if it may be due to SQL Server not using enough memory. I have noticed that the memory used by SQL Server is close to 5 gigs.
Below is a screen shot that shows how much memory is being used, and how much is available on the machine.
This next screen shot is the configuration values showing that SQL Server should be using as much memory as it likes. I have about two dozen databases on this server, so I would expect it would use more.
When looking at the log files for SQL Server, I see this memory error every few seconds, so this is happening all the time.
Any suggestions?
Geography type - Polygons
Hi,
We're currently with ongoing spatial data project. We will use SQL SERVER 2014 to store spatial data in WGS84 SRS. We are having problems importing polygon's to database because of ring orientation defined. The restriction that existed on SQL SERVER 2008 of
a polygon not being imported because it surpassed one hemisfere has been removed on this version so that is not problem. The problem we have is when calculating distances, areas and relations between polygons because of the ring orientation. We have no control
over the data that is sent to us so we cannot force the clients to give the right ring orientation.
We've checked if SQL SERVER 2014 as a solution for this, meaning, reorient spatial object if the points are on the wrong orientation and it doesn't. There is a method on the geography type that reorients the ring orientation but, we only want that, when the
ring orientation is wrong. Is there a good way to check if the polygon ring orientation is wrong and then reorient it? We discovered some solutions but they are straight saying that could fail on some cases.
If we use a geometry type column we could overpass the relations problems between spatial objets but the distances and areas are given on decimal degrees which is not what we want.
Best regards,
Bruno da Fonseca
Polygon creation from existing Lat/Long fields
Hi Guys,
I've spent a few hours on this and can't figure out where I'm going wrong.
I am trying to modify an old existing database (SQL Server 2008 R2) by adding a geography column to an existing table and using the Long/lats within this table to create the spatial object, the resulting object will be used in MapInfo. The geography column has been added (BoundingPy_Geo) and the update query I have come up with is below:
UPDATE DatasetWGS84Extent
SET BoundingPy_Geo =(geography::STGeomFromText('POLYGON('
+CAST([MinX]ASVARCHAR(50))+' '+CAST([MaxY]ASVARCHAR(50))+','
+CAST([MinX]ASVARCHAR(50))+' '+CAST([MinY]ASVARCHAR(50))+','
+CAST([MaxX]ASVARCHAR(50))+' '+CAST([MinY]ASVARCHAR(50))+','
+CAST([MaxX]ASVARCHAR(50))+' '+CAST([MaxY]ASVARCHAR(50))+','
+CAST([MinX]ASVARCHAR(50))+' '+CAST([MaxY]ASVARCHAR(50)) +')', 4326))
GO
It fails however with the following error:
Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24142: Expected "(" at position 9. The input has "9".
System.FormatException:
at Microsoft.SqlServer.Types.OpenGisWktReader.RecognizeToken(String token)
at Microsoft.SqlServer.Types.OpenGisWktReader.ParseLineStringText()
at Microsoft.SqlServer.Types.OpenGisWktReader.ParsePolygonText()
at Microsoft.SqlServer.Types.OpenGisWktReader.ParseTaggedText(OpenGisType type)
at Microsoft.SqlServer.Types.OpenGisWktReader.Read(OpenGisType type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
I can’t find the 9 referenced or figure out where position 9 is.
Any help would be greatly appreciated.
Cheers,
Tony
Sql Server Azure PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE
We received this error yesterday.I found a few articles suggesting it was an issue with orphaned userIds, but because the database is hosted on Azure the stored procedure to access the user profiles isn't available and I'm no database expert.
It says it cant find assembly 'microsoft.sqlserver.types' 11.1.0.0 the version that was deployed a few weeks back was 10.0.0.0 so i updated my nuget packages but that version is only on 11.0.2
We resolved the issue at the moment by taking a copy of the database. Its only temporarily resolved i feel and it'll happen again.
System.Data.SqlClient.SqlException : An error occurred in the Microsoft .NET Framework while trying to load assembly id 1. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: System.IO.FileNotFoundException: Could not load file or assembly 'microsoft.sqlserver.types, Version=11.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'microsoft.sqlserver.types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: System.IO.FileNotFoundException: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString)
Spatial index statistics missing
If I run a query that utilises a spatial index the query plan says the statistics are missing.
This is born out by the fact the optimiser thought estimated the number of rows as 11,000 and the actual number was 123.
All in all the estimated number of rows and the actual number are wildly out. This is after building the indexes and not making any modifications to the data
Microsoft.SqlServer.Types Error in SSIS
Hi,
I have a SSIS package built in 2012 that uses Geo data types from Microsoft.SqlServer.Types. I am trying to upgrade to 2014 but when I try in visuals studio 2012 it doesnt seem to see the latest version of the assembly for me to upgrade too. When i try to do the automatic upgrade using management studio it fails also saying "The binary code for the script could not be foudn", even though I can see the files on my local computer and server.
Any ideas :)
Thank you!
Default port
How do I display 3 different geography objects in Spatial Results window?
Hello,
I am doing a basic spatial query that loads 3 geographies. They are one point, and 2 polygons. First, I have one point that is the centroid of the first polygon. This is shown below when I just query
SELECT GEOGRAPHY::STGeomFromText('POLYGON ((-76.759611 39.957715, -76.759576 39.957718, -76.759566 39.957741, -76.759629 39.957745, -76.759611 39.957715))', 4269)
UNION ALL
SELECT GEOGRAPHY::STPointFromText('POINT (-76.759595499999349 39.957729750002805)', 4269)
However, when I run my desired query to include one more POLYGON object which is larger than both of these objects, I will end up no longer seeing the first polygon shown above. I believe it is because it is covering (or the same color?) as the larger second POLYGON object. (see query & the results below)
SELECT GEOGRAPHY::STGeomFromText('POLYGON ((-77.57345493469239 40.133857196124765, -77.57345493469239 39.79177166186643, -75.97357090148927 39.79177166186643, -75.97357090148927 40.133857196124765, -77.57345493469239 40.133857196124765))', 4269)UNION ALL
SELECT GEOGRAPHY::STPointFromText('POINT (-76.759595499999349 39.957729750002805)', 4269)
UNION ALL
SELECT GEOGRAPHY::STGeomFromText('POLYGON ((-76.759611 39.957715, -76.759576 39.957718, -76.759566 39.957741, -76.759629 39.957745, -76.759611 39.957715))', 4269)
Can anyone help me be able to see the first polygon and the second polygon on in this result set window? Perhaps I just need to change the color of the first polygon?
Any help would be appreciated. Thank you in advance.
Nick
Thanks! Nick