【GIS】OGR空间参考

5 篇文章 1 订阅

空间参考 · SpatialReference

  • 空间参考是空间数据的骨骼框架,能够将我们的空间数据定位到相应的位置,为地图中的每一点提供准确的坐标
  • 同一个地图上显示的地图数据的空间参考必须是一致的(不一致往往会导致两幅地图无法正确拼合)
  • 一个空间参考中主要包括大地水准面、地球椭球体、投影坐标系等
  • 他们之间的关系:
  • 基准面(椭球+摆放方式)+角度测量单位+中央经线(本初子午线)=地理坐标系(GCS)
  • 地理坐标系+投影参数(投影方式,怎么投)+线性单位=投影坐标系(PCS)

使用示例

构造SpatialReference对象并输出wkt字符串

 static void constructOSR() {
        //定义一个OGRSpatialReference对象
        SpatialReference oSRS = new SpatialReference("");
        /**
         * 对该对象进行初始化,以WGS84的地理坐标系为示例
         */
        //M.1 使用常用名称进行构造
        oSRS.SetWellKnownGeogCS("WGS84");

        //M.2 s使用ESRI的prj文件进行构造
        oSRS.SetFromUserInput("ESRI::C:\\Program Files (x86)\\GIS\\ArcGIS\\Desktop10.3\\Reference Systems\\utm.prj");

        //导出wkt
        String wkt = oSRS.ExportToWkt();
        System.out.println("wkt:\n"+wkt);

        String prettyWkt = oSRS.ExportToPrettyWkt(0);
        System.out.println("prettyWkt:\n"+prettyWkt);
    }

输出:

wkt:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433],AXIS["Longitude",EAST],AXIS["Latitude",NORTH]]
prettyWkt:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.0174532925199433],
    AXIS["Longitude",EAST],
    AXIS["Latitude",NORTH]]

坐标转换

static void coordinateTransformation(){
        //构建一个PROJ.4格式的字符串(西安80 三度带 39带投影坐标系统)
        String xian80="+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs";
        SpatialReference spatialReferenceXiAn80=new SpatialReference("");
        //使用PROJ.4格式的字符串构造一个西安80 三度带 39带投影坐标系统
        spatialReferenceXiAn80.SetFromUserInput(xian80);
        //获取该投影坐标系统中的地理坐标
        SpatialReference spatialReferenceLonLat=spatialReferenceXiAn80.CloneGeogCS();
        //构造一个从UTM投影坐标系统到地理坐标系统的转换关系
        CoordinateTransformation transformation=new CoordinateTransformation(spatialReferenceXiAn80,spatialReferenceLonLat);

        double[] pointX=new double[2];
        pointX[0]=39464667.861;
        pointX[1]=39458907.868;
        double[] pointY =new double[2];
        pointY[0]=44441766.356;
        pointY[1]=44444406.349;

        transformation.TransformPoint(pointX[0],pointY[0],0);
        transformation.TransformPoint(pointY[1],pointY[1],0);

        System.out.println(pointX[0]+","+pointY[0]);
        System.out.println(pointX[1]+","+pointY[1]);
    }

输出:

3.9464667861E7,4.4441766356E7
3.9458907868E7,4.4444406349E7

Proj4

Proj4字符串是一种识别空间或坐标参考系统的简介方法,通过其定义的语法规则,将想要定义的CRS(坐标参考系统)全部参数信息保存到一条字符串里。

语法

示例

+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs 
  • proj=tmerc:声明投影方法为Transverse Mercator 横轴墨卡托
  • units=m:声明坐标系单位设置为米
  • lat_0:声明初始纬度为0
  • lon_0:声明中央经线为117°
  • k=1:换算系数为1
  • x_0:声明东移距离为3950000
  • y_0:声明北偏距离为0
  • a:声明椭球的长半轴为6378140
  • b:声明椭球的短半轴为6356755.288157528

参数列表

Parameter 参数

Description 描述

+a

Semimajor radius of the ellipsoid axis 椭球的长轴半径

+axis

Axis orientation 轴向方向

+b

Semiminor radius of the ellipsoid axis 椭球的短轴半径

+ellps

Ellipsoid name (see proj -le) 椭球名

+k

Scaling factor (deprecated) 换算系数

+k_0

Scaling factor

+lat_0

Latitude of origin 初始纬度

+lon_0

Central meridian 中央经线

+lon_wrap

Center longitude to use for wrapping (see below)

当经度超过该值后继续超过-180,就转换为+180

例如:lon_wrap=180 表示经度范围为0-360

+over

Allow longitude output outside -180 to 180 range, disables wrapping (see below)

禁用wrap,不做经度转换(默认情况下,PROJ 在 -180 到 180 范围内)

+pm

Alternate prime meridian (typically a city name, see below)

交替本初子午线(通常是一个城市的名字)

+proj

Projection name (see proj -l) 投影坐标名

+units

meters, US survey feet, etc. 单位

+vunits

vertical units. 垂直方向的单位

+x_0

False easting 东移

+y_0

False northing 北偏

强推一个网站!!!

CS2CS - Transform Coordinates On-line - MyGeodata Cloud

这个网站可以提供不同地理坐标系的PROJ.4格式字符串,可以用于地理坐标系相互转换

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AQin1012

求小鱼干呢~~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值