24 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Skill: td_grid 栅格基础维表计算指导
## 1. 实现目标
基于 ODS 层 OTT 数据,生成全量唯一的 20m 栅格基础信息及其空间几何对象。
## 2. 计算环境与流转
- **主计算侧**HiveSQL
- **持久化侧**PostgreSQL (PG)
- **流转逻辑**Hive 侧完成 WKT 生成 -> 同步至 PG 生成几何索引 -> 备份一份回 Hive 支撑后续聚合。
## 3. 核心计算逻辑
- **数据源**`ODS_OTT_GRID`
- **唯一性**:提取全量不重复的 `regionid` 序列。
- **WKT 构造 (关键)**
- 采用“中心点坐标偏移法”。
- 顶点坐标 = `(center_lon ± x_offset_20 / 2, center_lat ± y_offset_20 / 2)`
- **严禁**进行米/度单位转换,直接使用 ODS 中给出的坐标偏移值。
- **几何生成**PG 侧利用 `ST_GeomFromText(grid_wkt, 4326)` 转换为 `grid_geom`
## 4. 索引优化 (PG 侧)
-`grid_geom` 建立 `GIST` 空间索引。
-`regionid` 建立 `B-TREE` 唯一索引。
-`provincecode`, `citycode`, `districtcode` 建立复合索引。