我有一个具有以下属性的表hospitals_healthcenters_jointed_to_evacuationzones
:
lat
纬度long_
经度我正在尝试创建一个将Point
和lat
组合在一起的几何数据类型列[C0
我使用了发现的以下代码:
long_
但出现以下错误:
ALTER TABLE hospitals_healthcenters_jointed_to_evacuationzones
ADD shape Point
;
UPDATE hospitals_healthcenters_jointed_to_evacuationzones
SET shape = Point("long_", "lat")
假设您使用的是PostgreSQL
已安装扩展名ERROR: function point(character varying, numeric) does not exist
LINE 4: SET shape = Point("long_", "lat");
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 157
,对于具有纬度和经度的点,存在PostGIS数据类型。
添加列:
geography
为每个记录更新列ALTER TABLE hospitals_healthcenters_jointed_to_evacuationzones
ADD COLUMN geo_point GEOGRAPHY(POINT,4326);
(基于列geo_point
,long
中的现有坐标:]
lat_
UPDATE hospitals_healthcenters_jointed_to_evacuationzones
SET geo_point = 'SRID=4326;POINT(' || long || ' ' || lat_ || ')';
的数据值以文本形式给出,请参见以下示例和说明:
'SRID =
point
; POINT(4326
)'
-71.104 42.315
的4326
(与GPS使用的相同,请参见WGS 84)没有安装PostGIS,您仍然具有geometric类型-71.104 42.315
。这种类型的值是使用几何转换函数point
构造的。
添加列:
point
更新每条记录的点(基于point(double precision, double precision)
类型的列ALTER TABLE hospitals_healthcenters_jointed_to_evacuationzones
ADD COLUMN geo_point POINT;
,double
中的现有坐标:] >>
,此(本机)几何点以后可以转换为geographic点。long
如果安装并应使用PostGIS
lat_