@dsh-gis/dsh-opengis-skill 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +19 -0
- package/CHANGELOG.md +96 -0
- package/LICENSE +21 -21
- package/README.md +91 -30
- package/THIRD_PARTY_NOTICES.md +37 -10
- package/assets/gdal/reference/raster-tools.md +538 -538
- package/assets/gdal/reference/vector-tools.md +149 -149
- package/assets/gdal-api/reference/raster-api.md +424 -424
- package/assets/gdal-api/reference/vector-api.md +724 -724
- package/assets/geometry-api-net/reference/geometry-types.md +243 -243
- package/assets/geopandas/reference/core-api.md +221 -221
- package/assets/geotools/reference/raster-rendering.md +108 -108
- package/assets/geotools/reference/vector-io.md +149 -149
- package/assets/jts/reference/geometry-operations.md +303 -303
- package/assets/mapsui/SKILL.md +283 -283
- package/assets/opengis-all/reference/data-stages.md +608 -608
- package/assets/opengis-all/reference/workflow-cheatsheets.md +324 -324
- package/assets/opengis-utils-for-java/reference/common-tasks.md +384 -384
- package/assets/opengis-utils-for-net/reference/code-patterns.md +124 -124
- package/assets/opengis-utils-for-net/reference/util-classes.md +291 -291
- package/assets/pyqgis/reference/processing-rendering.md +292 -292
- package/assets/pyqgis/reference/vector-raster-layers.md +318 -318
- package/assets/qgis-process/SKILL.md +414 -414
- package/assets/qgis-process/reference/algorithm-cheatsheet.md +194 -194
- package/assets/shapely/reference/operations-reference.md +199 -199
- package/cordis.patch.yml +6 -3
- package/lib/catalog.d.ts +50 -0
- package/lib/catalog.js +238 -0
- package/lib/index.d.ts +47 -6
- package/lib/index.js +32 -44
- package/lib/markdown-links.d.ts +11 -0
- package/lib/markdown-links.js +103 -0
- package/lib/skill-file.js +104 -17
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +11 -5
- package/upstream.json +64 -2
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
# GeoPandas Core API Reference
|
|
2
|
-
|
|
3
|
-
GeoSeries and GeoDataFrame core API details split from SKILL.md.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 核心类 API
|
|
8
|
-
|
|
9
|
-
### GeoDataFrame
|
|
10
|
-
|
|
11
|
-
```python
|
|
12
|
-
gpd.GeoDataFrame(data=None, *args, geometry=None, crs=None, **kwargs)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
#### 备选构造器
|
|
16
|
-
|
|
17
|
-
| 方法 | 签名 |
|
|
18
|
-
|------|------|
|
|
19
|
-
| `GeoDataFrame.from_dict()` | `(data, geometry=None, crs=None, **kwargs)` |
|
|
20
|
-
| `GeoDataFrame.from_file()` | `(filename, **kwargs)` |
|
|
21
|
-
| `GeoDataFrame.from_features()` | `(features, crs=None, columns=None)` |
|
|
22
|
-
| `GeoDataFrame.from_postgis()` | `(sql, con, geom_col="geom", crs=None, ...)` |
|
|
23
|
-
| `GeoDataFrame.from_arrow()` | `(table, geometry=None, to_pandas_kwargs=None)` |
|
|
24
|
-
|
|
25
|
-
#### 核心属性
|
|
26
|
-
|
|
27
|
-
| 属性 | 说明 |
|
|
28
|
-
|------|------|
|
|
29
|
-
| `.geometry` | 活跃几何列 (GeoSeries) |
|
|
30
|
-
| `.crs` | 坐标参考系 (pyproj.CRS) |
|
|
31
|
-
| `.active_geometry_name` | 活跃几何列名 |
|
|
32
|
-
| `.total_bounds` | 整体边界 `[minx, miny, maxx, maxy]` |
|
|
33
|
-
| `.sindex` | 空间索引 (STRtree) |
|
|
34
|
-
|
|
35
|
-
#### 几何管理
|
|
36
|
-
|
|
37
|
-
| 方法 | 签名 |
|
|
38
|
-
|------|------|
|
|
39
|
-
| `set_geometry()` | `(col, drop=None, inplace=False, crs=None)` |
|
|
40
|
-
| `rename_geometry()` | `(col, inplace=False)` |
|
|
41
|
-
| `set_crs()` | `(crs=None, epsg=None, inplace=False, allow_override=False)` |
|
|
42
|
-
| `to_crs()` | `(crs=None, epsg=None, inplace=False)` |
|
|
43
|
-
| `estimate_utm_crs()` | `(datum_name="WGS 84")` → pyproj.CRS |
|
|
44
|
-
|
|
45
|
-
#### 空间操作(GeoDataFrame 级别)
|
|
46
|
-
|
|
47
|
-
| 方法 | 签名 |
|
|
48
|
-
|------|------|
|
|
49
|
-
| `dissolve()` | `(by=None, aggfunc="first", as_index=True, sort=True, method="unary", grid_size=None)` |
|
|
50
|
-
| `explode()` | `(column=None, ignore_index=False, index_parts=False)` |
|
|
51
|
-
| `sjoin()` | `(df, how="inner", predicate="intersects", lsuffix="left", rsuffix="right")` |
|
|
52
|
-
| `sjoin_nearest()` | `(right, how="inner", max_distance=None, distance_col=None, exclusive=False)` |
|
|
53
|
-
| `clip()` | `(mask, keep_geom_type=False, sort=False)` |
|
|
54
|
-
| `overlay()` | `(right, how="intersection", keep_geom_type=None, make_valid=True)` |
|
|
55
|
-
|
|
56
|
-
#### 序列化输出
|
|
57
|
-
|
|
58
|
-
| 方法 | 说明 |
|
|
59
|
-
|------|------|
|
|
60
|
-
| `to_file(filename, driver=None, ...)` | Shapefile/GPKG/GeoJSON 等 |
|
|
61
|
-
| `to_parquet(path, compression="snappy", geometry_encoding="WKB", ...)` | GeoParquet |
|
|
62
|
-
| `to_feather(path, ...)` | Feather |
|
|
63
|
-
| `to_json(na="null", show_bbox=False, to_wgs84=False, ...)` | GeoJSON 字符串 |
|
|
64
|
-
| `to_geo_dict(...)` | Python dict (FeatureCollection) |
|
|
65
|
-
| `to_wkb(hex=False)` | DataFrame (WKB) |
|
|
66
|
-
| `to_wkt()` | DataFrame (WKT) |
|
|
67
|
-
| `to_postgis(name, con, schema=None, if_exists="fail", ...)` | PostGIS |
|
|
68
|
-
| `to_arrow(geometry_encoding="WKB", ...)` | Arrow Table |
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
### GeoSeries
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
gpd.GeoSeries(data=None, index=None, crs=None, **kwargs)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
#### 备选构造器
|
|
79
|
-
|
|
80
|
-
| 方法 | 签名 |
|
|
81
|
-
|------|------|
|
|
82
|
-
| `GeoSeries.from_wkb()` | `(data, index=None, crs=None, on_invalid="raise")` |
|
|
83
|
-
| `GeoSeries.from_wkt()` | `(data, index=None, crs=None, on_invalid="raise")` |
|
|
84
|
-
| `GeoSeries.from_xy()` | `(x, y, z=None, index=None, crs=None)` |
|
|
85
|
-
| `GeoSeries.from_file()` | `(filename, **kwargs)` |
|
|
86
|
-
| `GeoSeries.from_arrow()` | `(arr, **kwargs)` |
|
|
87
|
-
|
|
88
|
-
#### 坐标访问器(仅限 Point)
|
|
89
|
-
|
|
90
|
-
`.x`, `.y`, `.z`, `.m` → pandas.Series
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
### 共享几何属性与方法(GeoDataFrame.geometry / GeoSeries)
|
|
95
|
-
|
|
96
|
-
#### 标量属性 → pandas.Series
|
|
97
|
-
|
|
98
|
-
| 属性 | 返回类型 | 说明 |
|
|
99
|
-
|------|---------|------|
|
|
100
|
-
| `.area` | float | 面积(CRS 单位) |
|
|
101
|
-
| `.length` | float | 长度/周长 |
|
|
102
|
-
| `.geom_type` | str | 几何类型名称 |
|
|
103
|
-
| `.is_valid` | bool | 几何有效性 |
|
|
104
|
-
| `.is_empty` | bool | 空几何检查 |
|
|
105
|
-
| `.is_simple` | bool | 不自相交 |
|
|
106
|
-
| `.has_z` | bool | 含 z 坐标 |
|
|
107
|
-
| `.bounds` | DataFrame | 每几何体 (minx, miny, maxx, maxy) |
|
|
108
|
-
| `.total_bounds` | array | 整体 (minx, miny, maxx, maxy) |
|
|
109
|
-
|
|
110
|
-
#### 几何属性 → GeoSeries
|
|
111
|
-
|
|
112
|
-
`.boundary`, `.centroid`, `.convex_hull`, `.envelope`, `.exterior`
|
|
113
|
-
|
|
114
|
-
#### 一元几何方法 → GeoSeries
|
|
115
|
-
|
|
116
|
-
| 方法 | 签名 |
|
|
117
|
-
|------|------|
|
|
118
|
-
| `buffer()` | `(distance, quad_segs=None, **kwargs)` |
|
|
119
|
-
| `simplify()` | `(tolerance, preserve_topology=True)` |
|
|
120
|
-
| `representative_point()` | `()` |
|
|
121
|
-
| `make_valid()` | `(method="linework", keep_collapsed=True)` |
|
|
122
|
-
| `normalize()` | `()` |
|
|
123
|
-
| `reverse()` | `()` |
|
|
124
|
-
| `segmentize()` | `(max_segment_length)` |
|
|
125
|
-
| `force_2d()` | `()` |
|
|
126
|
-
| `force_3d()` | `(z=0)` |
|
|
127
|
-
| `offset_curve()` | `(distance, quad_segs=8, join_style="round", mitre_limit=5.0)` |
|
|
128
|
-
| `minimum_rotated_rectangle()` | `()` |
|
|
129
|
-
| `minimum_bounding_circle()` | `()` |
|
|
130
|
-
| `maximum_inscribed_circle()` | `(tolerance)` |
|
|
131
|
-
| `concave_hull()` | `(ratio, allow_holes)` |
|
|
132
|
-
| `extract_unique_points()` | `()` |
|
|
133
|
-
| `remove_repeated_points()` | `(tolerance=0.0)` |
|
|
134
|
-
| `line_merge()` | `(directed=False)` |
|
|
135
|
-
| `set_precision()` | `(grid_size, mode="valid_output")` |
|
|
136
|
-
| `orient_polygons()` | `(exterior_cw=False)` |
|
|
137
|
-
| `constrained_delaunay_triangles()` | `()` |
|
|
138
|
-
|
|
139
|
-
#### 二元谓词 → Series[bool]
|
|
140
|
-
|
|
141
|
-
```text
|
|
142
|
-
contains(other, align=None) covers(other, align=None)
|
|
143
|
-
covered_by(other, align=None) crosses(other, align=None)
|
|
144
|
-
disjoint(other, align=None) intersects(other, align=None)
|
|
145
|
-
overlaps(other, align=None) touches(other, align=None)
|
|
146
|
-
within(other, align=None) contains_properly(other, align=None)
|
|
147
|
-
dwithin(other, distance, align=None)
|
|
148
|
-
geom_equals(other, align=None) geom_equals_exact(other, tolerance, align=None)
|
|
149
|
-
geom_equals_identical(other, align=None)
|
|
150
|
-
relate_pattern(other, pattern)
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
#### 二元几何运算 → GeoSeries
|
|
154
|
-
|
|
155
|
-
```text
|
|
156
|
-
difference(other, align=None) intersection(other, align=None)
|
|
157
|
-
symmetric_difference(other, align=None) union(other, align=None)
|
|
158
|
-
shortest_line(other, align=None) snap(other, tolerance, align=None)
|
|
159
|
-
shared_paths(other, align=None)
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
#### 距离方法 → Series[float]
|
|
163
|
-
|
|
164
|
-
```text
|
|
165
|
-
distance(other, align=None)
|
|
166
|
-
hausdorff_distance(other, align=None)
|
|
167
|
-
frechet_distance(other, align=None)
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
#### 线性参考
|
|
171
|
-
|
|
172
|
-
```text
|
|
173
|
-
interpolate(distance, normalized=False) → GeoSeries (线上的点)
|
|
174
|
-
project(other, normalized=False) → Series[float] (沿线距离)
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
#### 聚合方法
|
|
178
|
-
|
|
179
|
-
```text
|
|
180
|
-
union_all(method="unary", grid_size=None) → 单个 Shapely geometry
|
|
181
|
-
intersection_all() → 单个 Shapely geometry
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
#### 仿射变换 → GeoSeries
|
|
185
|
-
|
|
186
|
-
```text
|
|
187
|
-
affine_transform(matrix)
|
|
188
|
-
translate(xoff=0.0, yoff=0.0, zoff=0.0)
|
|
189
|
-
rotate(angle, origin="center", use_radians=False)
|
|
190
|
-
scale(xfact=1.0, yfact=1.0, zfact=1.0, origin="center")
|
|
191
|
-
skew(xs=0.0, ys=0.0, origin="center", use_radians=False)
|
|
192
|
-
transform(transformation, include_z=False)
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
#### 其他方法
|
|
196
|
-
|
|
197
|
-
| 方法 | 返回 | 说明 |
|
|
198
|
-
|------|------|------|
|
|
199
|
-
| `clip_by_rect(xmin, ymin, xmax, ymax)` | GeoSeries | 矩形裁剪 |
|
|
200
|
-
| `relate(other, align=None)` | Series[str] | DE-9IM 矩阵 |
|
|
201
|
-
| `count_coordinates()` | Series[int] | 坐标对数量 |
|
|
202
|
-
| `count_geometries()` | Series[int] | 多部件几何体部件数 |
|
|
203
|
-
| `get_coordinates()` | DataFrame | 提取所有坐标 |
|
|
204
|
-
| `hilbert_distance()` | Series | Hilbert 曲线距离 |
|
|
205
|
-
| `is_valid_reason()` | Series[str] | 无效原因 |
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
### 空间索引 (SpatialIndex)
|
|
210
|
-
|
|
211
|
-
```python
|
|
212
|
-
sindex = gdf.sindex
|
|
213
|
-
sindex.query(geometry, predicate=None, sort=False, distance=None)
|
|
214
|
-
sindex.nearest(geometry, max_distance=None, return_distance=False, return_all=True, exclusive=False)
|
|
215
|
-
sindex.valid_query_predicates # 有效谓词集合
|
|
216
|
-
sindex.size # 几何体数量
|
|
217
|
-
sindex.is_empty # 是否为空
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
1
|
+
# GeoPandas Core API Reference
|
|
2
|
+
|
|
3
|
+
GeoSeries and GeoDataFrame core API details split from SKILL.md.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 核心类 API
|
|
8
|
+
|
|
9
|
+
### GeoDataFrame
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
gpd.GeoDataFrame(data=None, *args, geometry=None, crs=None, **kwargs)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### 备选构造器
|
|
16
|
+
|
|
17
|
+
| 方法 | 签名 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| `GeoDataFrame.from_dict()` | `(data, geometry=None, crs=None, **kwargs)` |
|
|
20
|
+
| `GeoDataFrame.from_file()` | `(filename, **kwargs)` |
|
|
21
|
+
| `GeoDataFrame.from_features()` | `(features, crs=None, columns=None)` |
|
|
22
|
+
| `GeoDataFrame.from_postgis()` | `(sql, con, geom_col="geom", crs=None, ...)` |
|
|
23
|
+
| `GeoDataFrame.from_arrow()` | `(table, geometry=None, to_pandas_kwargs=None)` |
|
|
24
|
+
|
|
25
|
+
#### 核心属性
|
|
26
|
+
|
|
27
|
+
| 属性 | 说明 |
|
|
28
|
+
|------|------|
|
|
29
|
+
| `.geometry` | 活跃几何列 (GeoSeries) |
|
|
30
|
+
| `.crs` | 坐标参考系 (pyproj.CRS) |
|
|
31
|
+
| `.active_geometry_name` | 活跃几何列名 |
|
|
32
|
+
| `.total_bounds` | 整体边界 `[minx, miny, maxx, maxy]` |
|
|
33
|
+
| `.sindex` | 空间索引 (STRtree) |
|
|
34
|
+
|
|
35
|
+
#### 几何管理
|
|
36
|
+
|
|
37
|
+
| 方法 | 签名 |
|
|
38
|
+
|------|------|
|
|
39
|
+
| `set_geometry()` | `(col, drop=None, inplace=False, crs=None)` |
|
|
40
|
+
| `rename_geometry()` | `(col, inplace=False)` |
|
|
41
|
+
| `set_crs()` | `(crs=None, epsg=None, inplace=False, allow_override=False)` |
|
|
42
|
+
| `to_crs()` | `(crs=None, epsg=None, inplace=False)` |
|
|
43
|
+
| `estimate_utm_crs()` | `(datum_name="WGS 84")` → pyproj.CRS |
|
|
44
|
+
|
|
45
|
+
#### 空间操作(GeoDataFrame 级别)
|
|
46
|
+
|
|
47
|
+
| 方法 | 签名 |
|
|
48
|
+
|------|------|
|
|
49
|
+
| `dissolve()` | `(by=None, aggfunc="first", as_index=True, sort=True, method="unary", grid_size=None)` |
|
|
50
|
+
| `explode()` | `(column=None, ignore_index=False, index_parts=False)` |
|
|
51
|
+
| `sjoin()` | `(df, how="inner", predicate="intersects", lsuffix="left", rsuffix="right")` |
|
|
52
|
+
| `sjoin_nearest()` | `(right, how="inner", max_distance=None, distance_col=None, exclusive=False)` |
|
|
53
|
+
| `clip()` | `(mask, keep_geom_type=False, sort=False)` |
|
|
54
|
+
| `overlay()` | `(right, how="intersection", keep_geom_type=None, make_valid=True)` |
|
|
55
|
+
|
|
56
|
+
#### 序列化输出
|
|
57
|
+
|
|
58
|
+
| 方法 | 说明 |
|
|
59
|
+
|------|------|
|
|
60
|
+
| `to_file(filename, driver=None, ...)` | Shapefile/GPKG/GeoJSON 等 |
|
|
61
|
+
| `to_parquet(path, compression="snappy", geometry_encoding="WKB", ...)` | GeoParquet |
|
|
62
|
+
| `to_feather(path, ...)` | Feather |
|
|
63
|
+
| `to_json(na="null", show_bbox=False, to_wgs84=False, ...)` | GeoJSON 字符串 |
|
|
64
|
+
| `to_geo_dict(...)` | Python dict (FeatureCollection) |
|
|
65
|
+
| `to_wkb(hex=False)` | DataFrame (WKB) |
|
|
66
|
+
| `to_wkt()` | DataFrame (WKT) |
|
|
67
|
+
| `to_postgis(name, con, schema=None, if_exists="fail", ...)` | PostGIS |
|
|
68
|
+
| `to_arrow(geometry_encoding="WKB", ...)` | Arrow Table |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### GeoSeries
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
gpd.GeoSeries(data=None, index=None, crs=None, **kwargs)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### 备选构造器
|
|
79
|
+
|
|
80
|
+
| 方法 | 签名 |
|
|
81
|
+
|------|------|
|
|
82
|
+
| `GeoSeries.from_wkb()` | `(data, index=None, crs=None, on_invalid="raise")` |
|
|
83
|
+
| `GeoSeries.from_wkt()` | `(data, index=None, crs=None, on_invalid="raise")` |
|
|
84
|
+
| `GeoSeries.from_xy()` | `(x, y, z=None, index=None, crs=None)` |
|
|
85
|
+
| `GeoSeries.from_file()` | `(filename, **kwargs)` |
|
|
86
|
+
| `GeoSeries.from_arrow()` | `(arr, **kwargs)` |
|
|
87
|
+
|
|
88
|
+
#### 坐标访问器(仅限 Point)
|
|
89
|
+
|
|
90
|
+
`.x`, `.y`, `.z`, `.m` → pandas.Series
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### 共享几何属性与方法(GeoDataFrame.geometry / GeoSeries)
|
|
95
|
+
|
|
96
|
+
#### 标量属性 → pandas.Series
|
|
97
|
+
|
|
98
|
+
| 属性 | 返回类型 | 说明 |
|
|
99
|
+
|------|---------|------|
|
|
100
|
+
| `.area` | float | 面积(CRS 单位) |
|
|
101
|
+
| `.length` | float | 长度/周长 |
|
|
102
|
+
| `.geom_type` | str | 几何类型名称 |
|
|
103
|
+
| `.is_valid` | bool | 几何有效性 |
|
|
104
|
+
| `.is_empty` | bool | 空几何检查 |
|
|
105
|
+
| `.is_simple` | bool | 不自相交 |
|
|
106
|
+
| `.has_z` | bool | 含 z 坐标 |
|
|
107
|
+
| `.bounds` | DataFrame | 每几何体 (minx, miny, maxx, maxy) |
|
|
108
|
+
| `.total_bounds` | array | 整体 (minx, miny, maxx, maxy) |
|
|
109
|
+
|
|
110
|
+
#### 几何属性 → GeoSeries
|
|
111
|
+
|
|
112
|
+
`.boundary`, `.centroid`, `.convex_hull`, `.envelope`, `.exterior`
|
|
113
|
+
|
|
114
|
+
#### 一元几何方法 → GeoSeries
|
|
115
|
+
|
|
116
|
+
| 方法 | 签名 |
|
|
117
|
+
|------|------|
|
|
118
|
+
| `buffer()` | `(distance, quad_segs=None, **kwargs)` |
|
|
119
|
+
| `simplify()` | `(tolerance, preserve_topology=True)` |
|
|
120
|
+
| `representative_point()` | `()` |
|
|
121
|
+
| `make_valid()` | `(method="linework", keep_collapsed=True)` |
|
|
122
|
+
| `normalize()` | `()` |
|
|
123
|
+
| `reverse()` | `()` |
|
|
124
|
+
| `segmentize()` | `(max_segment_length)` |
|
|
125
|
+
| `force_2d()` | `()` |
|
|
126
|
+
| `force_3d()` | `(z=0)` |
|
|
127
|
+
| `offset_curve()` | `(distance, quad_segs=8, join_style="round", mitre_limit=5.0)` |
|
|
128
|
+
| `minimum_rotated_rectangle()` | `()` |
|
|
129
|
+
| `minimum_bounding_circle()` | `()` |
|
|
130
|
+
| `maximum_inscribed_circle()` | `(tolerance)` |
|
|
131
|
+
| `concave_hull()` | `(ratio, allow_holes)` |
|
|
132
|
+
| `extract_unique_points()` | `()` |
|
|
133
|
+
| `remove_repeated_points()` | `(tolerance=0.0)` |
|
|
134
|
+
| `line_merge()` | `(directed=False)` |
|
|
135
|
+
| `set_precision()` | `(grid_size, mode="valid_output")` |
|
|
136
|
+
| `orient_polygons()` | `(exterior_cw=False)` |
|
|
137
|
+
| `constrained_delaunay_triangles()` | `()` |
|
|
138
|
+
|
|
139
|
+
#### 二元谓词 → Series[bool]
|
|
140
|
+
|
|
141
|
+
```text
|
|
142
|
+
contains(other, align=None) covers(other, align=None)
|
|
143
|
+
covered_by(other, align=None) crosses(other, align=None)
|
|
144
|
+
disjoint(other, align=None) intersects(other, align=None)
|
|
145
|
+
overlaps(other, align=None) touches(other, align=None)
|
|
146
|
+
within(other, align=None) contains_properly(other, align=None)
|
|
147
|
+
dwithin(other, distance, align=None)
|
|
148
|
+
geom_equals(other, align=None) geom_equals_exact(other, tolerance, align=None)
|
|
149
|
+
geom_equals_identical(other, align=None)
|
|
150
|
+
relate_pattern(other, pattern)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### 二元几何运算 → GeoSeries
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
difference(other, align=None) intersection(other, align=None)
|
|
157
|
+
symmetric_difference(other, align=None) union(other, align=None)
|
|
158
|
+
shortest_line(other, align=None) snap(other, tolerance, align=None)
|
|
159
|
+
shared_paths(other, align=None)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### 距离方法 → Series[float]
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
distance(other, align=None)
|
|
166
|
+
hausdorff_distance(other, align=None)
|
|
167
|
+
frechet_distance(other, align=None)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### 线性参考
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
interpolate(distance, normalized=False) → GeoSeries (线上的点)
|
|
174
|
+
project(other, normalized=False) → Series[float] (沿线距离)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### 聚合方法
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
union_all(method="unary", grid_size=None) → 单个 Shapely geometry
|
|
181
|
+
intersection_all() → 单个 Shapely geometry
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### 仿射变换 → GeoSeries
|
|
185
|
+
|
|
186
|
+
```text
|
|
187
|
+
affine_transform(matrix)
|
|
188
|
+
translate(xoff=0.0, yoff=0.0, zoff=0.0)
|
|
189
|
+
rotate(angle, origin="center", use_radians=False)
|
|
190
|
+
scale(xfact=1.0, yfact=1.0, zfact=1.0, origin="center")
|
|
191
|
+
skew(xs=0.0, ys=0.0, origin="center", use_radians=False)
|
|
192
|
+
transform(transformation, include_z=False)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### 其他方法
|
|
196
|
+
|
|
197
|
+
| 方法 | 返回 | 说明 |
|
|
198
|
+
|------|------|------|
|
|
199
|
+
| `clip_by_rect(xmin, ymin, xmax, ymax)` | GeoSeries | 矩形裁剪 |
|
|
200
|
+
| `relate(other, align=None)` | Series[str] | DE-9IM 矩阵 |
|
|
201
|
+
| `count_coordinates()` | Series[int] | 坐标对数量 |
|
|
202
|
+
| `count_geometries()` | Series[int] | 多部件几何体部件数 |
|
|
203
|
+
| `get_coordinates()` | DataFrame | 提取所有坐标 |
|
|
204
|
+
| `hilbert_distance()` | Series | Hilbert 曲线距离 |
|
|
205
|
+
| `is_valid_reason()` | Series[str] | 无效原因 |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### 空间索引 (SpatialIndex)
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
sindex = gdf.sindex
|
|
213
|
+
sindex.query(geometry, predicate=None, sort=False, distance=None)
|
|
214
|
+
sindex.nearest(geometry, max_distance=None, return_distance=False, return_all=True, exclusive=False)
|
|
215
|
+
sindex.valid_query_predicates # 有效谓词集合
|
|
216
|
+
sindex.size # 几何体数量
|
|
217
|
+
sindex.is_empty # 是否为空
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
# GeoTools Raster and Rendering Reference
|
|
2
|
-
|
|
3
|
-
> 这是 [../SKILL.md](../SKILL.md) 的补充文件,收录 GeoTIFF 栅格处理与地图渲染输出示例。
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 栅格数据(GeoTIFF)
|
|
8
|
-
|
|
9
|
-
### 读取 GeoTIFF
|
|
10
|
-
|
|
11
|
-
```java
|
|
12
|
-
import org.geotools.gce.geotiff.GeoTiffReader;
|
|
13
|
-
import org.geotools.coverage.grid.GridCoverage2D;
|
|
14
|
-
|
|
15
|
-
File file = new File("data/dem.tif");
|
|
16
|
-
GeoTiffReader reader = new GeoTiffReader(file);
|
|
17
|
-
GridCoverage2D coverage = reader.read(null);
|
|
18
|
-
|
|
19
|
-
// 获取 CRS
|
|
20
|
-
CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem();
|
|
21
|
-
|
|
22
|
-
// 获取范围
|
|
23
|
-
ReferencedEnvelope envelope = new ReferencedEnvelope(coverage.getEnvelope());
|
|
24
|
-
|
|
25
|
-
// 获取像素值
|
|
26
|
-
double[] values = coverage.evaluate(
|
|
27
|
-
new DirectPosition2D(crs, 116.4, 39.9), (double[]) null
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
// 获取栅格图像
|
|
31
|
-
RenderedImage image = coverage.getRenderedImage();
|
|
32
|
-
|
|
33
|
-
reader.dispose();
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### 写入 GeoTIFF
|
|
37
|
-
|
|
38
|
-
```java
|
|
39
|
-
import org.geotools.gce.geotiff.GeoTiffWriter;
|
|
40
|
-
|
|
41
|
-
File output = new File("output/result.tif");
|
|
42
|
-
GeoTiffWriter writer = new GeoTiffWriter(output);
|
|
43
|
-
writer.write(coverage, null);
|
|
44
|
-
writer.dispose();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## 地图渲染
|
|
50
|
-
|
|
51
|
-
### 渲染为 PNG 图片
|
|
52
|
-
|
|
53
|
-
```java
|
|
54
|
-
import org.geotools.map.*;
|
|
55
|
-
import org.geotools.styling.*;
|
|
56
|
-
import org.geotools.renderer.lite.StreamingRenderer;
|
|
57
|
-
import java.awt.image.BufferedImage;
|
|
58
|
-
import java.awt.*;
|
|
59
|
-
|
|
60
|
-
// 创建地图
|
|
61
|
-
MapContent map = new MapContent();
|
|
62
|
-
map.setTitle("城市分布图");
|
|
63
|
-
|
|
64
|
-
// 添加矢量图层
|
|
65
|
-
Style style = SLD.createSimpleStyle(featureSource.getSchema());
|
|
66
|
-
map.addLayer(new FeatureLayer(featureSource, style));
|
|
67
|
-
|
|
68
|
-
// 渲染为图片
|
|
69
|
-
int width = 800, height = 600;
|
|
70
|
-
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
|
71
|
-
Graphics2D g2d = image.createGraphics();
|
|
72
|
-
g2d.setColor(Color.WHITE);
|
|
73
|
-
g2d.fillRect(0, 0, width, height);
|
|
74
|
-
|
|
75
|
-
StreamingRenderer renderer = new StreamingRenderer();
|
|
76
|
-
renderer.setMapContent(map);
|
|
77
|
-
renderer.paint(g2d, new Rectangle(width, height), map.getMaxBounds());
|
|
78
|
-
g2d.dispose();
|
|
79
|
-
|
|
80
|
-
// 保存
|
|
81
|
-
javax.imageio.ImageIO.write(image, "png", new File("output/map.png"));
|
|
82
|
-
map.dispose();
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### 使用 SLD 样式
|
|
86
|
-
|
|
87
|
-
```java
|
|
88
|
-
import org.geotools.styling.*;
|
|
89
|
-
import org.geotools.factory.CommonFactoryFinder;
|
|
90
|
-
|
|
91
|
-
StyleFactory sf = CommonFactoryFinder.getStyleFactory();
|
|
92
|
-
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
|
|
93
|
-
|
|
94
|
-
// 创建面填充样式
|
|
95
|
-
Fill fill = sf.createFill(ff.literal(new Color(0, 128, 255, 128)));
|
|
96
|
-
Stroke stroke = sf.createStroke(ff.literal(Color.BLACK), ff.literal(1.0));
|
|
97
|
-
PolygonSymbolizer sym = sf.createPolygonSymbolizer(stroke, fill, null);
|
|
98
|
-
|
|
99
|
-
Rule rule = sf.createRule();
|
|
100
|
-
rule.symbolizers().add(sym);
|
|
101
|
-
|
|
102
|
-
FeatureTypeStyle fts = sf.createFeatureTypeStyle(new Rule[]{rule});
|
|
103
|
-
Style style = sf.createStyle();
|
|
104
|
-
style.featureTypeStyles().add(fts);
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
1
|
+
# GeoTools Raster and Rendering Reference
|
|
2
|
+
|
|
3
|
+
> 这是 [../SKILL.md](../SKILL.md) 的补充文件,收录 GeoTIFF 栅格处理与地图渲染输出示例。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 栅格数据(GeoTIFF)
|
|
8
|
+
|
|
9
|
+
### 读取 GeoTIFF
|
|
10
|
+
|
|
11
|
+
```java
|
|
12
|
+
import org.geotools.gce.geotiff.GeoTiffReader;
|
|
13
|
+
import org.geotools.coverage.grid.GridCoverage2D;
|
|
14
|
+
|
|
15
|
+
File file = new File("data/dem.tif");
|
|
16
|
+
GeoTiffReader reader = new GeoTiffReader(file);
|
|
17
|
+
GridCoverage2D coverage = reader.read(null);
|
|
18
|
+
|
|
19
|
+
// 获取 CRS
|
|
20
|
+
CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem();
|
|
21
|
+
|
|
22
|
+
// 获取范围
|
|
23
|
+
ReferencedEnvelope envelope = new ReferencedEnvelope(coverage.getEnvelope());
|
|
24
|
+
|
|
25
|
+
// 获取像素值
|
|
26
|
+
double[] values = coverage.evaluate(
|
|
27
|
+
new DirectPosition2D(crs, 116.4, 39.9), (double[]) null
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// 获取栅格图像
|
|
31
|
+
RenderedImage image = coverage.getRenderedImage();
|
|
32
|
+
|
|
33
|
+
reader.dispose();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 写入 GeoTIFF
|
|
37
|
+
|
|
38
|
+
```java
|
|
39
|
+
import org.geotools.gce.geotiff.GeoTiffWriter;
|
|
40
|
+
|
|
41
|
+
File output = new File("output/result.tif");
|
|
42
|
+
GeoTiffWriter writer = new GeoTiffWriter(output);
|
|
43
|
+
writer.write(coverage, null);
|
|
44
|
+
writer.dispose();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 地图渲染
|
|
50
|
+
|
|
51
|
+
### 渲染为 PNG 图片
|
|
52
|
+
|
|
53
|
+
```java
|
|
54
|
+
import org.geotools.map.*;
|
|
55
|
+
import org.geotools.styling.*;
|
|
56
|
+
import org.geotools.renderer.lite.StreamingRenderer;
|
|
57
|
+
import java.awt.image.BufferedImage;
|
|
58
|
+
import java.awt.*;
|
|
59
|
+
|
|
60
|
+
// 创建地图
|
|
61
|
+
MapContent map = new MapContent();
|
|
62
|
+
map.setTitle("城市分布图");
|
|
63
|
+
|
|
64
|
+
// 添加矢量图层
|
|
65
|
+
Style style = SLD.createSimpleStyle(featureSource.getSchema());
|
|
66
|
+
map.addLayer(new FeatureLayer(featureSource, style));
|
|
67
|
+
|
|
68
|
+
// 渲染为图片
|
|
69
|
+
int width = 800, height = 600;
|
|
70
|
+
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
|
71
|
+
Graphics2D g2d = image.createGraphics();
|
|
72
|
+
g2d.setColor(Color.WHITE);
|
|
73
|
+
g2d.fillRect(0, 0, width, height);
|
|
74
|
+
|
|
75
|
+
StreamingRenderer renderer = new StreamingRenderer();
|
|
76
|
+
renderer.setMapContent(map);
|
|
77
|
+
renderer.paint(g2d, new Rectangle(width, height), map.getMaxBounds());
|
|
78
|
+
g2d.dispose();
|
|
79
|
+
|
|
80
|
+
// 保存
|
|
81
|
+
javax.imageio.ImageIO.write(image, "png", new File("output/map.png"));
|
|
82
|
+
map.dispose();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 使用 SLD 样式
|
|
86
|
+
|
|
87
|
+
```java
|
|
88
|
+
import org.geotools.styling.*;
|
|
89
|
+
import org.geotools.factory.CommonFactoryFinder;
|
|
90
|
+
|
|
91
|
+
StyleFactory sf = CommonFactoryFinder.getStyleFactory();
|
|
92
|
+
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
|
|
93
|
+
|
|
94
|
+
// 创建面填充样式
|
|
95
|
+
Fill fill = sf.createFill(ff.literal(new Color(0, 128, 255, 128)));
|
|
96
|
+
Stroke stroke = sf.createStroke(ff.literal(Color.BLACK), ff.literal(1.0));
|
|
97
|
+
PolygonSymbolizer sym = sf.createPolygonSymbolizer(stroke, fill, null);
|
|
98
|
+
|
|
99
|
+
Rule rule = sf.createRule();
|
|
100
|
+
rule.symbolizers().add(sym);
|
|
101
|
+
|
|
102
|
+
FeatureTypeStyle fts = sf.createFeatureTypeStyle(new Rule[]{rule});
|
|
103
|
+
Style style = sf.createStyle();
|
|
104
|
+
style.featureTypeStyles().add(fts);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|