我有一个表mytable
,其坐标表示对象的Bounding BOX,作为geom_bbox
列中的文本字符串,如"548477,6591107,548493,6591121"
。以米为单位的EPSG3301坐标。我想用这些坐标创建一个多边形几何体,一个矩形几何体。
更多示例坐标:
"548477,6591107,548493,6591121"
"545827,6587929,545864,6588021"
"539646,6586576,539694,6586621"
"549054,6594762,549101,6594811"
"547131,6589014,547182,6589046"
"547131,6589014,547182,6589046"
PostGIS可以吗?
答案 0 :(得分:3)
如果只有边界框,请使用函数ST_MakeEnvelope。此功能从4个坐标(2个点)创建一个矩形。首先用string_to_array分割文本,然后使用结果作为坐标:
SELECT ST_MakeEnvelope(arr[1]::double precision,
arr[2]::double precision,
arr[3]::double precision,
arr[4]::double precision,
3301)
FROM (SELECT string_to_array(geom_bbox,',') AS arr FROM mytable) as foo;