首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将EPSG:4326转换为EPSG:32632

如何将EPSG:4326转换为EPSG:32632
EN

Stack Overflow用户
提问于 2017-05-15 13:55:32
回答 1查看 1.6K关注 0票数 0

我得到了我的位置,在EPSG: 4326通过我的安卓全球定位系统,现在我将它的坐标转换为EPSG: 32632。有人有主意吗?

EN

回答 1

Stack Overflow用户

发布于 2017-12-12 04:17:15

使用地理工具。http://www.geotools.org/

下面是一个转换示例。

http://docs.geotools.org/stable/userguide/library/api/jts.html

首先,您必须从下载目录中删除3个jar文件,如下所示:

例如geotools版本18.0,

gt-epsg-hsql-18.0.jar gt-epsg-oracle-18.0.jar gt-epsg-PostgreSQL18.0.jar

几乎有两种情况存在。1.使用CRS类的解码方法:

代码语言:javascript
复制
CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);

CoordinateReferenceSystem targetCRS = null;
CoordinateReferenceSystem sourceCRS = null;
Geometry transCoordGeometry = null;

try {
    targetCRS = CRS.decode("EPSG:32632");
    sourceCRS = CRS.decode("EPSG:4326");
} catch (FactoryException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}


MathTransform transform = null;
try {
    transform = CRS.findMathTransform(sourceCRS, targetCRS);
    transCoordGeometry = JTS.transform(orgGeometry, transform);
} catch (FactoryException | MismatchedDimensionException | TransformException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
  1. 用一根绳子。

targetWKT的字符串变量。

http://spatialreference.org/ref/epsg/wgs-84-utm-zone-32n/prettywkt/

代码语言:javascript
复制
PROJCS["WGS 84 / UTM zone 32N",
    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"]],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    AUTHORITY["EPSG","32632"],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH]]

然后,代码是:

代码语言:javascript
复制
CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    CoordinateReferenceSystem targetCRS = null;

    CoordinateReferenceSystem sourceCRS = null;
    Geometry transCoordGeometry = null;

    try {
        targetCRS = crsFactory.createFromWKT(targetWKT); 
        sourceCRS = CRS.decode("EPSG:4326");
    } catch (FactoryException e1) {
        e1.printStackTrace();
    }


    MathTransform transform = null;
    try {
        transform = CRS.findMathTransform(sourceCRS, targetCRS);
        transCoordGeometry = JTS.transform(orgGeometry, transform);
    } catch (FactoryException | MismatchedDimensionException | TransformException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43981408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档