【发布时间】:2017-02-22 04:33:51
【问题描述】:
我正在尝试创建从点缓冲区生成的多边形的视图或表格,并根据年份对所有多边形进行分组。 源表中的数据字段:
point_id(int), point_created(date), geom geometry(Point,3301)
1, 2014-05-09, point
2, 2015-01-01, point
2, 2015-02-05, point
3, 2016-02-05, point
4, 2017-02-10, point
我能够创建表,在该表中按年份对所有点进行分组并将缓冲区生成为多面体,但我需要根据年份之间的日期对点进行分组(将超过一年的点组合在一起),因此表必须如下所示:
polygon(geom), nr_of_features(int), year(string)
1, 1, 2014(all point from 2014)
2, 3, 2015(all points from 2014 to 2015)
3, 4, 2016(all points from 2014 to 2016)
4, 5, 2017(all points from 2014 to 2017)
我现在正在使用的脚本:
CREATE TABLE my_new_table as
SELECT ST_Union(ST_Buffer(geom,10))::geometry(MultiPolygon,3301) as polygon,count(point_id)::integer as nr_of_features,
extract(year from point_created) as year
FROM my_table
group by year;
欢迎任何帮助。
【问题讨论】:
标签: postgresql