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_PATH
和WRS_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