Files
tldr/pages.zh/common/ogr2ogr.md

28 lines
1.1 KiB
Markdown
Raw Permalink 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.

# ogr2ogr
> 在文件格式之间转换地理空间矢量数据。
> 更多信息:<https://gdal.org/programs/ogr2ogr.html>。
- 将 Shapefile 转换为 GeoPackage
`ogr2ogr -f GPKG {{path/to/output.gpkg}} {{path/to/input.shp}}`
- 将 GeoJSON 减少到符合条件的特征:
`ogr2ogr -where '{{myProperty > 42}}' -f {{GeoJSON}} {{path/to/output.geojson}} {{path/to/input.geojson}}`
- 将 GeoPackage 的坐标参考系统从 `EPSG:4326` 更改为 `EPSG:3857`
`ogr2ogr -s_srs {{EPSG:4326}} -t_srs {{EPSG:3857}} -f GPKG {{path/to/output.gpkg}} {{path/to/input.gpkg}}`
- 将 CSV 文件转换为 GeoPackage指定坐标列的名称并分配坐标参考系统
`ogr2ogr -f GPKG {{path/to/output.gpkg}} {{path/to/input.csv}} -oo X_POSSIBLE_NAMES={{longitude}} -oo Y_POSSIBLE_NAMES={{latitude}} -a_srs {{EPSG:4326}}`
- 将 GeoPackage 加载到 PostGIS 数据库中:
`ogr2ogr -f PostgreSQL PG:dbname="{{database_name}}" {{path/to/input.gpkg}}`
- 将 GeoPackage 文件的图层裁剪到给定的边界框:
`ogr2ogr -spat {{min_x}} {{min_y}} {{max_x}} {{max_y}} -f GPKG {{path/to/output.gpkg}} {{path/to/input.gpkg}}`