SDE 空間表操做

1. 建立空間表(包含st_geometry屬性字段)sql

CREATE TABLE sensitive_areas (area_id integer, name varchar(128), 
area_size float, type varchar(10), zone sde.st_geometry);

 

2. 建立空間參考spa

   (1)查詢空間參考表,是否存在對象

select * from SDE.ST_SPATIAL_REFERENCES

   (2)建立空間參考   --這裏是GCS_WGS_1984座標系,注意 srid 不能和已有的座標系重複blog

insert into SDE.ST_SPATIAL_REFERENCES (SR_NAME, SRID, X_OFFSET, Y_OFFSET, XYUNITS, Z_OFFSET, Z_SCALE, M_OFFSET, M_SCALE, MIN_X, MAX_X, MIN_Y, MAX_Y, MIN_Z, MAX_Z, MIN_M, MAX_M, CS_ID, CS_NAME, CS_TYPE, ORGANIZATION, ORG_COORDSYS_ID, DEFINITION, DESCRIPTION)
values ('GCS_WGS_1984', 0, -400, -400, 1000000000, -100000, 10000, -100000, 10000, -180, 180, -90, 90, 0, 0, 0, 0, 4326, 'GCS_WGS_1984', 'GEOGRAPHIC', 'GCS_WGS_1984', null, 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]', 'Default Spatial Reference SRID 0');

 

3. 插入數據 (注意座標系代碼要和咱們上面建立的保持一致,這裏爲 0)索引

  (1)點對象string

INSERT INTO SENSITIVE_AREAS (area_id, name, area_size, type, zone)
VALUES (1, 'Summerhill Elementary School', 67920.64, 'school', sde.ST_PointFromText('point(112.32 22.43)',0));

   (2)線對象it

INSERT INTO SENSITIVE_AREAS (area_id, name, area_size, type, zone)
VALUES (1, 'Summerhill Elementary School', 67920.64, 'school', sde.ST_LineFromText('linestring(112.32 22.43, 112.56 22.31, 112.62 22.78)', 0));

   (3)面對象io

INSERT INTO SENSITIVE_AREAS (area_id, name, area_size, type, zone)
VALUES (1, 'Summerhill Elementary School', 67920.64, 'school', sde.ST_PolyFromText('polygon((112.32 22.43, 112.56 22.31, 112.62 22.78, 112.32 22.43))', 1));

 

4. 建立空間索引class

CREATE INDEX sa_idx ON sensitive_areas(zone)
INDEXTYPE IS sde.st_spatial_index
PARAMETERS('st_grids=1,3,0 st_srid=0');

 

5. 其它數據操做select

  (1)更新空間字段

UPDATE sensitive_areas
SET zone = sde.st_pointfromtext('point(18 57)', 1) 
WHERE area_id = 102;

   (2)刪除一條記錄(和其它空間表進行空間分析)

DELETE FROM sensitive_areas WHERE names
(SELECT sa.names 
FROM sensitive_areas sa, hazardous_sites hs
WHERE sde.st_overlaps (sa.zone, sde.st_buffer (hs.location,.01)) = 1);
相關文章
相關標籤/搜索