ogr2ogr导入导出数据。
生活随笔
收集整理的這篇文章主要介紹了
ogr2ogr导入导出数据。
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.導(dǎo)入shp數(shù)據(jù)
ogr2ogr -f "PostgreSQL" -sql "SELECT ISO2, NAME FROM TM_WORLD_BORDERS_3 WHERE REGION=2 " -nlt MULTIPOLYGON PG:"host=localhost port=5432 dbname=postgis_32_sample user=postgres password=postgres schemas=public" -nln africa_countries -lco GEOMETRY_NAME=the_geom TM_WORLD_BORDERS_3.shp其中,參數(shù)的含義如下:
| -f? | 表示輸出文件類型。 |
| -sql | 表示要執(zhí)行的sql語句。 |
| ?-nln | 圖層的名稱 |
| ?-nlt | 圖層定義的幾何類型 |
2.查找日照時(shí)間最長(zhǎng)的100個(gè)地區(qū)。
select ST_AsText(the_geom) AS the_geom, bright_t31 from global_24h order by bright_t31 desc limit 100;在pgAdmin中的查詢結(jié)果如下:
3.查找非洲日照時(shí)間最長(zhǎng)的100個(gè)地區(qū)。
select ST_AsText(f.the_geom) AS the_geom, f.bright_t31, ac.iso2, ac.name from global_24h as f join africa_countries as ac on ST_Contains(ac.the_geom, ST_Transform(f.the_geom,4326)) order by f.bright_t31 desc limit 100;在pgAdmin中的查詢結(jié)果如下:
4.將查詢結(jié)果以GeoJson的格式導(dǎo)出
ogr2ogr -f "GeoJSON" -t_srs EPSG:4326 warmest_hs.geojson -sql "select f.the_geom AS the_geom, f.bright_t31, ac.iso2, ac.name from global_24h as f join africa_countries as ac on ST_Contains(ac.the_geom, ST_Transform(f.the_geom,4326)) order by f.bright_t31 desc limit 100" PG:"host=localhost port=5432 dbname=postgis_32_sample user=postgres password=postgres schemas=public"其中,參數(shù)-t_srs表示 在輸出上重新投影或轉(zhuǎn)換為 EPSG:4326 坐標(biāo)系下。
5.在QGIS中,查看africa_countries 和 warmest_hs.geojson 信息
總結(jié)
以上是生活随笔為你收集整理的ogr2ogr导入导出数据。的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++计算逆矩阵
- 下一篇: ae怎么设置gpu渲染_AE/PR ma