2 PostGIS UDF hex-grid
https://github.com/minus34/postgis-scripts/tree/master/hex-grid
PostGIS不需要多介绍了,几十年的老牌GIS插件,在军方、科研、民用等各个领域有着非常广泛对应用。
如果你使用了PostGIS插件的话,在里面存储了不管是geometry, polygon还是其他的地图类型,都可以转换为六边形网格。
转换时使用这些定义好的UDF即可。
UDF使用方法
See the 2 sample usage scripts to see how to create a national hex grid, using the function.
UDF输入参数
Parameter
Description
areakm2
Area of each hexagon in square km. Note: output hexagon sizes can be off slightly due to coordinate rounding in the calcs.
xmin,ymin
Minimum coordinates of the grid extents (i.e. bottom, left).
xmax,ymax
Maximum coordinates of the grid extents (i.e. top, right).
inputsrid
The coordinate system (SRID) of the min/max coordinates.
workingsrid
The SRID used to process the hexagons:
SRID must be a projected coord sys (i.e. in metres) as the calcs require ints. Degrees are out.
Should be an equal area SRID - i.e. Albers or Lambert Azimuthal (e.g. Australia = 3577, US = 2163).
Using a Mercator projection will NOT return hexagons of equal area (don't try it in Greenland).
ouputsrid
The SRID of the output hexagons.
A set of hexagonal polygons as PostGIS geometries
转换基础,参考如下
https://trac.osgeo.org/postgis/wiki/UsersWikiGenerateHexagonalGrid
1. 在PostGIS中虽然也支持网格对象的描述方式,但是并不是使用网格编码的方法来进行几何运算(比如相交,包含,距离计算等),而是类似矢量的计算方法,因此不存在网格的精度问题,个人建议没有强需求的话,不必将几何图形转换为网格。
PostgreSQL GIS索引的原理请参考
《从难缠的模糊查询聊开 - PostgreSQL独门绝招之一 GIN , GiST , SP-GiST , RUM 索引原理与技术背景》
2. 如果是多种精度地图的切换(比如多个图层,每个图层代表一种地图精度),建议使用辐射的方式逐渐展开更精细的图层,以点为中心,逐渐辐射。(很多专业的地图软件是这样做的)
3. 如果要将图形转换为网格,可以使用geotools提供的java class来转换,也可以使用PostGIS的UDF来转换,当然PostgreSQL如果安装了pljava过程语言的话,可以直接在数据库中调用geotools提供的java class对图形进行转换。
4. pljava
https://tada.github.io/pljava/
1. geotools vector grid包
http://docs.geotools.org/latest/userguide/extension/grid.html
2. PostGIS 生成六边形网格的UDF
https://github.com/minus34/postgis-scripts/tree/master/hex-grid
3. PostGIS 生成六边形网格的算法基础
https://trac.osgeo.org/postgis/wiki/UsersWikiGenerateHexagonalGrid
4. 六边形几何公式
https://hexnet.org/content/hexagonal-geometry
阿里云数据库专家于巍荣获PostgreSQL中国技术大会“最具价值专家 MVP”奖
2023年3月3日,在由PostgreSQL中文社区主办的“第十二届PostgreSQL中国技术大会”上,阿里云数据库开源首席架构师于巍荣获“中国 PostgreSQL 最具价值专家 MVP”奖项。
喜讯!阿里云数据库PolarDB荣获第12届PostgreSQL中国技术大会“开源数据库杰出贡献奖”
2023年3月3日,由PostgreSQL中文社区主办的“第十二届PostgreSQL中国技术大会”在杭州隆重开幕。本次大会以“突破·进化·共赢 —— 安全可靠,共建与机遇”为主题,邀请了来自国内外的行业专家、企业家代表等,共见创新成果、共论国产数据库发展机遇。会上,PolarDB for PostgreSQL(简称PolarDB-PG )凭借在数据库开源领域的深耕布局和产品技术实力,荣获“开源数据库杰出贡献奖”。