GDAL——命令使用專題——gdalsrsinfo命令html
前言數據庫
GDAL(Geospatial Data Abstraction Library)是一個在X/MIT許可協議下的開源柵格空間數據轉換庫。它利用抽象數據模型來表達所支持的各類文件格式。它還有一系列命令行工具來進行數據轉換和處理。api
主要針對:ogrinfo命令、gdalinfo命令、gdalsrsinfo命令、gdallocationinfo命令、gdal_translate命令、gdaltransform命令 等。這一節討論gdalsrsinfo命令。app
gdalsrsinfo命令主要是用於獲取空間座標信息,如:WKT,PROJ.4 等格式。 工具
軟件環境:在安裝Mapserver時集成安裝。詳見《MapServer Configuring with IIS》。spa
語法命令行
Usage: gdalsrsinfo [options] srs_def srs_def may be the filename of a dataset supported by GDAL/OGR from which to extract SRS information OR any of the usual GDAL/OGR forms (complete WKT, PROJ.4, EPSG:n or a file containing the SRS)
#srs_def 表示空間座標系統或座標參考系統的文件,或代號 或數據集等。
#其須要被GDAL/OGR 支持
#如:WKT、PROJ.4,EPSG:n 或 包含 srs 信息的文件(如:esri的prj、shp文件等) Options: [--help-general] [-h] Show help and exit [-p] Pretty-print where applicable (e.g. WKT) #格式化輸出 [-V] Validate SRS #打印驗證的空間座標信息 [-e] Search for EPSG number(s) corresponding to SRS #查詢空間座標信息對應的ESPG number [-o out_type] Output type { default, all, wkt_all, proj4, #指定輸出數據類型,wkt,proj.四、wkt_esri都有本身的格式,按照指定的格式類型輸出 wkt, wkt_simple, wkt_noct, wkt_esri, mapinfo, xml }
簡單用例code
#輸出 ESPG:4326 的座標信息
gdalsrsinfo "EPSG:4326" PROJ.4 : '+proj=longlat +datum=WGS84 +no_defs ' OGC WKT : GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]]
#將prj文件轉 proj.4格式 輸出
gdalsrsinfo -o proj4 osr/data/lcc_esri.prj '+proj=lcc +lat_1=34.33333333333334 +lat_2=36.16666666666666 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +datum=NAD83 +units=m +no_defs '
#輸出tif文件的空間信息
gdalsrsinfo -o proj4 landsat.tif PROJ.4 : '+proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs '
#將 EPSG:32722 裝換爲 wkt 格式輸出 並格式化
gdalsrsinfo -o wkt -p "EPSG:32722" PROJCS["WGS 84 / UTM zone 22S", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]], PROJECTION["Transverse_Mercator"], PARAMETER["latitude_of_origin",0], PARAMETER["central_meridian",-51], PARAMETER["scale_factor",0.9996], PARAMETER["false_easting",500000], PARAMETER["false_northing",10000000], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AXIS["Easting",EAST], AXIS["Northing",NORTH], AUTHORITY["EPSG","32722"]]
#去掉 -p 參數後,其數據所有在一行裏面
gdalsrsinfo -o wkt "EPSG:32722" PROJCS["WGS 84 / UTM zone 22S",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-51],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32722"]]
#輸出全部的wkt格式
gdalsrsinfo -o wkt_all "EPSG:4618" OGC WKT : GEOGCS["SAD69", DATUM["South_American_Datum_1969", SPHEROID["GRS 1967 Modified",6378160,298.25, AUTHORITY["EPSG","7050"]], TOWGS84[-57,1,-41,0,0,0,0], AUTHORITY["EPSG","6618"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4618"]] OGC WKT (simple) : GEOGCS["SAD69", DATUM["South_American_Datum_1969", SPHEROID["GRS 1967 Modified",6378160,298.25], TOWGS84[-57,1,-41,0,0,0,0]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433]] OGC WKT (no CT) : GEOGCS["SAD69", DATUM["South_American_Datum_1969", SPHEROID["GRS 1967 Modified",6378160,298.25]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433]] ESRI WKT : GEOGCS["SAD69", DATUM["D_South_American_1969", SPHEROID["GRS_1967_Truncated",6378160,298.25]], PRIMEM["Greenwich",0], UNIT["Degree",0.017453292519943295]]
名詞解釋orm
WKT:Well-known text,文本標記語言,用於在地圖上表示矢量幾何對象、空間對象的空間參考系統以及空間參考系統之間的轉換。server
EPSG:EPSG是一個與歐洲石油工業有聯繫的科學組織,由與石油勘探相關的應用大地測量、測量和製圖方面的專家組成。《大地測量參數集》是地球橢球體、大地基準面、地理和投影座標系、測量單位等資料的通用數據庫。其實這裏指的是「ESPG的通用數據庫」
PROJ:PROJ是一個通用的座標轉換軟件,它將地理空間座標從一個座標系轉換爲另外一個座標系。這包括地圖投影和大地變換。