【问题标题】:Find length of geometry line after it intersects with geometry polygon using STIntersect使用 STIntersect 查找几何线与几何多边形相交后的长度
【发布时间】:2013-01-01 02:28:23
【问题描述】:
SQL SERVER 2012

在使用STIntersect 将线与多边形几何相交后,我需要找到线的几何长度。
例如,我有一条 7731 米长的线,但我 STIntersect 将它与一组多边形相对,我需要找出每个多边形中线的长度。

输出表看起来像

ReferenceID    PolygonID   LineID   Length
12324          3234        24661    1635
12325          3233        24652     663
12326          3236        24653     256
12327          3365        24634     165

目前使用这个但不能返回几何和长度

insert [VMS_OBS_LINES_INTERSECT] (CA_Reference_Key, STAT_AREA,WATERS,GNMFSAREA, Grid_ID, Length)select l.CA_Reference_Key,g.stat_area,g.waters, g.GNMFSAREA , g.Grid_ID, g.shape.STIntersection(l.shape).STLength()
FROM GRID_AREA_SQL g, VMS_OBS_COMBINE_LINES_AI l
WHERE g.shape.STIntersects(l.shape) = 1;

【问题讨论】:

  • 这能回答你的问题吗? stackoverflow.com/questions/13259215/…>

标签: sql-server geometry spatial intersect


【解决方案1】:
declare @g geometry, @l geometry;

select @g = geometry::STGeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))', 0), --10x10 box
       @l = geometry::STGeomFromText('LINESTRING( -10 -10 , 20 20 )', 0); --a line that will go through the corners of the box

select @g.STIntersection(@l).STLength();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 2013-07-08
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多