GEE错误——如何将原有矢量将维度转化为地理坐标系,重投影坐标坐标无法实现?

简介:

投影转换是一种将三维空间中的物体及其属性转换为二维平面上的方法。它是一种将三维空间坐标(x,y,z)映射到二维平面坐标(x',y')的技术。在计算机图形学和计算机视觉中,投影转换是非常重要的,因为它可以帮助我们将三维物体呈现在二维屏幕上,并且可以进行各种变换和处理。常见的投影转换有正交投影和透视投影。在GEE中我们可以使用哨兵2号数据其中任何一个波段所自带的坐标,让其成为我们默认的坐标,然后将其重新投影。

这里我们发现无法转换的原因在于,这里的坐标通过您(盲目)指定的投影中内置的仿射变换进行缩放和偏移。打印投影时您可以看到这些值。不过我们也可以使用投影的 wkt 进行新投影,以便获得默认的投影比例和偏移量。

函数:

wkt()

Returns a WKT representation of the base coordinate system of this Projection.

返回此投影的基坐标系的 WKT 。

Arguments:

this:projection (Projection)

Returns: String

projection()

Returns the default projection of an Image. Throws an error if the bands of the image don't all have the same projection.

Arguments:

this:image (Image):

The image from which to get the projection.

Returns: Projection

transform()

Returns a WKT representation of the transform of this Projection. This is the transform that converts from projected coordinates to the base coordinate system.

Arguments:

this:projection (Projection)

Returns: String

原始投影代码:


// Coords in Australia
var jsonPoly = {'type': 'Polygon', 'coordinates': [[[151.2927484, -33.7224076], [151.2953236, -33.7345426], [151.3093994, -33.7331863], [151.3062239, -33.7205514], [151.2927484, -33.7224076]]]};
var ee_geom = ee.Geometry(jsonPoly, 'EPSG:4326'); // WGS84 geographic

var sr_data = ee.ImageCollection('COPERNICUS/S2').filterDate('2018-06-03', '2018-06-05').filter(ee.Filter.bounds(ee_geom));
var img = sr_data.first();
print(img.get('system:index') );

var projObj = img.select('B3').projection(); // a UTM EPSG, 32756

var eeGeomUtm = ee_geom.transform(projObj, 1).coordinates().get(0);
print(eeGeomUtm);

// Would have expected coords something in the approx vicinity of:

// Easting: 342228.66002316
// Northing: 6268389.4293557

未成功投影的结果

List (5 elements)

0:

[4181.8970063,3272.6363911]

1:

[4306.4270138,3249.9945839]

2:

[4338.1488216,3389.6226067]

3:

[4207.9833261,3406.8093767]

4:

[4181.8970063,3272.6363911]

修改后的代码:


// Coords in Australia
var jsonPoly = {'type': 'Polygon', 'coordinates': [[[151.2927484, -33.7224076], [151.2953236, -33.7345426], [151.3093994, -33.7331863], [151.3062239, -33.7205514], [151.2927484, -33.7224076]]]};
var ee_geom = ee.Geometry(jsonPoly, 'EPSG:4326'); // WGS84 geographic

var sr_data = ee.ImageCollection('COPERNICUS/S2').filterDate('2018-06-03', '2018-06-05').filter(ee.Filter.bounds(ee_geom));
var img = sr_data.first();
print(img.get('system:index') );

var projObj = img.select('B3').projection(); // a UTM EPSG, 32756
projObj = ee.Projection(projObj.wkt())

var eeGeomUtm = ee_geom.transform(projObj, 1).coordinates().get(0);
print(eeGeomUtm);

使用wkt函数的结果

List (5 elements)

0:

[341818.970063,6267313.636089]

1:

[342079.833261,6265971.906233]

2:

[343381.488216,6266143.773933]

3:

[343064.270138,6267540.054161]

4:

[341818.970063,6267313.636089]

你可能感兴趣的:(前端,javascript,开发语言)