Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
379 views
in Technique[技术] by (71.8m points)

javascript - 如何将多个站点(点几何)组合在一起作为要素集合,以在所有站点上执行NDVI变化计算?(How do I group a number of sites (point geometries) together as a feature collection, to perform NDVI change calculations on all the sites?)

I am new to stack overflow and javascript, so apologies in advance.

(我是堆栈溢出和javascript的新手,所以提前致歉。)

The overall aim: calculate the NDVI change over time (inter- and intra-annual) at 8 sites using the landsat 8 image collection.

(总体目标:使用Landsat 8图像采集来计算8个地点的NDVI随时间(年际和年内)的变化。)

Rather than do calculations on each one separately, I want to group the sites together and then do the NDVI calculation on all the sites at once (but get results for each site separately).

(与其将每个站点分开进行计算,不如将它们组合在一起,然后一次对所有站点进行NDVI计算(但要分别获取每个站点的结果)。)

Initial aim : filter for individual sites .

(最初的目标过滤单个站点 。)

So, before doing the NDVI calcs, I need to first filter and reduce the landsat 8 image collection (to remove cloud, get the right dates, etc), including using .filterBounds() to filter spatially by site, as in the code below.

(因此,在执行NDVI计算之前,我需要先过滤并减少landat 8图像集合(以去除云朵,获取正确的日期等),包括使用.filterBounds()按站点进行空间过滤,如下面的代码所示。)

When I run the code, only one image from the last site (site 5D) listed appears in the map window, and there are no error messages in the console.

(当我运行代码时,地图窗口中仅列出了最后一个站点(站点5D)中的一个图像,并且控制台中没有错误消息。)

//import the image collection
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_RT');

//define a list of geometry points with co-ordinates as the 8 distinct sites
var siteList = [
    ee.Feature(/* color: #166f12 */ee.Geometry.Point (135.78877, -15.146215), {name: 'site1A'}), 
    ee.Feature(/* color: #1f921a */ee.Geometry.Point (135.836993, -15.171145), {name: 'site1B'}),
    ee.Feature(/* color: #1c73d5 */ee.Geometry.Point (136.434148, -15.647369), {name: 'site2A'}),
    ee.Feature(/* color: #144882 */ee.Geometry.Point (136.441971, -15.650919), {name: 'site2B'}), 
    ee.Feature(/* color: #de2626 */ee.Geometry.Point (140.853576, -17.422561), {name: 'site4A'}), 
    ee.Feature(/* color: #911919 */ee.Geometry.Point (140.89625, -17.340024), {name: 'site4B'}), 
    ee.Feature(/* color: #23cf7b */ee.Geometry.Point (141.665424, -15.027324), {name: 'site5A'}),
    ee.Feature(/* color: #228c58 */ee.Geometry.Point (141.660919, -14.996538), {name: 'site5D'})
    ];

// Create a FeatureCollection from the list and print it.
var sites = ee.FeatureCollection(siteList);
print(sites);

//Define the image
var image = ee.Image(l8
  .filterDate("2014-07-01", "2016-09-30")
  .filterBounds(sites)
  .sort("CLOUD_COVER")
  .first());
print("Landsat 8:", image);

var vis = {min: 0, max: 14000, bands:['B5', 'B4', 'B3']};
Map.addLayer(image, vis,'Sites test');

The question: As the script shows, and following the GEE tutorials and other SO answers, I have defined the sites as point geometries, put them in a list, then defined a ee.FeatureCollection() as the list of sites.

(问题:如脚本所示,并按照GEE教程和其他SO答案,我已将站点定义为点几何,将它们放置在列表中,然后将ee.FeatureCollection()定义为站点列表。)

But something is obviously incorrect.

(但是显然有些不正确。)

How do I change the script to make it work?

(如何更改脚本以使其正常工作?)

I considered a possible workaround being filtering the image collection by WRS_PATH and WRS_ROW to get the images taken nearest the sites.

(我考虑了一种可能的解决方法,即通过WRS_PATHWRS_ROW过滤图像集合以获取距站点最近的图像。)

Then define 'roi's' as polygon geometries and do the NDVI calcs within the polygons (I guess clip() image to polygon.

(然后将“ roi's”定义为多边形的几何形状,并在多边形内进行NDVI计算(我想将clip()图像转换为多边形。)

Hope that's enough info.

(希望有足够的信息。)

  ask by jerry_88 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're only seeing one image because you only select one image using the first function.

(您仅看到一张图像,因为您仅使用第first功能选择了一张图像。)

There is a lot you need to do here, but here are some goalposts:

(您需要在这里做很多事情,但是这里有一些目标:)

  1. Create an NDVI composite for each image in the image collection using map and a custom function.

    (使用map和自定义功能为图像集中的每个图像创建NDVI复合图像。)

  2. Mosaic the composites for a single date within the image collection (will be a little tricky, you'll probably have to define and iterate over the specific image dates).

    (将图像集合中单个日期的合成图像拼接起来(会有些棘手,您可能必须定义并迭代特定的图像日期)。)

  3. Create an image from the composites-by-date by using eg iterate and addBands .

    (通过使用iterateaddBands从复合图像创建图像。)

    (You'll have to store the date in the image name somehow so you know which date each band refers to in the final product).

    ((您必须以某种方式将日期存储在图像名称中,以便您知道每个乐队在最终产品中指的日期)。)

  4. Use reduceRegions on the feature collection and the multiband image you created to get values for each point for each image band.

    (在要素集合和创建的多波段图像上使用reduceRegions获取每个图像波段的每个点的值。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...