【发布时间】:2020-09-15 22:35:57
【问题描述】:
我想将投影坐标中的一个点转换为纬度/经度。 我读过this blog post about transformations 并想出了以下代码:
factory_25831 = RGeo::Cartesian.factory(:srid => 25831)
point_25831 = factory_25831.point(505500.421875, 4699669.4375)
factory_4326 = RGeo::Geographic.spherical_factory(:srid => 4326)
point_4326 = RGeo::Feature.cast(point_25831, :factory => factory_4326, :project => true)
这给了我:
=> #<RGeo::Geographic::SphericalPointImpl:0xe35f6c "POINT (60.421875 90.0)">
但是我应该得到类似 long: 3.0668887° / lat: 42.4493345°。
我做错了什么?
编辑:
显然我“可以”转换一个点,但只提供完整的 proj4 和 WKT 规范,这在某种程度上失去了只提供 srid 代码的好处。我的代码接收带有 srid 作为元数据的随机几何图形 - 因此我无法对规范进行硬编码。
proj4_25831 = '+proj=utm +zone=31 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
wkt_25831 = 'PROJCS["ETRS89 / UTM zone 31N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","25831"]]'
factory_25831 = RGeo::Cartesian.factory(:srid => 25831,
:proj4 => proj4_25831, :coord_sys => wkt_25831)
proj4_4326 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
wkt_4326 = <<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.01745329251994328,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
WKT
factory_4326 = RGeo::Geographic.spherical_factory(:srid => 4326,
:proj4 => proj4_4326, :coord_sys => wkt_4326)
【问题讨论】: