是否可以使用SQL Server重新投影空间数据?


19

SQL Server在创建空间数据时会采用SRID,但是是否可以使用翻译坐标的其他SRID进行检索?

例如,假设我有一堆使用SRID 4258的空间多边形,但我想与SRID为4326的一些先前存在的数据一起使用-是否内置转换,或者我必须处理这个问题自己转换?

PostGIS实现的SQL-MM方法是ST_Transform。如何在SQL Server中做到这一点?


Answers:




6

从EPSG:2193投影到EPSG:3857的示例

c:\OSGeo4W64\bin\ogr2ogr.exe ^
 -f "MSSQLSpatial"^
 "MSSQL:server=DestServerName;database=DestDbName;trusted_connection=yes"^
 "MSSQL:server=SourceServerName;database=SourceDbName;trusted_connection=yes"^
 -sql "SELECT [Id], [Shape].STAsText() Shape FROM [SourceDbName].[dbo].[SourceTableName]"^
 -nln "DestTableName"^
 -overwrite^
 -s_srs EPSG:2193^
 -t_srs EPSG:3857

此后执行SQL查询

update  [DestDbName].[dbo].[DestTableName]
set     [ogr_geometry] =  geometry::STGeomFromText([shape], 3857)

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.