SQL Server Spatial ForumAny questions related to the use of spatial data in SQL Server.© 2009 Microsoft Corporation. All rights reserved.Wed, 09 May 2012 02:36:14 Z264afbfa-113f-400e-b4a9-5faead328944- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/4fe31159-a95b-4c99-9e1f-3a061a55003fhttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/4fe31159-a95b-4c99-9e1f-3a061a55003fAbhijit- SQL2008http://social.technet.microsoft.com/profile/abhijit-%20sql2008/?type=forumhow to convert STDistance value to KM<div>Declare @Point1 Geometry,@Point2 Geometry</div>
<div>SET @Point1 = GEOMETRY::STGeomFromText('POINT (88.358206509833749 22.527348591128348)',18)</div>
<div>SET @Point2 = GEOMETRY::STGeomFromText('POINT (72.873565892186846 19.119301736552419)',18)</div>
<div></div>
<div>SELECT @Point1.STDistance(@Point2)</div>
<div></div>
<div>output 15.8552476619151 </div>
<div></div>
<div>please tell me how to convert this value to Kilometers </div>
<div></div>Thu, 01 Dec 2011 07:36:12 Z2012-05-08T13:54:35Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/6079b49c-9da2-49d6-b32b-765443ef6293http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/6079b49c-9da2-49d6-b32b-765443ef6293tpcolsonhttp://social.technet.microsoft.com/profile/tpcolson/?type=forumSpatial index hints don't work in SQL Server 2008?<p>Using the following</p>
<pre class="prettyprint">SELECT * FROM dbo.GRSM_WETLAND_POLY CROSS APPLY (SELECT TOP 1 Name, shape
FROM GRSM.dbo.GRSM_Trails --WITH(index S319_idx))
WHERE GRSM_Trails.Shape.STDistance(dbo.GRSM_WETLAND_POLY.Shape) IS NOT NULL
ORDER BY GRSM_Trails.Shape.STDistance(dbo.GRSM_WETLAND_POLY.Shape) ASC) fnc</pre>
<br/>
<pre class="lang-sql prettyprint"> </pre>
<p>runs very slow on 134 rows (56 seconds), however, with the index hint <br/>
uncommented, it returns</p>
<p><br/>
</p>
<blockquote>
<p>Msg 8635, Level 16, State 4, Line 3<br/>
The query processor could not produce <br/>
a query plan for a query with a spatial index hint. Reason: Spatial indexes do <br/>
not support the comparator supplied in the predicate. Try removing the index <br/>
hints or removing SET FORCEPLAN.</p>
</blockquote>
<p>Execution plan shows the filter cost at 98%, it's querying against 1400 rows <br/>
in the other table, so the total cost is 134 * 1400 individual seeks, which is <br/>
where the delay is. On their own, the spatial indexes in each table perform <br/>
great, with no fragmentation, 99% page fulness, and use medium for all 4 grid <br/>
levels with 16 cells per object. Changing the spatial index properties on either <br/>
table had no effect on performance. </p>
<p>Documentation suggests that spatial index hints can only be used in queries <br/>
in SQL Server 2012, but surely there's a work around for this?</p>Tue, 08 May 2012 00:31:39 Z2012-05-09T02:36:14Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/68271a9b-c462-40ef-b406-f8a0ad0a11aahttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/68271a9b-c462-40ef-b406-f8a0ad0a11aaSPEHEhttp://social.technet.microsoft.com/profile/spehe/?type=forumzoom and move map control<p>Hello,</p>
<p>when designing a report and using the Map .Net control, you can zoom the map and move it around. But when you run the report, it will be static in both size and position. Is it possible to let the users zoom and move the map after they have rendered the
report? </p>Thu, 03 May 2012 08:18:56 Z2012-05-03T09:47:22Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/28729874-1199-4dcb-a39b-bd63e504d93dhttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/28729874-1199-4dcb-a39b-bd63e504d93dswirl80http://social.technet.microsoft.com/profile/swirl80/?type=forumSpatial Data/Indexing performance issues<p><a href="http://www.sqlservercentral.com/Forums/Topic1292997-391-1.aspx">A</a>ny advice on this?</p>
<p><a href="http://www.sqlservercentral.com/Forums/Topic1292997-391-1.aspx">http://www.sqlservercentral.com/Forums/Topic1292997-391-1.aspx</a></p>
<p>thanks,</p>
<p>Chris</p>Tue, 01 May 2012 12:07:12 Z2012-05-02T10:13:13Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/8f053f4d-01d6-4550-99c5-72fa38b0a26chttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/8f053f4d-01d6-4550-99c5-72fa38b0a26cstrmshadowhttp://social.technet.microsoft.com/profile/strmshadow/?type=forumHow to convert a SQL geography column back to individual latitude and longitude?<p></p>
<p>I have some routes stored in a sql 2008 database as geography linestrings, basically a bunch of lat\long points. I need to draw these routes on bing maps, bing needs them as individual lat\long points.
</p>
<p>So how would I take them from the database into C# .net \ typed data set and iterate them. I can see them in the typed data set but it comes across as LINESTRING( -2.3234, 54.2323 ....). I could build a parser that takes the dataset LINESTRING
and converts it into lat\long but I'd hate to reinvent the wheel if there is built in way to do it. Thanks for any help <br/>
</p>Tue, 01 May 2012 22:11:22 Z2012-05-08T08:49:01Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/8bb8173c-1235-4102-bae7-3a01298c79a3http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/8bb8173c-1235-4102-bae7-3a01298c79a3aixchilehttp://social.technet.microsoft.com/profile/aixchile/?type=forumdata reader slow when performing spatial query<p>Good afternoon,</p>
<p>I have an odd issue with my data : I'm trying to perform a simple bounding box query, but fetching geometry data is longer than further processing the data.</p>
<p>Here is my code :</p>
<pre class="prettyprint">using (var conn = new SqlConnection("myconnectionstring"))
using (var cmd = new SqlCommand("SELECT geom FROM " + table, conn))
{
cmd.CommandType = System.Data.CommandType.Text;
using (var rdr = cmd.ExecuteReader())
{
DateTime start = DateTime.Now; // start timer
while (rdr.Read())
{ SqlGeometry geom = (SqlGeometry)rdr[0]; }
Debug.WriteLine("loaded in: " + (DateTime.Now - start).TotalMilliseconds); // around 50ms with 36000 records
}
}</pre>
<p>The fetch part (the while block) runs for 50ms.</p>
<p>Now, when I add a WHERE clause that includes everything and returns the same records (like WHERE geom.STIntersects(@TheWholeWorld) = 1), the same block takes 500ms (ten times slower).</p>
<pre class="prettyprint">using (var conn = new SqlConnection("myconnectionstring"))
using (var cmd = new SqlCommand("SELECT geom FROM " + table + " WHERE geom.STIntersects(@worldBBox) = 1", conn))
{
cmd.CommandType = System.Data.CommandType.Text;
using (var rdr = cmd.ExecuteReader())
{
DateTime start = DateTime.Now; // start timer
while (rdr.Read())
{ SqlGeometry geom = (SqlGeometry)rdr[0]; }
Debug.WriteLine("loaded in: " + (DateTime.Now - start).TotalMilliseconds); // now 500ms (!) with the same 36000 records
}
}</pre>
<br/>
<p></p>
<p>Do you know why this is happening ?</p>
<p>The aim is generating image tiles on the fly the .net way, and with this issue, on tiles with a lot of geometries, 75% of processing time is passed fetching data.</p>
<p><br/>
</p>
<br/>
<br/>Mon, 30 Apr 2012 14:40:35 Z2012-05-03T06:29:28Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/148d75c2-6f25-4799-958e-dddba9b3e6efhttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/148d75c2-6f25-4799-958e-dddba9b3e6efTek_Timhttp://social.technet.microsoft.com/profile/tek_tim/?type=forumSTUnion Resulting in huge number of vertices<p>Hello,</p>
<p>I am trying to merge to polygons using STUnion method. The resulting polygon seems to have a vertex where huge number of vertices are stacked over each other. Here is the code I am using to merge-</p>
<pre class="prettyprint">DECLARE @Polygon1 geometry
SET @Polygon1 = geometry::STPolyFromText('POLYGON ((-10553853.400672335 4002307.7175941337, -10553858.803142548 4002348.6219978333, -10553912.122381078 4002360.8854242279, -10553931.955673218 4002310.851436615, -10553853.400672335 4002307.7175941337))',3857)
DECLARE @Polygon2 geometry
SET @Polygon2 = geometry::STPolyFromText('POLYGON ((-10553858.204683276 4002344.09157344, -10553835.215061188 4002355.7880477905, -10553899.708805084 4002368.6270828247, -10553900.671458066 4002358.2518135007, -10553858.803119659 4002348.6220970154, -10553858.803115845 4002348.6220932007, -10553858.80311203 4002348.6220932007, -10553858.803108215 4002348.6220932007, -10553858.8031044 4002348.622089386, -10553858.803100586 4002348.622089386, -10553858.803096771 4002348.622089386, -10553858.803092957 4002348.6220855713, -10553858.803089142 4002348.6220855713, -10553858.803089142 4002348.6220817566, -10553858.803085327 4002348.6220817566, -10553858.803081512 4002348.6220779419, -10553858.803077698 4002348.6220741272, -10553858.803073883 4002348.6220741272, -10553858.803073883 4002348.6220703125, -10553858.803070068 4002348.6220664978, -10553858.803066254 4002348.6220664978, -10553858.803066254 4002348.6220626831, -10553858.803062439 4002348.6220588684, -10553858.803062439 4002348.6220550537, -10553858.803058624 4002348.6220550537, -10553858.80305481 400
2348.622051239, -10553858.80305481 4002348.6220474243, -10553858.803050995 4002348.6220397949, -10553858.80304718 4002348.6220321655, -10553858.80304718 4002348.6220283508, -10553858.803043365 4002348.6220207214, -10553858.803043365 4002348.622013092, -10553858.204683276 4002344.09157344))',3857)
var firstStandGeom = SqlGeometry.Parse(firstStandDTO.StandAreaPolygonWKT);
var secondStandGeom = SqlGeometry.Parse(secondStandDTO.StandAreaPolygonWKT);
double dist = firstStandGeom.STDistance(secondStandGeom).Value;
double buffer = Constants.SPLIT_MIN_BUFFER;
if (dist < Constants.SPLIT_MAX_BUFFER)
buffer = .01;
//buffer the two stands and merge them to avoid cases where really close polygons end up being multipolygons
//then buffer them negatively to offset the buffer done above
firstStandGeom = firstStandGeom.STBuffer(buffer)
.STUnion(secondStandGeom.STBuffer(buffer))
.STBuffer(-1 * buffer);
</pre>
<p>Any help on this will be highly appreciated.</p>
<p></p>
<p>Thanks</p>
<p></p>
<p>Apurva</p>
<pre class="prettyprint"><br/></pre>
<p></p>
<p></p>
<p></p>Mon, 30 Apr 2012 14:51:37 Z2012-05-02T07:00:36Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/10696d27-60d6-45bf-b8b0-ca2c55a50749http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/10696d27-60d6-45bf-b8b0-ca2c55a50749Trevor Danielhttp://social.technet.microsoft.com/profile/trevor%20daniel/?type=forumHelp with GeoCoding<p>Hello,</p>
<p>Can anyone give me some pointers on how to geocode an address in the UK to Lat/Long using SQL2008 please?</p>
<p>I have had a good search around but have not been able to find any help.</p>
<p>Many thanks</p>
<p>Trev</p>Mon, 30 Apr 2012 12:44:53 Z2012-05-01T02:42:34Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/1050b55e-ac29-4a79-9000-71cd0d04fdd7http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/1050b55e-ac29-4a79-9000-71cd0d04fdd7SPEHEhttp://social.technet.microsoft.com/profile/spehe/?type=forumHow to add a map to the map control?<p>Hello,</p>
<p>I am interesting in learning how to use the map object in SQL reporting services. Since I live in Sweden I would like to add a Swedish map. I have bought a shape file for Sweden which is supposed to contain information about the Swedish postal areas based
on the first two digits in the postal code (WGS 84). </p>
<p>Can anyone tell me how to use these files in SQL Reporting services so that I get a map just like the one that is included by default (USA)? Or maybe point me to documentation/tutorial on the subject?</p>Thu, 26 Apr 2012 19:21:23 Z2012-04-30T06:25:32Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/b9cebf36-46e9-443c-978c-2a76defa2487http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/b9cebf36-46e9-443c-978c-2a76defa2487Abdullah101http://social.technet.microsoft.com/profile/abdullah101/?type=forumHow to define an oval shape?<p>Hi all,</p>
<p>I'm trying to define an oval shape that looks like this:</p>
<p><img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/99377"></p>
<p>How can I do it using </p>
geography::STGeomFromText('
<div><wbr>CURVEPOLYGON(CIRCULARSTRING( ??????? )</div>
<p></p>
<p>??</p>
<p>Thanks for your help :)</p>Sat, 28 Apr 2012 05:12:27 Z2012-05-07T06:10:52Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/9d6a57ad-9e45-4ef5-80d2-7694423ae98chttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/9d6a57ad-9e45-4ef5-80d2-7694423ae98cZafar.Yousafihttp://social.technet.microsoft.com/profile/zafar.yousafi/?type=forumWhat SRID and Spatial Type Should I Use for this Prj file<p>Hi, I am trying to import Zillow neighborhood boundry shape files (http://www.zillow.com/howto/api/neighborhood-boundaries.htm) in my DB. I want to ask what data type should I use (geometry or geography) and what SRID should I Use for this</p>
<p></p>
<p>here is the prj file data</p>
<p>GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]</p>
<p></p>
<p>thanx</p>Thu, 26 Apr 2012 05:28:31 Z2012-04-27T07:09:20Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/7714d57e-bb79-40e8-8a37-ce999f2ac6d3http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/7714d57e-bb79-40e8-8a37-ce999f2ac6d3elisa puccionihttp://social.technet.microsoft.com/profile/elisa%20puccioni/?type=forumproblem when trying to insert a polygon in SQL Server table with MapInfo Easyloader<p>Hi All,</p>
<p>I'm using SQL Server 2008 R2 SP1 and the latest version of MapInfo (11.0.4). </p>
<p>With a tool called EasyLoader I'm trying to insert a polygon in a table of SQL Server that contains an insert trigger. The trigger is doing a quite long geographic query finding and saving in a new table all the points from an existent table that fall inside
the polygon inserted.</p>
<p>Everything was working fine till 1 month ago, then it stopped working without any apparent reason.</p>
<p>What's happening now is that EasyLoader can insert the polygon if there is no trigger or if the code inside the trigger is a fast query (such as update a field), but when the query starts to involve a long process, like the geographic one described before,
after about 30-45 seconds the program stops saying that the inserting was successful when instead is not.</p>
<p>If I'm inserting the polygon from another table using only SQL Server management studio, the trigger works smoothly, so it's not a problem of the coding, but it seems almost that a sort of timeout during the query kicks EasyLoader out.</p>
<p>Any idea?</p>
<p>Thanks,</p>
<p>Elisa</p>Wed, 25 Apr 2012 23:16:32 Z2012-04-27T01:23:27Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/29f9be82-30e8-4ad3-a247-5a08e5e1e668http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/29f9be82-30e8-4ad3-a247-5a08e5e1e668Abhijit- SQL2008http://social.technet.microsoft.com/profile/abhijit-%20sql2008/?type=forumNode to Node Connectivity<p>Hi,</p>
<p>i have a table named Roads it has </p>
<p>Roadtype smallint, RoadID Bigint , StartPoint Geometry, EndPoint Geometry and Geom Geometry Witch stores the polyline Data
</p>
<p>and now i want to Connect the Road to Road Dynamic Connection Withn the Procedure.
</p>
<p>any help how do i Draw the road within seconds. </p>
<p> </p>
<p>thanks</p>
<p></p>
<p></p>
<p></p>Thu, 26 Apr 2012 11:55:43 Z2012-05-04T04:18:27Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/cc5e75e1-7d50-4bfa-8bf7-fcb4acd7feb9http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/cc5e75e1-7d50-4bfa-8bf7-fcb4acd7feb9Babak Yaghoobihttp://social.technet.microsoft.com/profile/babak%20yaghoobi/?type=forumOut of memory in SQL Server 2012 Management Studio<p>Hi,</p>
<p>1)</p>
<p>I install SQL Server 2012 ( x64 bit) and i put it a very lot of spatial data (Geography data type)</p>
<p>then i import shapefiles into geography field and when i want to update records (774,000 record with 8,000,000 geography points!) with :</p>
<p></p>
<pre class="prettyprint lang-sql">UPDATE GIS
SET GeoPos = GeoPos.MakeValid()
WHERE GeoPos.STIsValid() = 0</pre>
<p>this take a 1h , 45 minutes !then </p>
<p>SQL Server Management Studio raise this error:</p>
<pre class="prettyprint lang-sql"><p></p><p>Msg 6532, Level 16, State 49, Line 5
.NET Framework execution was aborted by escalation policy because of out of memory.
The statement has been terminated.</p><p></p>
</pre>
<p>PC Memory : 4G</p>
<p>I test again this update on SQL Server 2008 R2 x64 ( with dbo.MakeValidGeographyFromText function. i get it from codeplex ) and work it without problem!</p>
<p>Is the bug in the SQL Server 2012 ?</p>
<p>Best Regards</p>
<br/>
<br/>Sun, 18 Mar 2012 22:16:13 Z2012-04-24T20:03:34Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/2a5189bc-2262-43fa-b39c-70195742c559http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/2a5189bc-2262-43fa-b39c-70195742c559Sonic.Jessyhttp://social.technet.microsoft.com/profile/sonic.jessy/?type=forumQuestion About Plotting Map USA Borders<p>I have a table with Million Points based on Latitude and Longitude. So when I run SQL Query it comes like this - its a Geo Data type plotten in points.
</p>
<p>Now I need an OUTLINE for US MAP so that it looks more pretty visually....how can i embed a Line String for the USA Borders in the same query.
</p>
<p></p>
<p>The table is really simpple: Customer_No, Long, Lat and Geography_Val (Geo data type)</p>
<p>Thanks</p>
<p><img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/96923"></p>Mon, 23 Apr 2012 20:58:28 Z2012-04-24T23:13:33Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/4962e25d-b76d-459b-8b4f-5a0905f9dc6ahttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/4962e25d-b76d-459b-8b4f-5a0905f9dc6aaixchilehttp://social.technet.microsoft.com/profile/aixchile/?type=forumSingle emisphere problem with Antarctica<p>Hello !</p>
<p>I have recently donwloaded shape files from Natural Earth Data (<a href="http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/110m-admin-0-scale-ranks.zip" target="_blank">110m scale ranks)</a></p>
<p>These are the shapes for all countries. All are importing OK except one : Antarctica.</p>
<p>Sql Server says (in french): Microsoft.SqlServer.Types.GLArgumentException: 24205 : l'entrée spécifiée ne représente pas d'instance géographique valide, car elle dépasse un seul hémisphère. Chaque instance géographique doit s'ajuster à un seul hémisphère.
Cette erreur a souvent pour origine une mauvaise orientation de l'anneau du polygone.<a href="http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/110m-admin-0-scale-ranks.zip" target="_blank"></a></p>
<p>This means that I broke the single emisphere rule. OK.</p>
<p>Now what is the good way for having it as a geography in my table ?</p>
<ul>
<li>Break it into single emisphere parts ?</li><li>Do something I didn't think about ?</li><li>Use geometry instead ?</li></ul>
<p>Other case is Russia that is crossing International Date Line...<br/>
</p>
<p>I'm looking for best pratices for that cases. </p>
<p>Thank you</p>
<p>Xavier</p>Thu, 19 Apr 2012 14:48:28 Z2012-04-24T11:27:29Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/9d75106a-b0d4-49cc-ac86-d41cba4ab797http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/9d75106a-b0d4-49cc-ac86-d41cba4ab797Dinand Kleijbeukerhttp://social.technet.microsoft.com/profile/dinand%20kleijbeuker/?type=forumRecieving error when converting Geometric data to Geographic data<p>hi,</p>
<p>I need to convert from Geometric data to Geographic datatypes, because I want to use the map (original shape file of the Netherlands) in an SSRS report with Bing layer. This requires the map to be of the Mercator type. (SRID 4326).</p>
<p>I already have the shape data in a SQL table.</p>
<p>Upon conversion I recieve the following error:</p>
<pre class="prettyprint">Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.
System.FormatException:
at Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types.Validator.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types.ForwardingGeoDataSink.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types.CoordinateReversingGeoDataSink.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types.WellKnownTextReader.ParseLineStringText()
at Microsoft.SqlServer.Types.WellKnownTextReader.ParsePolygonText()
at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)</pre>
<p>I've been going crazy on this and have already tried many suggestions like mentioned in : "Fixing Invalid Geography Data"<br/>
</p>
<p>Any suggestions are appreciated.</p>
<p>thx.</p>
<p>Dinand</p>Thu, 09 Feb 2012 22:11:08 Z2012-04-22T10:05:51Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/442469e0-8ca6-423f-83d4-b81ceb70fbe5http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/442469e0-8ca6-423f-83d4-b81ceb70fbe5didou13http://social.technet.microsoft.com/profile/didou13/?type=forumChange of geometry SRID<p>Hi All,</p>
<p>I have a database with several spatial data (wgs84 X and Y values, Lambert2 X and Y values and Geometry points (example
</p>
<span style="font-size:small">
<p>0xB46B0000010C000000002836134100000000A8ED4141 with a SRID of 27572).</p>
<p>I would like to create new columns with : geometry points (same as above) and X/Y values both with a SRID of 2154 (Lambert93) ?</p>
<p>What would be the best method to create these columns ?</p>
<p>Many thanks in advance</p>
<p></p>
</span><hr class="sig"><p>Didou13</p>Wed, 11 Apr 2012 13:54:03 Z2012-04-24T15:52:42Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/bc0eea0b-179f-4576-a690-28b9760b9dd8http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/bc0eea0b-179f-4576-a690-28b9760b9dd8Jamesdouglas101http://social.technet.microsoft.com/profile/jamesdouglas101/?type=forumConverting from GPS lat-lon to Wyoming East State Plane Coordinate system<p>I need help in getting around this problem:</p>
<p>I have the following coordinates in GPS Latitude and Longitude decimal and would like to convert them to Wyoming East State Planes Coordinate system with (FIPS Code 4901). I would be grateful for any suggestion/logic or code snippet in TSQL that I can modify
and use to create a stored procedure.</p>
<table border="0" cellpadding="0" cellspacing="0" width="295" style="width:221.0pt">
<tbody>
<tr style="height:15.0pt">
<td nowrap="nowrap" valign="bottom" width="99" style="width:74.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">GPSLatitude</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="103" style="width:77.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">GPSLongitude</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="93" style="width:70.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">GPS Elevation</span></p>
</td>
</tr>
<tr style="height:15.0pt">
<td width="99" style="width:74.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">N4409.7503</span></p>
</td>
<td width="103" style="width:77.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">W10523.8541</span></p>
</td>
<td width="93" style="width:70.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">1339.3</span></p>
</td>
</tr>
<tr style="height:15.0pt">
<td width="99" style="width:74.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">N4409.8183</span></p>
</td>
<td width="103" style="width:77.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">W10524.0288</span></p>
</td>
<td width="93" style="width:70.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">1428.6</span></p>
</td>
</tr>
<tr style="height:15.0pt">
<td width="99" style="width:74.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">N4409.1548</span></p>
</td>
<td width="103" style="width:77.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">W10524.2987</span></p>
</td>
<td width="93" style="width:70.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal"><span style="color:black">1361.8</span></p>
</td>
</tr>
<tr style="height:15.0pt">
<td width="99" style="width:74.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt"></td>
<td width="103" style="width:77.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt">
</td>
<td width="93" style="width:70.0pt; padding:0in 5.4pt 0in 5.4pt; height:15.0pt"></td>
<p></p>
<p></p>
<p></p>
</tr>
</tbody>
</table>Mon, 16 Apr 2012 21:33:55 Z2012-04-23T08:55:43Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/4c1d8712-c22e-4265-a4ba-996c25cd8970http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/4c1d8712-c22e-4265-a4ba-996c25cd8970lasahttp://social.technet.microsoft.com/profile/lasa/?type=forumGenerating SVG from WKT<p>I recently generated SVG (Scalable Vector Graphics) from the WKT (Well Known Text) representation of MULTIPOLYGONs. This was done in order to view some selected zip code areas and allow for further editing in vector based graphics programs. Seeing as it
was not all that difficult to achieve I thought it may be of interest to others as well. Below is an example of how it was done for the zip code areas, but I expect that not much modification would have to be made in order for it to work with other types of
areas as well. It should provide a good starting point for anyone who needs to produce SVG from WKT using SQL.<br/>
</p>
<pre class="prettyprint lang-sql">---------------------------------------- Generate SVG ------------------------------------
declare @xOffset varchar(42), @yOffset varchar(42);
select
@xOffset = CAST(-AVG(ZipCodeArea.STCentroid().STX) as DECIMAL(19,10)),
@yOffset = CAST(-AVG(ZipCodeArea.STCentroid().STY) as DECIMAL(19,10))
from
MyZipCodeAreaTable
where
left(ZipCode, 2) in ('41', '42', '43', '44');
declare @header varchar(max) =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' +
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">' +
'<g id="viewport" transform="translate(' + @xOffset + ', ' + @yOffset + ')">' +
'<g stroke="black" fill-rule="evenodd">';
declare @middler varchar(max) =
'</g>' +
'<g font-family="sans-serif" fill="black" text-anchor="middle" text-align="center" vertical-align="middle">';
declare @footer varchar(max) =
'</g>' +
'</g>' +
'</svg>';
declare @areas xml = (
select
ZipCode as [@id],
case ZipCode % 9
when 0 then '#99CC33'
when 1 then '#66CC33'
when 2 then '#339900'
when 3 then '#336600'
when 4 then '#FF6600'
when 5 then '#CC9900'
when 6 then '#FFCC33'
when 7 then '#FF9933'
when 8 then '#FFCC66'
end as [@fill],
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(ZipCodeArea.STAsText(),
'MULTIPOLYGON (((', 'M'),
')), ((', ' Z M'),
'), (', ' Z M'),
', ', ' L'),
')))', ' Z') as [@d]
from
MyZipCodeAreaTable
where
left(ZipCode, 2) in ('41', '42', '43', '44')
for xml path ('path')
);
declare @labels xml = (
select
cast(ZipCodeArea.STCentroid().STX as decimal(28,12)) as [@x],
cast(ZipCodeArea.STCentroid().STY as decimal(28,12)) as [@y],
cast(cast(case
when sqrt(ZipCodeArea.STArea())/5 < 10 then 10
else sqrt(ZipCodeArea.STArea())/5
end as int) as varchar(42)) + 'pt' as [@font-size],
cast(ZipCode as char(5))
from
MyZipCodeAreaTable
where
left(ZipCode, 2) in ('41', '42', '43', '44')
for xml path ('text')
);
select @header + cast(@areas as varchar(max)) + @middler + cast(@labels as
varchar(max)) + @footer;
</pre>
<br/>
<p><br/>
</p><hr class="sig"><p>Lars Rönnbäck -- http://www.anchormodeling.com -- An Agile Modeling Technique for Evolving Information</p>Tue, 10 Apr 2012 13:12:04 Z2012-04-18T01:49:35Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/566eee09-3af1-409d-af44-3350741985e1http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/566eee09-3af1-409d-af44-3350741985e1Sanket Guptehttp://social.technet.microsoft.com/profile/sanket%20gupte/?type=forumRouting using Geographic Data Types<p>I want to use OSM data (preferably) to perform routing entirely in SQL server... </p>
<p>I liked the articles by Alastair Aitchison <<a href="http://alastaira.wordpress.com/2011/02/09/loading-open-street-map-pois-with-sql-server-bing-maps/">Loading OSM to SQL</a>> and <<a href="http://alastaira.wordpress.com/2011/04/15/loading-open-street-map-data-in-sql-server-part-ii-ways/">Loading
OSM part-2</a>> and the one which was looking for.. <<a href="http://alastaira.wordpress.com/2011/04/27/categorising-open-street-map-road-types-for-display-and-routefinding/">Categorising and Route-finding</a>></p>
<p>I also found old forum posts which indicated, that Route calculation was not done by many people when the geography data type was introduced .. and SQL Server didn't have the functionality at that time... (Thats what I got from my research about it)... </p>
<p>I am also aware of "<a href="http://msdn.microsoft.com/en-us/library/ff929252(v=sql.110).aspx">ShortestLineTo</a>" function.... Have not tried it yet ..... </p>
<p>What I want to do is, based on my own weights given to the 'ways' (edges/roads/streets etc) of the network (Imported from OSM file), I want to perform routing, and wish to have 3-4 routes for each source-destination couples... I have my own Visualization
Software, to display vehicles running around on the map..... The input to my Visualization Software would be a text file which has set of routes calculated by SQL.</p>
<p>Routing is not the main purpose of my work, so I would rather use any pre-existing APIs/Engines/SQL-AddOns than write my own routing code.</p>
<p>If anyone who has implemented routing on SQL using OSM and kept as Open Source, I would be really glad to use it. I assure of proper acknowledgement to the coder.</p>
<p>I hope I m clear of what I intend to do.</p>
<p>Thanks a lot in advance.</p><hr class="sig">Sanket GupteFri, 24 Jun 2011 13:04:01 Z2012-04-17T08:14:53Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/2e4bf537-c852-401d-96c9-016d2cbff542http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/2e4bf537-c852-401d-96c9-016d2cbff542Runiehttp://social.technet.microsoft.com/profile/runie/?type=forumFind closest point to location <p>Hi Folks,</p>
<p>I need help to optimize my algorithm to calculate the distance the nearest coast (within a range of 2km) to a given real estate location.</p>
<p>I have a table - t1- containing the real estates and locations and another table - t2- containing coast lines and the 'STBuffer'ed value of the coast line called Coast2000. There is 1.2 mill records in table t1 and 1600 records in table t2 with
spatial index on Coast2000 using the high level grid setting.</p>
<p>I am using the following sql:</p>
<p> select a.ID, min(a.Location.STDistance(b.Coast_Location)) CoastDistance<br/>
from t1 a <br/>
join t2 b <br/>
on b.Coast2000.Filter(a.Location)=1 with(index(spix_buffer))<br/>
group by a.ID</p>
<p>However, this takes ages to run. Any ideas how to optimize this?<br/>
</p>Fri, 13 Apr 2012 11:27:36 Z2012-04-23T08:49:54Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/59729e0b-9de6-4a50-8ffb-0c39470306c8http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/59729e0b-9de6-4a50-8ffb-0c39470306c8GaroVhttp://social.technet.microsoft.com/profile/garov/?type=forumCreate ConvexHull polygon of polygons in table<p>Hi,</p>
<p></p>
<p>I have table that represent polygons and I have to create ConvexHull polygon. The problem is how to pick up all polygons from table into one geometry and then create a ConvexHull polygon!</p>
<p>Thanks!</p>Sun, 08 Apr 2012 10:27:11 Z2012-04-16T09:05:26Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/2317fa9c-fe23-4397-8134-e5b121867c2ehttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/2317fa9c-fe23-4397-8134-e5b121867c2eMayukh Royhttp://social.technet.microsoft.com/profile/mayukh%20roy/?type=forumFind angle in clockwise direction<p> I have 2 lines connected, represented by 3 points(LAT, LONG), and I want to find the angle between them. But not just the regular angle, I want to find the angle always in a CLOCKWISE motion.
</p>
<p>please suggest.</p>
<p>Thanks ..</p><hr class="sig"><p>Mayukh Roy</p>Mon, 02 Apr 2012 07:00:30 Z2012-04-09T02:56:26Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/13bca70a-fee9-4e36-a935-64371d3a538ahttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/13bca70a-fee9-4e36-a935-64371d3a538aJerryWalkershttp://social.technet.microsoft.com/profile/jerrywalkers/?type=forumBest way of displaying multiple polygons together?<p>Help Please,</p>
<p>I have a geometry data stored in Table W. What is the best way of showing all 400 multi polygons in sql server 2008r2 by the use of a query instead of manually loading the coordinates and displaying the polygons one by one? Thanks:</p>
<p>I have a sample bellow:
<table border="0" cellpadding="0" cellspacing="0" width="979" style="width:734pt; border-collapse:collapse">
<tbody>
<tr style="height:15pt">
<td nowrap="nowrap" valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">PK</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Xmax</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Xmin</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Ymax</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="92" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Ymin</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Bottom_Left</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Upper_Left</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="153" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Upper_Right</span></p>
</td>
<td nowrap="nowrap" valign="bottom" width="152" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">Lower_Right</span></p>
</td>
</tr>
<tr style="height:15pt">
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">1</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">134084</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">132893</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">388276</span></p>
</td>
<td valign="bottom" width="92" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">386410</span></p>
</td>
<td valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (132893 386410)</span></p>
</td>
<td valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (132893 388276)</span></p>
</td>
<td valign="bottom" width="153" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (134084 388276)</span></p>
</td>
<td valign="bottom" width="152" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (134084 386410)</span></p>
</td>
</tr>
<tr style="height:15pt">
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">2</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">133943</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">133364</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">388200</span></p>
</td>
<td valign="bottom" width="92" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">386746</span></p>
</td>
<td valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133364 386746)</span></p>
</td>
<td valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133364 388200)</span></p>
</td>
<td valign="bottom" width="153" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133943 388200)</span></p>
</td>
<td valign="bottom" width="152" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133943 386746)</span></p>
</td>
</tr>
<tr style="height:15pt">
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">3</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">133112</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">133079</span></p>
</td>
<td valign="bottom" width="64" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">386791</span></p>
</td>
<td valign="bottom" width="92" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">386756</span></p>
</td>
<td valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133079 386756)</span></p>
</td>
<td valign="bottom" width="163" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133079 386791)</span></p>
</td>
<td valign="bottom" width="153" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133112 386791)</span></p>
</td>
<td valign="bottom" width="152" style="padding-bottom:0in; padding-right:5.4pt; height:15pt">
<p align="center" style="text-align:center; line-height:normal; margin-bottom:0pt">
<span style="color:black">POINT (133112 386756)</span></p>
</td>
</tr>
</tbody>
</table>
</p>
<p></p>
<p></p>
<p></p>Wed, 04 Apr 2012 05:43:52 Z2012-04-10T02:57:35Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/f502242b-25a1-4f33-8ed0-cf522c58b02chttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/f502242b-25a1-4f33-8ed0-cf522c58b02cLeakyMemoryhttp://social.technet.microsoft.com/profile/leakymemory/?type=forumSDE to STGeometry<p>From a thread I posted to Esri Forum, trying to get some additional perspective. Obviously not specific to SQL ST, but nonetheless:</p>
<p>#################<br/>
</p>
<p><span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">I'll spare you the details, but I need to move an SDE Featureclass to SQL Spatial Type.</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">For various reasons I can't use Shape2SQL, nor a python script that I have to read/write geometries.</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">I need to move it using SSMS from my SDE DB to my plain ole regular SQL DB.</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Found some stuff online that said the following should work, but I get the following error:</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Msg 257, Level 16, State 3, Line 5</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Implicit conversion from data type geometry to varbinary is not allowed. Use the CONVERT function
to run this query.</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">declare @g varbinary(max);</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">set @g = 0x3200000001000000A6D0E5BEAA0681AFEFC0D713D4F705ECD5F30497E222BA049DB30597B1BB04B080B704ADEA</span></p>
<p><span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">018C3DA8F937DCDCD904FAC401;</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">declare @h geometry;</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">set @h = geometry::STGeomFromWKB(convert(geometry, @g), 3857)</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">select @h FEATURE_SHAPE</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Or the same implementation on the table directly, acting upon the same geometry as above:</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">SELECT</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">geometry::STGeomFromWKB(convert(geometry, points), 3857) as FEATURE_SHAPE</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">FROM [SDE_WORK_GIS].[sde].[f216]</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">where fid = 1</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Other methods result in errors indicating that the varbinary format is invalid.</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Read/writing to datatype geometry using python results in the following geometry binary, completely
different (kind of expect that since the datatypes are different):</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">0x110F0000010407000000AEB662F3667861C1091B9EE6B5464B418A8EE48E677861C10F0BB5CEB4454B41228E75FF</span></p>
<p><span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">637861C15AF5B9D2B4454B41637FD971637861C13EE8D9DC9E464B4153962162297861C152B81E9D9F464B419A999</span></p>
<p><span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">955297861C1D656EC87B6464B41AEB662F3667861C1091B9EE6B5464B4101000000020000000001000000FFFFFFFF0</span></p>
<p><span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">000000003</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Recently back from the Dev Summit where numerous Product Engineers and the like said this
could be done, and that SDE stores geometry in the same format as SQL ST. </span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Thoughts?</span><br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; text-align:left; background-color:#fafafa">Thanks in advance.</span><br/>
</p>
<p></p>
<br/>Sun, 01 Apr 2012 23:48:27 Z2012-04-02T16:48:46Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/e2cdccce-46e3-4941-a491-37fbe0e7a1f2http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/e2cdccce-46e3-4941-a491-37fbe0e7a1f2LatinChrizhttp://social.technet.microsoft.com/profile/latinchriz/?type=forumSQL Server 2008/2012 - Polygon with some near points covers the whole world<p>Hi!</p>
<p>I´m creating polygons out of a collection of points, but i have a weird situation in which the SQL Server return me the enitre World :-):</p>
<p>This Query:</p>
<p>SELECT geography::STPolyFromText('POLYGON ((9.6024305 47.58411, 9.5901797 47.5720098, 9.550566 47.5371757, 9.5319082 47.5357151, 9.5146841 47.5369248, 9.502768 47.5472144, 9.6024305 47.58411))', 4326)</p>
<p>The Management Studio 2008 shows nothing and isn´t able to render it, the Management Studio 2012 will show you a rect from -90 to +90 and from -180 to +180 :-).</p>
<p>Does anybody know what the error is ?</p>Sat, 31 Mar 2012 23:55:52 Z2012-04-01T22:19:28Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/7a77f938-6f64-452c-9866-7a0f96d4c661http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/7a77f938-6f64-452c-9866-7a0f96d4c661Gluck_Ghttp://social.technet.microsoft.com/profile/gluck_g/?type=forumRetrieve all coordinates that lie a certain distance from a linestring.<p>I need help in getting around this problem.</p>
<p>I have two tables that have GPS coordinate locations (X, Y, Z in separate columns as well as a geometry column, GP) known as TableA. The second TableB also have separe columns (Xs,Ys,Zs , Xe,Ye,Ze as the start and finish points of traverses and then a geometry
column GL, of linestrings formed from Xs,Ys,Zs , Xe,Ye,Ze). I can display the geometry as well as linestrings in sqlserver 2008r2 spatial results.
<br/>
My challenge is:</p>
<p>1.Bringing these two geometry points and linestrings together as one display when a query is run.<br/>
2.Get a logic/algorithm to retrieve all points that lie within a certain distance (for example x meters from the red linestring) so that they can be shown in both spatial results as well as in the business Intelligence environment of ss 2008r2.
Below is a sketch of the problem: I appreciate any suggestion.<img alt="" height="169" src="../getfile/87024" width="575"></p>Fri, 30 Mar 2012 21:43:57 Z2012-04-06T10:42:13Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/5c325662-ffb7-4f28-9a5f-af638af1440ahttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/5c325662-ffb7-4f28-9a5f-af638af1440aMayukh Royhttp://social.technet.microsoft.com/profile/mayukh%20roy/?type=forumImprove Accuracy of a Geographical POLYGON<p>Hi All,</p>
<p>The situation is like:</p>
<p>We have marked an area(POLYGON) with few points.{Say, it is POLYGON1}</p>
<p>Later, user wanted to mark the land/ POLYGON again with much more points.{Say, it is POLYGON2}</p>
<p><strong>Now, we need to improve the accuracy of the polygon using all the points. Can we merge these two Polygons somehow to improve the accuracy?</strong></p>
<p><em>[The main problem I am facing is while creating a new polygon with all the points(lat,long) used in POLYGON1 and POLYGON2. Can't get the proper Ordering to find the polygon. We can't neglect the POLYGON1. How to deal with?]</em></p>
<p>Any suggestion is appretiated. Thanks a lot in advance.</p>
<p></p><hr class="sig"><p>Mayukh Roy</p>Thu, 29 Mar 2012 14:31:15 Z2012-04-06T01:36:00Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/cca539b4-1821-48a9-813a-b33cf3ff2280http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/cca539b4-1821-48a9-813a-b33cf3ff2280Mayukh Royhttp://social.technet.microsoft.com/profile/mayukh%20roy/?type=forumHow to Calculate Angle Between 3 Geographical POINTs<p>Hi All,</p>
<p>I want to know, can we <strong>calculate angle between 3 Geographical points.</strong></p>
<p>Suppose A(-122.358, 47.653), B(-122.358, 47.753) and C(-121.358 47.653) are 3 points, and we need Angle(ABC).</p>
<p>Do we have any Geography functions for it?</p>
<p>THanks in advance..</p>
<br/>Wed, 28 Mar 2012 11:58:57 Z2012-03-30T06:33:28Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/57aa0855-d784-4b53-aaea-aed13e859f1fhttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/57aa0855-d784-4b53-aaea-aed13e859f1fMBebanhttp://social.technet.microsoft.com/profile/mbeban/?type=forumHow to derive a new GPS point that is a given direction and distance from an origin GPS point<p>How can I use the spatial features of SQL Server 2008 to take one GPS point and derive a new GPS point that is a specified distance and direction from that point? eg given a start long/lat location - I want to obtain an end long/lat location that is 1000m
due east.</p>
<p> </p>
<p>Can this be done using the geography/geometry methods?</p>Wed, 18 Jan 2012 23:35:13 Z2012-03-27T10:16:11Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/3ddc956c-2dce-4ba6-bebe-3fab69371878http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/3ddc956c-2dce-4ba6-bebe-3fab69371878Richard_Woodwardhttp://social.technet.microsoft.com/profile/richard_woodward/?type=forumOut of Memory when using STBuffer() on complex aggregated polygons<p>Hi chaps,</p>
<p>I am experiencing an out of memory issue when processing complex shapes that consist of smaller aggregated polygons. Firstly I will tell you how I got here.</p>
<p>I have a dataset that contains SQL geography polygons for every postcode in the UK. My goal is to create aggregate shapes for every possible postcode sector, these aggregate shapes need to load quickly so mustn't contain too many points (performance testing
I have carried out show acceptable performance with shapes that contain 250 points or less). Note that a postcode sector consists of the outcode + the first digit of the incode, e.g. the postcodes G53 7WQ, G53 7NL and G53 7ZD belong to the G53 7 postcode sector.</p>
<p>I calculated all possible sectors and used STUnion() in a cursor to create aggregate shapes for all postcode polygons that belong to that sector. I was left with some very complex postcode sector shapes, so I decided to reduce the complexity of these shapes
using the Reduce() function.</p>
<p>It is important that the reduced shapes do not lose coverage of any areas, or that any gaps appear between sectors, so I decided to use the STBuffer() function to buffer out the shape before reducing it (it is not a problem if a shape is a little too big,
but it is a problem the other way around). I buffered them out using the following script:</p>
<p><br/>
SET BufferedShape = Shape.STBuffer((SQRT(shape.STArea()))/100)</p>
<p>The idea behind this is that the amount I buffer out is related to the area of the shape, so for example if I used the above script on a square that was 100m by 100m then I would buffer out by 1m (the area is 100 x 100 = 10000m2, square root of 10000 is
100, divide by 100 = 1).</p>
<p>Unfortunately it is at this stage I come across the out of memory error. It only occurs when attempting to STBuffer() these very complex aggregate shapes, I have read that that this memory issue can occur when a buffer larger than the radius is supplied.</p>
<p>I have tried to divide the buffer task into smaller chunks and process and commit these chunks one at a time so to reduce the pressure on the VAS memory, but I have found that this doesn't make a difference as buffering a single complex geography can eat
all the memory on my machine (12GBs).</p>
<p>Could this be a problem specifically to do with multipolygons and buffering out some of the smaller polygons based on the STArea() of the geography value?</p>
<p>Has anyone else come across this problem? If so what method did you use to tackle it? Even if you have not experienced this problem, does anyone have any suggestions on how to deal with it?</p>
<p>Many thanks and apologies for the long post.</p>
<p>Richard</p>Mon, 30 Jan 2012 15:38:58 Z2012-03-22T11:59:28Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/6f324d50-dad7-4dcc-9a56-58ab2a7057b3http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/6f324d50-dad7-4dcc-9a56-58ab2a7057b3Kev Rileyhttp://social.technet.microsoft.com/profile/kev%20riley/?type=forumSimple Spatial query<p>Probably a simple question, but I'm just starting to 'play' with spatial data, and can't get my head round this.</p>
<p>Given the example data</p>
<pre class="prettyprint lang-sql">DECLARE @Towns TABLE
(
name VARCHAR(255) ,
location GEOGRAPHY
);
INSERT INTO @Towns VALUES
('Leeds', 'POINT(-1.58333 53.8)'),
('Preston', 'POINT(-2.7166667 53.766667)'),
('Altrincham', 'POINT(-2.35 53.383333)')
SELECT towns.name ,
towns.location
FROM @Towns AS towns</pre>
<br/>
<p>How do I 'draw' a line between each point.</p>
<p>I know I can hard code a line such as</p>
<p> geography::STGeomFromText('LINESTRING(-1.58333 53.8, -2.7166667 53.766667)',4326)</p>
<p>or</p>
<p> geometry::STGeomFromText('LINESTRING(-1.58333 53.8, -2.7166667 53.766667)',0)</p>
<p></p>
<p>But I thought I could read the data from the table (self joined) to get the data needed to draw the lines.</p>Wed, 21 Mar 2012 11:30:02 Z2012-03-21T14:24:44Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/0918974c-0b8a-4637-937a-995ef3356ba8http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/0918974c-0b8a-4637-937a-995ef3356ba8tanoshimihttp://social.technet.microsoft.com/profile/tanoshimi/?type=forumAsGml() to GeoRSSDoes anybody have an elegant way of taking the GML representation of a geometry object from the AsGml() method and turn it into a valid GeoRSS markup which can be consumed by, say Virtual Earth?<br><br>My current (very inelegant) method is as follows:<br><br>1.) Define a new variable @GeoRSS (xml datatype)<br>
<div style="text-align:left"><font size=2><span style="font-family:Courier">
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100%">Code Snippet</span></div>
<p>DECLARE @GeoRSS xml</p></div></div><br></span></font><br></div>2.) Retrieve the GML representation of objects and store them in the variable using<font size=2><span style="font-family:Arial"> the SELECT ... FOR XML construct</span><br style="font-family:Courier"></font>
<div style="text-align:left"><font size=2><span style="font-family:Courier">
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100%">Code Snippet</span></div>
<p>SET @GeoRSS = (SELECT 'title' AS title, 'description' as description, RadarGeography.AsGml() AS [where] FROM RadarStations FOR XML PATH('entry'), ROOT('feed'))<br><br></p></div></div></span></font><br style="font-family:Courier"><font size=2><span style="font-family:Courier"></span></font><br></div>3.) Use xquery modify method to insert <title>, <author> etc. elements at the beginning of the feed<br>
<div style="text-align:left"><font size=2><span style="font-family:Courier">
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100%">Code Snippet</span></div>
<p>SET @GeoRSS.modify('insert <title>SQL Server GeoRSS Feed</title> as first into (/feed)[1]')</p></div></div><br></span></font><br></div>4.) So far so good. Now here lies the problem.... the values returned by the AsGml() method are: <br>
<div style="text-align:left">
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100%">Code Snippet</span></div>
<p><Point><br> <pos>45.256 -71.92</pos><br></Point></p></div></div><br></div>Whereas GeoRSS expects:<br>
<div style="text-align:left">
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100%">Code Snippet</span></div>
<p><gml:Point><br> <gml:pos>45.256 -71.92</gml:pos><br></gml:Point></p></div></div><br></div><br>So basically for every child element of the <where> element (the alias I gave to the AsGml() column), I need to append the namespace gml: prefix - other than that the structure is identical.... the options I've considered are:<br>a.) Using xquery, but as far as I know while xquery can update the <span style="font-style:italic">values </span>of xml elements, it can't change the element names themselves. <br>b.) I could apply an XSL transformation, but to do that in SQL Server I would have to compile a .Net CLR assembly and I want to do this using tools that come 'out-of-the-box' with SQL Server alone. <br>c.) The answer may lie in the options of the SELECT ... FOR XML options, (like using the EXPLICIT switch) but I couldn't see how.<br><br>At the moment, I'm solving this by casting my (well-formed) xml statement into a varchar(max), then using a T-SQL REPLACE statement to update the <Point>, <Polygon>, <posList> element names etc. to include the <gml: prefix, before casting the whole thing back as xml again. It works, but.... Yuck!<br><br>Any suggestions would be much appreciated!<br><br>(For those not familiar, the schema of the GeoRSS GML profile can be found here - http://www.georss.org/xml/1.1/gmlgeorss.xsd)<br><br>A sample GeoRSS feed of a point object would be as follows:<br>
<div style="text-align:left">
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100%">Code Snippet</span></div>
<p><?xml version="1.0" encoding="utf-8"?><br><feed xmlns="http://www.w3.org/2005/Atom" <br> xmlns:georss="http://www.georss.org/georss" <br> xmlns:gml="http://www.opengis.net/gml"><br> <title>Earthquakes</title><br> <subtitle>International earthquake observation labs</subtitle><br> <link href="http://example.org/"/><br> <updated>2005-12-13T18:30:02Z</updated><br> <author><br> <name>Dr. Thaddeus Remor</name><br> <email>[email protected]</email><br> </author><br> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id><br> <entry><br> <title>M 3.2, Mona Passage</title><br> <link href="http://example.org/2005/09/09/atom01"/><br> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id><br> <updated>2005-08-17T07:02:32Z</updated><br> <summary>We just had a big one.</summary><br> <georss:where><br> <gml:Point><br> <gml:pos>45.256 -71.92</gml:pos><br> </gml:Point><br> </georss:where><br> </entry><br></feed></p></div></div><br></div><br><br>Tue, 01 Apr 2008 20:39:51 Z2012-03-21T07:15:00Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/38b9dc65-1c5d-4f5e-baca-e33e999e79cahttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/38b9dc65-1c5d-4f5e-baca-e33e999e79caWJRHhttp://social.technet.microsoft.com/profile/wjrh/?type=forumHow to STUnion a STIntersect <p></p>
<p>Please excuse if this has been covered elsewhere but I'm relatively new to Spatial elements within SQL Server.</p>
<p>I'm looking to create a proc in SQL server that when passed a simple polygon, will check a table to see if the new polygon intersects any existing polygons in that table. If it does, Union the polygon to the existing ones. If no intersect
exists add the original polygon to the table as a new record.</p>
<p>I think it sounds simple but am struggling to find a solution.</p>
<p>Many thanks for any help.</p>
<p>WJRH</p>Fri, 16 Mar 2012 02:44:31 Z2012-03-19T06:16:12Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/c7f95c9c-737b-4676-9f48-9ad40053cb0fhttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/c7f95c9c-737b-4676-9f48-9ad40053cb0fChamy07http://social.technet.microsoft.com/profile/chamy07/?type=forumconvert AsGML() into Georss<p>Hi I saw this post. i need the same thing but its urgent if someone can give me a basic structure i can modify it for my case.</p>
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0918974c-0b8a-4637-937a-995ef3356ba8">http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0918974c-0b8a-4637-937a-995ef3356ba8</a> </p>
<p>Just did not know how to use some of the contructs like for loop inside a stroed procedure to do the following thing</p>
<p> </p>
<p>for $child in /where</p>
<p>if (fn:local-name($child) = "Point") <br/>
then <gml:Point> { $child/* } </gml:Point></p>
<p style="font-family:Courier"><span style="font-size:x-small"><span style="font-size:10pt">else if (fn:local-name($child) = "LineString")
<br/>
then <gml:LineString> { $child/* } </gml:LineString></span></span></p>
<p style="font-family:Courier"><span style="font-size:x-small"><span style="font-size:10pt"><span>etc.</span></span></span></p>
<p><span style="font-size:x-small"><span style="font-family:Courier; font-size:10pt"><span>etc.</span></span></span></p>
<p>but if i can see a sample of working code i can easily learn the xquery and its structures</p>
<p> </p>
<p>Thanks</p>
<p>If you guys have sample code please post :)</p><hr class="sig">Chamy07Fri, 18 Mar 2011 15:19:10 Z2012-03-15T06:38:11Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/c56aafd1-1456-43ca-adb0-c46ae67aa43ahttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/c56aafd1-1456-43ca-adb0-c46ae67aa43aMontyBurnshttp://social.technet.microsoft.com/profile/montyburns/?type=forumSplitting/Tiling large numbers of Geography objects<p>We have a mapping application which is required to show shapes covering many areas worldwide - districts, in some countries, boroughs in others, etc. Entire countries can be covered.</p>
<p>We can't show all shapes at one time, for obvious performance reasons, so we have implemented what should be a nice tiling system, utilising the benefits of http caching. Shapes are received in ESRI shapefiles and are imported using a batch script
which runs Shape2Sql.exe and some SQL scripts. We then have a web interface which allows us to view the current set of 'tiles' or 'ShapeGroups'. It offers the ability to split each of these into smaller tiles. It's this last piece which we
think is causing us problems, as we appear to be missing some shapes.</p>
<p>Out splitting function is in C#:<br/>
</p>
<pre class="prettyprint">public IEnumerable<Viewport> SplitGrid(int times)
{
if (times == 1)
{
var medianX = MinX + ((MaxX - MinX) / 2D);
var medianY = MinY + ((MaxY - MinY) / 2D);
return new[]
{
new Viewport(MinX, MinY, medianX, medianY, Resolution),
new Viewport(MinX, medianY, medianX, MaxY, Resolution),
new Viewport(medianX, medianY, MaxX, MaxY, Resolution),
new Viewport(medianX, MinY, MaxX, medianY, Resolution)
};
}
return SplitGrid(1).SelectMany(_ => _.SplitGrid(times - 1));
}</pre>
<br/>
<p>So if a tile has a lot of shapes, we'll call SplitGrid passing the Id of that tile and an int saying how many times do you want to recursively loop and keep splitting. So SplitGrid(<id>, 1) would result in 4 tiles, SplitGrid(<id>,
2) will result in 16, etc.</p>
<p>What we appear to be seeing is gaps appearing - and we can only surmise that it's because we need to take into account geodesic/cartesian issues? Can anyone enlighten us and explain, and also if anyone knows the correct way to do this we'd really appreciate
a suggested solution.</p>
<p>Thanks,<br/>
Monty</p>
<br/>Tue, 13 Mar 2012 17:21:18 Z2012-03-15T11:27:03Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/6072d4d3-aa07-4c96-878a-7a15906241e0http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/6072d4d3-aa07-4c96-878a-7a15906241e0CK1286http://social.technet.microsoft.com/profile/ck1286/?type=forumHow to start working with spatial data<p>Hello,</p>
<p>I have a table with city, state, country ( mostly of united states) and then some count. the location columns are all varchar. I want to build a map with count as the value. I am just not sure how to get started. I read some articles on using spatial data
but just got very confused. SInce I have never used spatial data before, please guide me on how to do this. Thanks. </p>
<p>I would be using SSRS to build my map.</p>Sun, 04 Mar 2012 08:04:34 Z2012-03-08T19:36:47Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/1b39c327-8707-4c9d-bec2-69e1fda1999chttp://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/1b39c327-8707-4c9d-bec2-69e1fda1999crune007http://social.technet.microsoft.com/profile/rune007/?type=forumHow to do server side paging on data sets with spatial data?<p>Hi</p>
<p>I have some code which allows me to do server side paging on my data:</p>
<p><br/>
DECLARE @PageSize int, @PageNumber int;<br/>
SET @PageSize = 6;<br/>
SET @PageNumber = 2;</p>
<p>WITH SelectedNewsItems AS<br/>
(SELECT <br/>
Title, <br/>
ROW_NUMBER () OVER (ORDER BY COUNT(*) DESC, NewsItemID) AS SelectedRowNumber<br/>
FROM NewsItems <br/>
GROUP BY<br/>
NewsItemID, Title)</p>
<p>SELECT * FROM SelectedNewsItems<br/>
WHERE SelectedRowNumber BETWEEN ((@PageNumber - 1) * @PageSize) + 1 AND @PageNumber * @PageSize</p>
<p><br/>
My <strong>problem arises when I also want to return the POINT geography data in my dataset</strong>:</p>
<p><br/>
WITH SelectedNewsItems AS<br/>
(SELECT <br/>
Title, <br/>
<strong>PositionPoint</strong>,<br/>
ROW_NUMBER () OVER (ORDER BY COUNT(*) DESC, NewsItemID) AS SelectedRowNumber<br/>
FROM NewsItems <br/>
GROUP BY<br/>
NewsItemID, Title,<strong> PositionPoint</strong>)</p>
<p><br/>
I then get the error:</p>
<p>"<strong>The type "geography" is not comparable. It cannot be used in the GROUP BY clause</strong>."</p>
<p><br/>
<strong>What shall I do to do server side paging, but also return spatial data?</strong></p><hr class="sig"><p>rune007</p>Sun, 04 Mar 2012 18:21:07 Z2012-03-05T12:12:59Z
- http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/9e76aaef-43cf-4589-b0e4-c4939b480a38http://social.technet.microsoft.com/Forums/en-US/sqlspatial/thread/9e76aaef-43cf-4589-b0e4-c4939b480a38Przemo2http://social.technet.microsoft.com/profile/przemo2/?type=forumPolygon from point and with certain number of sides<p>Hi,</p>
<p></p>
<p>I need to create a polygon from point with given radius. This is my code</p>
<pre class="prettyprint lang-sql">DECLARE @g AS GEOGRAPHY = geography::STPointFromText('POINT(50 10)', 4326);
DECLARE @h AS GEOGRAPHY = @g.STBuffer(100)
SELECT @g as 'Geo', 'Point' AS 'Labels',@g.STAsText() as 'Text'
UNION ALL
SELECT @h, 'STBuffer(100)', @h.STAsText()
SELECT @h.STNumPoints(), 'NoPoints', ''</pre>
<br/>
<p><br/>
</p>
<p>Here are two questions:</p>
<p>1. Does .STBuffer(100) creates a radius of 100 meters? What does the unit comes from?</p>
<p>2. My polygon has 72 points ( returned by STNumPoints() ) How can I make a polygon with specific number of points/sides, for e.g. hexagon?</p>
<p></p>
<p>Thanks,</p>
<p>P.</p>Thu, 01 Mar 2012 08:13:48 Z2012-03-07T07:08:26Z