本文介绍了几何列的SRID 0是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我将几何列添加到空间表中,并使用了某些msdn引用,最终将SRID指定为0,如下所示:

So I added geometry columns to a spatial table and using some of the msdn references I ended up specifying the SRID as 0 like so:

  update dbo.[geopoint] set GeomPoint = geometry::Point([Longitude], [Latitude], 0)

但是,我认为这是一个错误,但是在必须更新列之前,默认值为0实际是4326吗?只要我在查询上将SRID指定为0,该查询就可以使用,但是与我所拥有的地理位置字段相比,我得到的结果很奇怪... sys.spatial_reference_systems中不存在SRID 0,并且我无法搜集有关的任何信息.任何帮助将不胜感激.

However, I believe this was a mistake, but before having to update the column, is 0 actually the default = 4326? The query works as long as I specify the SRID as 0 on the query, but I'm getting weird results in comparison to the geography field I have... SRID 0 does not exist in sys.spatial_reference_systems and I haven't been able to dig up any information on it. Any help would be appreciated.

推荐答案

技术上不存在SRID为0的情况,这仅表示没有SRID,即,如果您忘记设置,则为默认值.因此,从技术上讲,只要两组几何的SRID为0,您仍然可以执行距离,交集和所有其他查询.如果您的一个几何字段的SRID为0,而另一组的SRID实际上存在,您很可能会得到非常奇怪的结果.我记得在这种情况下,即使没有从空间查询中得到任何结果时,我也挠挠过头,SQL Server也没有抱怨,只有0个结果(因为值得这样做的Postgis实际上会失败,并发出关于不匹配的SRID的警告).

A SRID of 0 doesn't technically exist, it just means no SRID -- ie, the default if you forget to set it. So, technically, you can still perform distance, intersection and all other queries, so long as both sets of geometries have a SRID of 0. If you have one field of geometries with a SRID of 0 and another set with a SRID that actually exists, you will most likely get very strange results. I remember scratching my head once when not getting any results from a spatial query in exactly this situation and SQL Server did not complain, just 0 results (for what is is worth Postgis will actually fail, with a warning about non-matching SRIDs).

我认为,您应始终明确设置几何(或地理,自然始终为4326)的SRID,因为它不仅可以防止产生奇怪的查询结果,而且还意味着您可以将一个坐标系转换为其他.能够即时从经纬度(4326)转换为球形墨卡托(3857),如米制的Google Maps/Bing或其他局部坐标系(例如27700,British National Grid)以米为单位,可能非常有用.据我所知,SQL Server不支持从一种SRID转换为另一种SRID,但是由于空间类型本质上是CLR类型,因此如果需要,可以使用.NET库,请参见.

In my opinion, you should always explicitly set the SRID of your geometries (or geographies, which naturally will always be 4326), as not only does it prevent strange query results, but it means you can convert from one coordinate system to another. Being able to convert on the fly from lat/lon (4326), to Spherical Mercator (3857), as used in Google Maps/Bing, which is in meters, or some local coordinate system, such as 27700, British National Grid, also in meters, can be very useful. SQL Server does not to my knowledge support conversion from one SRID to another, but as spatial types are essentially CLR types, there are .NET libraries available should you ever need to do so, see Transform/ Project a geometry from one SRID to another for an example.

如果您决定更改几何形状,则可以执行以下操作:

If you do decide to change you geometries, you can do something like:

UPDATE your_table SET newGeom = geometry::STGeomFromWKB(oldGeom.STAsBinary(), SRID);

这将创建一个新列或就位:

which will create a new column or to do it in place:

UPDATE geom SET geom.STSrid=4326;

其中4326只是一个示例SRID.

where 4326 is just an example SRID.

http://spatialreference.org/上有关于SRID的很好的参考,尽管这基本上是相同的您在sys.spatial_reference_systems中找到的信息.

There is a good reference for SRIDs at http://spatialreference.org/, though this is essentially the same information as you find in sys.spatial_reference_systems.

这篇关于几何列的SRID 0是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 03:40