中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

手機網站建設的教程視頻南昌seo排名

手機網站建設的教程視頻,南昌seo排名,閔行營銷型網站建設,采集網站如何做標簽 PostgreSQL , PostGIS , 球坐標 , 平面坐標 , 球面距離 , 平面距離 背景 PostGIS中有兩種常用的空間類型geometry和geography,這兩種數據類型有什么差異,應該如何選擇? 對于GIS來說,首先是坐標系,有兩種&#…

標簽

PostgreSQL , PostGIS , 球坐標 , 平面坐標 , 球面距離 , 平面距離


背景

PostGIS中有兩種常用的空間類型geometry和geography,這兩種數據類型有什么差異,應該如何選擇?

對于GIS來說,首先是坐標系,有兩種:一種是球坐標(地理坐標),另一種是平面坐標(投影坐標)。

球坐標通常用于計算,平面坐標通常用于展示(也可以計算)。

投影坐標是從球坐標投影后展開得來(用一個圓柱將地球包起來,把地球當成會發(fā)光的光源,投影后,將圓柱展開得到),投影的范圍越大,精度就越低。范圍越小,精度就越高。除了投影扇形的大小有區(qū)別,在不同的行業(yè),也有不同的坐標系,例如用于測繪的坐標系。

目前用得最多的有SRID=4326球坐標,SRID為EPSG:3785的墨卡托投影坐標。

再來說geometry和geography兩種類型,geometry支持平面對象也支持空間對象,而geography則僅支持空間對象。

geometry支持更多的函數,一些幾何計算的代價更低。

geography支持的函數略少,計算代價更高。那為什么還要geography呢?因

4.2.2. When to use Geography Data type over Geometry data type    The geography type allows you to store data in longitude/latitude coordinates,     
but at a cost: there are fewer functions defined on GEOGRAPHY than there are on GEOMETRY;     
those functions that are defined take more CPU time to execute.    The type you choose should be conditioned on the expected working area of the application you are building.     
Will your data span the globe or a large continental area, or is it local to a state, county or municipality?    If your data is contained in a small area, you might find that choosing an appropriate     
projection and using GEOMETRY is the best solution, in terms of performance and functionality available.    If your data is global or covers a continental region, you may find that GEOGRAPHY     
allows you to build a system without having to worry about projection details.     
You store your data in longitude/latitude, and use the functions that have been defined on GEOGRAPHY.    If you don't understand projections, and you don't want to learn about them,     
and you're prepared to accept the limitations in functionality available in GEOGRAPHY,     
then it might be easier for you to use GEOGRAPHY than GEOMETRY.     
Simply load your data up as longitude/latitude and go from there.      Refer to Section 14.11, “PostGIS Function Support Matrix” for compare between     
what is supported for Geography vs. Geometry.     
For a brief listing and description of Geography functions,     
refer to Section 14.4, “PostGIS Geography Support Functions”    

既然提到距離計算和投影坐標系有關,引入了本文的問題:

在不知道要計算的geometry點,在什么投影坐標系下時,往往計算距離得到的結果并不準確。

例如,下面的點,換算成2163坐標系,計算距離得到的結果并不準確。

db1=# SELECT st_distance(ST_Transform(ST_GeomFromText('POINT(120.08 30.96)', 4326), 2163 ), ST_Transform(ST_GeomFromText('POINT(120.08 30.92)', 4326), 2163 ));   st_distance          
------------------      4030.46766234184      
(1 row)      

2163坐標系內容如下:

postgres=# select * from spatial_ref_sys where srid=2163;    
-[ RECORD 1 ]-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------    
srid      | 2163    
auth_name | EPSG    
auth_srid | 2163    
srtext    | PROJCS["US National Atlas Equal Area",GEOGCS["Unspecified datum based upon the Clarke 1866 Authalic Sphere",DATUM["Not_specified_based_on_Clarke_1866_Authalic_Sphere",SPHEROID["Clarke 1866 Authalic Sphere",6370997,0,AUTHORITY["EPSG","7052"]],AUTHORITY["EPSG","6052"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4052"]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center",45],PARAMETER["longitude_of_center",-100],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","2163"]]    
proj4text | +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs     
AUTHORITY["EPSG", "9122"]指的是EPSG數據集中UNIT為degree的ID是9122;  AUTHORITY["EPSG", "4326"]指的是地理坐標系WGS 84的ID是4326;  AUTHORITY["EPSG", "9001"]指的是EPSG中UNIT為meter的ID是9001;  AUTHORITY["EPSG", "32650"]指的是該投影坐標系WGS 84 / UTM zone 50N的ID是32650  

這樣會造成一個假象如下:

用st_distance函數計算出來的經緯度之間的距離,跟用java程序算出來的距離相差很大。      這個例子,st_distance算出來的距離是4030,我們程序算出來的是4445,換另外兩個相距很遠的點,這個差距值會更大。      

正確姿勢

算球面距離,不要算直線距離。

1、使用球坐標,通過st_distancespheroid計算兩個geometry類型的球面距離。

對于geometry類型,可以使用st_distancespheroid直接用球坐標計算,在計算時會自動設置這個橢球特性(SPHEROID["Krasovsky_1940",6378245.000000,298.299997264589] )。

postgres=# SELECT st_distancespheroid(ST_GeomFromText('POINT(120.08 30.96)', 4326),ST_GeomFromText('POINT(120.08 30.92)', 4326), 'SPHEROID["WGS84",6378137,298.257223563]');    st_distancespheroid     
---------------------    4434.73734584354    
(1 row)    

2、使用平面坐標,通過st_distance計算兩個geometry類型的平面投影后的距離。

采用精準的投影坐標(小面積投影坐標系)(但是必須要覆蓋到要計算的兩個點)

ST_Transform(ST_GeomFromText('POINT(120.08 30.96)', 4326), 2163 )    

如果geometry值的SRID不是(高精度)目標坐標系,可以使用ST_Transform函數進行轉換,轉換為目標投影坐標系,再計算距離。

postgres=# SELECT st_distance(ST_Transform(ST_GeomFromText('POINT(120.08 30.96)', 4326), 2390 ), ST_Transform(ST_GeomFromText('POINT(120.08 30.92)', 4326), 2390 ));   st_distance      
------------------  4547.55477647394  
(1 row)  

3、使用球坐標,通過ST_Distance計算兩個geography類型的球面距離。

float ST_Distance(geography gg1, geography gg2, boolean use_spheroid);   -- 適用橢球體(WGS84)    use_spheroid設置為ture表示使用:      -- WGS84 橢球體參數定義    vspheroid := 'SPHEROID["WGS84",6378137,298.257223563]' ;     

這里的XXXX就是你要選擇的球坐標系SRID。在spatial_ref_sys表里可以查看各種坐標系。

postgres=# SELECT st_distance(ST_GeogFromText('SRID=xxxx;POINT(120.08 30.96)'), ST_GeogFromText('SRID=xxxx;POINT(120.08 30.92)'), true);    st_distance       
----------------    xxxxxxxxxxxxxxxxxxxx    
(1 row)    例如  postgres=# SELECT st_distance(ST_GeogFromText('SRID=4610;POINT(120.08 30.96)'), ST_GeogFromText('SRID=4610;POINT(120.08 30.92)'), true);    st_distance     
----------------  4434.739418211  
(1 row)  

如果允許一定的偏差,可以使用全球球坐標系4326。

postgres=# SELECT st_distance(ST_GeogFromText('SRID=4326;POINT(120.08 30.96)'), ST_GeogFromText('SRID=4326;POINT(120.08 30.92)'), true);    st_distance       
----------------    4434.737345844    
(1 row)    

geography只支持球坐標系,使用投影坐標會報錯。

postgres=# SELECT st_distance(ST_GeogFromText('SRID=2369;POINT(120.08 30.96)'), ST_GeogFromText('SRID=2369;POINT(120.08 30.92)'), true);    
錯誤:  22023: Only lon/lat coordinate systems are supported in geography.  
LOCATION:  srid_is_latlong, lwgeom_transform.c:774  

4、指定SPHEROID內容,通過st_distancesphereoid計算geometry的球面距離。

這種方法最為精確,但是要求了解計算距離當地的地形屬性(即輸入參數的spheroid的內容)。

db1=# SELECT st_distancespheroid(ST_GeomFromText('POINT(120.08 30.96)', 4326),ST_GeomFromText('POINT(120.08 30.92)', 4326), 'SPHEROID["WGS84",6378137,298.257223563]');        st_distancesphere       
-------------------      4447.803189385      
(1 row)      

小結

計算距離,應該考慮到被計算的兩點所在處的地球特性(spheroid)。這樣計算得到的距離才是最精確的。

geometry和geography類型的選擇,建議使用geometry,既能支持球坐標系,又能支持平面坐標系。主要考慮到用戶是否了解位置所在處的地理特性,選擇合適的坐標系。

-- 適用平面直角坐標,適用geometry類型,計算直線距離    
float ST_Distance(geometry g1, geometry g2);             -- 適用橢球體坐標,適用geography類型,計算球面距離  
float ST_Distance(geography gg1, geography gg2);         -- 適用橢球體坐標(WGS84),適用geography類型,計算球面距離    
float ST_Distance(geography gg1, geography gg2, boolean use_spheroid);     use_spheroid設置為ture表示使用:      vspheroid := 'SPHEROID["WGS84",6378137,298.257223563]' ; -- WGS84 橢球體參數定義     -- 適用橢球體坐標以及投影坐標,適用geometry類型,求球面距離(需要輸入spheroid)  
float ST_DistanceSpheroid(geometry geomlonlatA, geometry geomlonlatB, spheroid measurement_spheroid);     

參考

1、計算球面距離

ST_DistanceSphere

2、計算球面以及平面距離(取決于輸入的類型geometry還是geography)

ST_Distance

3、坐標系轉換

ST_Transform

4、投影坐標和球坐標

《地理坐標系(球面坐標系)和投影坐標系(平面坐標系)》

5、PostGIS學習建議

《PostGIS 空間數據學習建議》

6、?http://blog.163.com/jey_df/blog/static/18255016120149145755781/

墨卡托 (Mercator) 投影—幫助 | ArcGIS for Desktop

http://www.risenshineclean.com/news/8207.html

相關文章:

  • 大連關鍵詞優(yōu)化服務怎么快速優(yōu)化網站排名
  • 專業(yè)的建設網站百度指數查詢官網入口登錄
  • 學網站開發(fā)的軟件有哪些微信群推廣網站
  • 無錫網站建設哪家做得比較好宜昌今日頭條新聞
  • 個人網站做接口可以么搜索網頁
  • 溫州有沒有專門的企業(yè)網站最近幾天發(fā)生的新聞大事
  • 閩清住房和城鄉(xiāng)建設局網站制作鏈接的小程序
  • 程序員就是做網站的嗎百度指數查詢官網入口登錄
  • 動漫網站建設方案項目書目錄白酒最有效的推廣方式
  • 大學學術建設專題網站seo按天計費系統(tǒng)
  • 服裝市場調網站建設的目的長春網站優(yōu)化體驗
  • 移動網站建設制作公司搜索引擎營銷的基本方法
  • 域名做好了怎么做網站內容對網絡營銷的認識
  • 浙江省建設職業(yè)注冊中心網站廣州營銷seo
  • 陜西省人民政府網站官網企業(yè)網站模板免費下載
  • 徐州網站app開發(fā)我贏網客服系統(tǒng)
  • 云南學校 手機網站建設網店代運營和推廣銷售
  • 做電影網站用什么程序推廣策略有哪些方法
  • 網站建設南京制作鏈接的app的軟件
  • 連云港做網站軟文發(fā)布門戶網站
  • 有ip怎么用自己的主機做網站青島谷歌優(yōu)化
  • 門戶網站開發(fā)jz1902020年百度搜索排名
  • 汕頭人什么叫seo網絡推廣
  • 網站后臺管理系統(tǒng)模塊怎樣進行seo優(yōu)化
  • 整體網站構架騰訊云1元域名
  • 網上做翻譯兼職網站好網店運營的工作內容
  • 自己建一個網站需要多少錢地推拉新接單網
  • 網站文案技巧公司網頁設計
  • 經營性網站備案需要哪些東西愛站網關鍵詞密度查詢
  • 文化網站建設論文寧德市人民政府