Postgesql 空间点聚合查询实验
短信预约 信息系统项目管理师 报名、考试、查分时间动态提醒
aggregate_build_data
create table tpoint(
gid serial primary key,
geom geometry(Point,4326)
);
create index tpoint_geom_idx on tpoint using gist(geom);
insert into tpoint(geom) SELECT st_setsrid((ST_Dump(p_geom)).geom,4326)
from (select ST_GeneratePoints(ST_GeomFromText("Polygon((117.357442 30.231278,119.235188 30.231278,119.235188 32.614617,117.357442 32.614617,117.357442 30.231278))"), 300000) as p_geom) as b
SELECT width_bucket(st_x(geom), 117.057442 ,119.235188 ,20) grid_x, width_bucket(st_y(geom), 30.431278 , 32.614617, 20) grid_y,
count(*), st_centroid(st_collect(geom)) geom, array_agg(gid) gids
from tpoint where st_x(geom) between 117.057442 and 119.235188 and st_y(geom) between 30.431278 and 32.614617 GROUP BY grid_x,grid_y
aggregate_search
SELECT width_bucket(st_x(geom), 117.057442 ,119.235188 ,20) grid_x, width_bucket(st_y(geom), 30.431278 , 32.614617, 20) grid_y,
count(*), st_centroid(st_collect(geom)) geom, array_agg(gid) gids
from tpoint where st_x(geom) between 117.057442 and 119.235188 and st_y(geom) between 30.431278 and 32.614617 GROUP BY grid_x,grid_y
width_bucket说明:
aggregate effects
参考阅读
PostgreSQL 9.6.0 手册 http://www.postgres.cn/docs/9.6/functions-math.html
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341