代码之家  ›  专栏  ›  技术社区  ›  four-eyes

用proj4和EPSG代码转换成不同的坐标系

  •  0
  • four-eyes  · 技术社区  · 6 年前

    EPSG:25833 ,这是 UTM ,32N区。 EPSG:3857 ,韦伯墨卡托。这个 documentation

    var firstProjection = 'PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",42.68333333333333],PARAMETER["standard_parallel_2",41.71666666666667],PARAMETER["latitude_of_origin",41],PARAMETER["central_meridian",-71.5],PARAMETER["false_easting",200000],PARAMETER["false_northing",750000],AUTHORITY["EPSG","26986"],AXIS["X",EAST],AXIS["Y",NORTH]]';
    var secondProjection = "+proj=gnom +lat_0=90 +lon_0=0 +x_0=6300000 +y_0=6300000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
    
    proj4(firstProjection,secondProjection,[2,5]);
    

    是否可以只传递一个EPSG字符串作为 firstProjection secondProjection ? 通过,即 那就是 UTM 32N 已经包含了所有需要的信息。为什么要通过

    Proj4js.defs["EPSG:25833"] = "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs"; 
    

    爱普生:25833 EPSG ? 那我得更新一下 +proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m +no_defs

    0 回复  |  直到 6 年前
        1
  •  1
  •   LuisTavares    6 年前

    Proj4js以以下坐标系分布,

    export default function(defs) {
      defs('EPSG:4326', "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
      defs('EPSG:4269', "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees");
      defs('EPSG:3857', "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
    
      defs.WGS84 = defs['EPSG:4326'];
      defs['EPSG:3785'] = defs['EPSG:3857']; // maintain backward compat, official code is 3857
      defs.GOOGLE = defs['EPSG:3857'];
      defs['EPSG:900913'] = defs['EPSG:3857'];
      defs['EPSG:102113'] = defs['EPSG:3857'];
    } 
    

    https://github.com/proj4js/proj4js/blob/master/lib/global.js

    这就是为什么你不能只传递一个EPSG代码,除非它是在别处定义的。

    只是个便条,

    Proj4js.defs["ETRS89 UTM32"] = "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs"; 
    

    而不是

    Proj4js.defs["EPSG:25833"] = "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs";
    

    Proj4js.MYEPSG = Proj4js.defs["EPSG:25833"]  
    
    推荐文章