1, Filter filter
(1) Relational comparison filter
var filter_1 = ee.Filter.eq/neq/gt/gte/lt/lte('field','field value');
//Judge the relationship and return the filter
var result_filter = (FeatureCollection/ImageCollection).fliter(filter_1);
//At this time, the filtering result is still of type Collection.
If a non Collection type is returned, it is as follows:
var result_filter = (FeatureCollection/ImageCollection).fliter(filter_1).first();
(2) Difference filter
var filter_1 = ee.Filter.maxDifference('Maximum difference','field','Field value'); 'var filter_1 = ee.Filter.maxDifference('10','area',100); ' //Represents the area with the maximum difference of 10 between the area field area and 100
(3) Character filter
Filter start, end and include strings
var filter_1 = ee.Filter.stringStartsWith('field','Start string'); var filter_2 = ee.Filter.stringEndsWith('field','End string'); var filter_3 = ee.Filter.stringContains('field','Include string');
Filter range
var filter_1 = ee.Filter.rangeContains('field','Starting letter', 'Termination letter'); 'var filter_1 = ee.Filter.rangeContains('NAME','B', 'D');' //Indicates that all areas of the NAME field containing the letters B to D are filtered out
Listcontents() is required for the field values in the form of lists in some fields
var filter_1 = ee.Filter.listContains('field','The list contains values');
When filtering for multiple values, you need to use the list to filter for multiple values:
var list_1 = ee.List('String 1', 'String 2', 'String 3'); var filter_1 = ee.Filter.inlist('field',list_1); //Filter out the results of some elements in the list contained in the field (multi value filter)
(4) Detailed time filtering
var filter_1 = ee.Filter.calendarRange(day1, day2, 'day_of_year'); //Filter: filter images from day1 to day2 of the year var filter_2 = ee.Filter.calendarRange(month1, month2, 'month_of_year'); //Filter: filter by month
You can also use DayOfYear() to filter the number of days in a year
filter_1 = ee.Filter.day_Of_Year(day1, day2); //Filter: filter images from day1 to day2 of the year
(5) Filter overlay filter
var filter_1 = ee.Filter.and(filter_A, filter_B); //Filter: filter var filter_2 = ee.Filter.or(filter_A, filter_B); //Filter: filter and filter var Result = China.filter(filter_1); //Which is equivalent to filter_A and filter_B. result consolidation
Anti screening
var filter_2 = filter_1.not(); //To filter_1. The unqualified part of the screening results
2, Join with Filter for joint filtering of two data sets
(1) Keep only the filter for the left dataset
[ee.Join.simple(), filter a data set when two data sets meet certain conditions]
[EE. Join. Converted(), filter a data set when two data sets do not meet certain conditions]
The following completes the filtering of dataset 1 whose difference in days between dataset 1 and dataset 2 is less than times.
'Used to filter the difference between images in a dataset times Dataset within' var filter_1 = ee.Filter.maxDifference( { difference: times, 'Contact data set through system time( system:time_start)' leftField: 'system:time_start',//Selector for left field, type time_start, i.e. timing from the beginning, in milliseconds rightField: 'system:time_start' //'selector for right field ' //Note: only one of the left and right fields and left and right objects can be selected. If there are left and right objects, there is no selector (the unit of the field already exists); When there is a selector, there cannot be an object. The object is currently unknown }); //The unit of times is milliseconds, for example, 1 * 24 * 60 * 60 * 1000 for one day 'Define an empty simpleJoin,When the filter is applied later, the results that meet the conditions are selected' var simpleJoin = ee.Join.simple(); 'Define an empty invetJoin,When the filter is applied later, the result that does not meet the criteria is selected' var invetJoin = ee.Join.inverted(); 'yes simpleJoin Apply Filter' var simpleJoined = simpleJoin.apply(Dataset 1, Dataset 2, filter_1); print(simpleJoined); //You can print and view the image name of dataset 1 that meets the conditions
(2) Filtering of data sets retained on both sides (data set fusion)
'It is used to filter the data set that meets the conditions between two images and a field' var filter_1 = ee.Filter.eq( { leftField: 'Field 1 name', rightField: 'Field 2 name' }); 'Define an empty innerJoin,When applying a filter, select the results that meet the criteria' var innerJoin = ee.Join.inner('Name 1', 'Name 2'); //The name of the two product definitions generated 'yes innerJoin Apply Filter' var toyJoin = innerJoin.apply(Dataset 1, Dataset 2, filter_1); print(toyJoin); //You can print and view two image names that meet the conditions, corresponding to the front name 1 and name 2 respectively
It is more applied to synthesize different product data sets, such as synthesizing Landsat and MODIS Image data of the same day based on system time. A variety of data fusion to form the required comprehensive products. (band integration of different images through cat() to form the image result after band fusion)
'inner Subsequent product integration' var toyJoin_result = toyJoin.map(function(IM){ return ee.image.cat(IM.get('Name 1'), IM.get('Name 2')); })
(3) Add the qualified data set to the data set on the left in the form of attribute
ee.Join.saveAll() is used to determine the data set that meets the requirements, and the result is marked in the new attribute field
var filter_1 = ee.Filter.maxDifference( { difference: times, leftField: 'system:time_start', rightField: 'system:time_start' }); var saveAllJoin = ee.Join.saveAll( { matchesKey: Attribute name, ordering: 'system:time_start', //sort field ascending: true //Ascending order }); 'yes saveAllJoin Apply Filter' var saveAll_Join_Images = saveAllJoin.apply(Dataset 1, Dataset 2, filter_1); print(saveAll_Join_Images);
ee.Join.saveBest() determines the optimal data set, returns it in the attribute field, and only retains the optimal image
var filter_1 = ee.Filter.maxDifference( { difference: times, leftField: 'system:time_start', rightField: 'system:time_start' }); var saveBestJoin = ee.Join.saveBest( { matchesKey: Attribute name, measureKey: Measurement field //Returns the measurement result, such as the time gap in milliseconds }); 'yes saveBestJoin Apply Filter' var saveBest_Join_Images = saveBestJoin.apply(Dataset 1, Dataset 2, filter_1); print(saveBest_Join_Images);
ee.Join.saveFirst() only retains the first qualified data image on the right
(4) Filtering between spatial data
Space filter introduction:
① ee.Filter.withinDistance()
Image filtering used to determine the gap between the two spatial distances (for example, site data and image grid data)
var filter_1 = ee.Filter.withinDistance({ distance: distance, leftField: '.geo', //. geo refers specifically to spatial attributes rightField: '.geo', maxError: 10 //Maximum scaling error of running computer });
② ee.Filter.intersects()
Image filters used to determine intersecting datasets (for example, raster data filters with which vector data intersects)
var filter_1 = ee.Filter.intersects({ leftField: '.geo', //. geo refers specifically to spatial attributes rightField: '.geo', maxError: 10 //Maximum scaling error of running computer });
The remaining filters that can be filtered based on the space can be combined with the operation of Join to realize the spatial filtering operation of a data set.