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

时间:2019-06-16 08:25:48

标签: javascript leaflet coordinate-systems proj

我在#000000(即EPSG:25833)的32N区中有坐标。 我想将它们转换为WebMercator的UTMdocumentation

EPSG:3857

是否可以仅将EPSG字符串作为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]); firstProjection传递?通过secondProjection的{​​{1}}传递已经包含所有需要的信息。为什么需要通过此操作

EPSG:25833

使用此定义也限制了我。如果UTM 32N更改为另一个Proj4js.defs["EPSG:25833"] = "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs"; 怎么办?然后我也必须更新此EPSG:25833 ...

1 个答案:

答案 0 :(得分:1)

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数据库一起分发的PROJ4 C库进行比较,...

这就是您不能仅传递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"]