zoukankan      html  css  js  c++  java
  • 【Postgres】根据字段数据创建空间字段

    
    
    --添加空间字段
    SELECT AddGeometryColumn ('GIS', '四至', 4326, 'POLYGON', 2);
    
    --根据其他字段更新空间字段数据
    update "GIS" b 
    set "四至"=ST_GeomFromText ('POLYGON((' || to_char(a."东经起",'999.9999') || to_char(a."北纬起",'999.9999') || ',' || to_char(a."东经止",'999.9999') || to_char(a."北纬起",'999.9999') || ',' || to_char(a."东经止",'999.9999') || to_char(a."北纬止",'999.9999') ||',' || to_char(a."东经起",'999.9999') || to_char(a."北纬止",'999.9999') || ',' || to_char(a."东经起",'999.9999') || to_char(a."北纬起",'999.9999') || '))',4326)
    from "GIS" a
    where b."ID"=a."ID"
    
    --创建索引
    CREATE INDEX shape_index_sz1
    ON "GIS"
    USING gist
    (四至); 
    
    --查询与指定范围相交的多边形
    SELECT * FROM "GIS" where 
    ST_Intersects(
    ST_GeomFromText('POLYGON((86 44.1667,87.3333 44.1667,87.3333 45.1667,86 45.1667,86 44.1667))'), ST_GeomFromText(ST_AsText("四至")))
    
     
  • 相关阅读:
    例2-3
    例2-2
    例2-1
    p14
    第一次作业
    例1-1
    第二次作业(2)
    第二次作业
    第三章3-3
    第三章3-2
  • 原文地址:https://www.cnblogs.com/defineconst/p/10855022.html
Copyright © 2011-2022 走看看