sqlserver操作geography方法

--总表面积
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STArea()

--二进制(WKB)表示形式
SELECT geography::STGeomFromText('LINESTRING( -122.360 47.656, -122.343 47.656)', 4326).STAsBinary()

--WKT表示形式
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STAsText()

--缓冲区
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STBuffer(1)

--返回指定的曲线
SELECT geography::STGeomFromText('COMPOUNDCURVE (CIRCULARSTRING (-122.358 47.653, -122.348 47.649, -122.348 47.658), CIRCULARSTRING(-122.348 47.658, -122.358 47.658, -122.358 47.653))',4326).STCurveN(2)

--圆弧线段的多边形近似值
SELECT geography::STGeomFromText('CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)',4326).STCurveToLine()

--差集
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STDifference(geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326))

--最大维度
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STDimension()

--是否不相联
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STDisjoint(geography::STGeomFromText('POINT( -122.343 47.656)', 4326))

--距离
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STDistance(geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326))

--终点
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STEndPoint()

--判断是否相等
SELECT geography::STGeomFromText('GEOMETRYCOLLECTION(POLYGON((-122.368 47.658, -122.338 47.649, -122.338 47.658, -122.368 47.658, -122.368 47.658)), LINESTRING(-122.360 47.656, -122.343 47.656), POINT (-122.35 47.656))', 4326).STEquals(geography::STGeomFromText('POLYGON((-122.368 47.658, -122.338 47.649, -122.338 47.658, -122.368 47.658, -122.368 47.658))', 4326))

--查找GeometryCollection中第n个实例
SELECT geography::STGeomFromText('MULTIPOINT(-122.360 47.656, -122.343 47.656)', 4326).STGeometryN(2)

--类型
SELECT geometry::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STGeometryType()

--交集
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STIntersection(geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326))

--判断是否相交
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STIntersects(geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326))

--判断是否闭合
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STIsClosed()

--判断是否为空
SELECT geography::STGeomFromText('POLYGON EMPTY', 4326).STIsEmpty()

--判断是否为有效geography格式
SELECT geography::STGeomFromText('LINESTRING(0 0, 2 2, 1 0)', 4326).STIsValid()

--边长总长度
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STLength()

--一维geography曲线数
SELECT geography::STGeomFromText('COMPOUNDCURVE(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))',4326).STNumCurves()

--geometry数量
SELECT geography::STGeomFromText('MULTIPOINT((-122.360 47.656), (-122.343 47.656))', 4326).STNumGeometries()

--点数量
SELECT geography::STGeomFromText('GEOMETRYCOLLECTION(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653) ,CURVEPOLYGON(CIRCULARSTRING(-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)))', 4326).STNumPoints()

--指定点
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STPointN(2)

--空间参考
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STSrid

--起点
SELECT geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STStartPoint()

--余集
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STSymDifference(geography::STGeomFromText('POLYGON((-122.351 47.656, -122.341 47.656, -122.341 47.661, -122.351 47.661, -122.351 47.656))', 4326))

--并集
SELECT geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326).STUnion(geography::STGeomFromText('POLYGON((-122.351 47.656, -122.341 47.656, -122.341 47.661, -122.351 47.661, -122.351 47.656))', 4326))

转载于:https://www.cnblogs.com/guanshan/p/guan2017-04-19_1.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值