美文网首页开源
PG+PostGIS 空间查询

PG+PostGIS 空间查询

作者: 秋收拖拉机 | 来源:发表于2020-06-15 13:31 被阅读0次

    1、计算线路长度(米)
    SELECT patrolid, st_length(ST_Transform(geom,3857))
    FROM public.patrolrecord where patrolid='3d4f8e0d-e759-469f-b78e-50f6445b56c9'

    ST_Area(ST_Transform(geom,3857))

    2、空间相交计算
    判断点是否在面内:
    select ST_DWithin(ST_SetSRID(ST_MakePoint(117.272031,31.868486),4326),(SELECT geom from sxkwg where xzqhcode='340103009'),0)

    3、矩形查询
    _st_intersects(st_transform(ST_MakeEnvelope(" + leftTopX + "," + leftTopY + "," + rightBottomX + "," + rightBottomY + ",4326" + "),4326),geom)

    4、多边形查询
    SELECT gid,year,cc,gb,ec,name,type,cc,gb,ec,name,type,st_astext(geom) wkt FROM V_ARCP where ST_Intersects(st_geometryfromtext('wkt',4326), geom) and year='2017'

    相关文章

      网友评论

        本文标题:PG+PostGIS 空间查询

        本文链接:https://www.haomeiwen.com/subject/jqicxktx.html