Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003eCreates a unary or binary filter that passes if the left operand is greater than the right operand.\u003c/p\u003e\n"],["\u003cp\u003eThe filter can compare two properties of a feature or a property against a constant value.\u003c/p\u003e\n"],["\u003cp\u003eIt can be used for filtering feature collections based on relational expressions.\u003c/p\u003e\n"],["\u003cp\u003eUseful in joins to group features based on shared properties.\u003c/p\u003e\n"]]],["The core functionality described is creating a filter where the left operand is greater than the right. This `ee.Filter.greaterThan()` function compares either two fields or a field and a value. It accepts `leftField` and `rightField` to compare properties, or `leftValue` and `rightValue` for field-to-value comparisons. The filter is used within the context of filtering feature collections and performing joins based on relational comparisons, for example finding the plots with invasive forb cover greater than a non-invasive one.\n"],null,["Creates a unary or binary filter that passes if the left operand is greater than the right operand.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------------------------------------------------------------|---------|\n| `ee.Filter.greaterThan(`*leftField* `, `*rightValue* `, `*rightField* `, `*leftValue*`)` | Filter |\n\n| Argument | Type | Details |\n|--------------|-----------------------|---------------------------------------------------------------------------------------|\n| `leftField` | String, default: null | A selector for the left operand. Should not be specified if leftValue is specified. |\n| `rightValue` | Object, default: null | The value of the right operand. Should not be specified if rightField is specified. |\n| `rightField` | String, default: null | A selector for the right operand. Should not be specified if rightValue is specified. |\n| `leftValue` | Object, default: null | The value of the left operand. Should not be specified if leftField is specified. |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\n// Field site vegetation characteristics from projects in western USA.\nvar fc = ee.FeatureCollection('BLM/AIM/v1/TerrADat/TerrestrialAIM')\n .filter('ProjectName == \"Colorado NWDO Kremmling FO 2016\"');\n\n// Display field plots on the map.\nMap.setCenter(-107.792, 39.871, 7);\nMap.addLayer(fc);\n\n// Compare the per-feature values of two properties and filter the collection\n// based on the results of various relational expressions. The two properties\n// to compare are invasive and non-invasive annual forb cover at each plot.\nvar leftProperty = 'InvAnnForbCover_AH';\nvar rightProperty = 'NonInvAnnForbCover_AH';\n\nprint('Plots where invasive forb cover is...');\n\nprint('...EQUAL to non-invasive cover',\n fc.filter(ee.Filter.equals(\n {leftField: leftProperty, rightField: rightProperty})));\n\nprint('...NOT EQUAL to non-invasive cover',\n fc.filter(ee.Filter.notEquals(\n {leftField: leftProperty, rightField: rightProperty})));\n\nprint('...LESS THAN non-invasive cover',\n fc.filter(ee.Filter.lessThan(\n {leftField: leftProperty, rightField: rightProperty})));\n\nprint('...LESS THAN OR EQUAL to non-invasive cover',\n fc.filter(ee.Filter.lessThanOrEquals(\n {leftField: leftProperty, rightField: rightProperty})));\n\nprint('...GREATER THAN non-invasive cover',\n fc.filter(ee.Filter.greaterThan(\n {leftField: leftProperty, rightField: rightProperty})));\n\nprint('...GREATER THAN OR EQUAL to non-invasive cover',\n fc.filter(ee.Filter.greaterThanOrEquals(\n {leftField: leftProperty, rightField: rightProperty})));\n\nprint('...is not greater than 10 percent different than non-invasive cover',\n fc.filter(ee.Filter.maxDifference(\n {difference: 10, leftField: leftProperty, rightField: rightProperty})));\n\n// Instead of comparing values of two feature properties using the leftField\n// and rightField parameters, you can compare a property value (leftProperty)\n// against a constant value (rightValue).\nprint('Plots where invasive forb cover is greater than 20%',\n fc.filter(ee.Filter.greaterThan(\n {leftField: leftProperty, rightValue: 20})));\n\n// You can also swap the operands to assign the constant to the left side of\n// the relational expression (leftValue) and the feature property on the right\n// (rightField). Here, we get the complement of the previous example.\nprint('Plots where 20% is greater than invasive forb cover.',\n fc.filter(ee.Filter.greaterThan(\n {leftValue: 20, rightField: leftProperty})));\n\n// Binary filters are useful in joins. For example, group all same-site plots\n// together using a saveAll join.\nvar groupingProp = 'SiteID';\nvar sitesFc = fc.distinct(groupingProp);\n\nvar joinFilter = ee.Filter.equals(\n {leftField: groupingProp, rightField: groupingProp});\n\nvar groupedPlots = ee.Join.saveAll('site_plots').apply(sitesFc, fc, joinFilter);\nprint('List of plots in first site', groupedPlots.first().get('site_plots'));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\nColab (Python) \n\n```python\n# Field site vegetation characteristics from projects in western USA.\nfc = ee.FeatureCollection('BLM/AIM/v1/TerrADat/TerrestrialAIM').filter(\n 'ProjectName == \"Colorado NWDO Kremmling FO 2016\"'\n)\n\n# Display field plots on the map.\nm = geemap.Map()\nm.set_center(-107.792, 39.871, 7)\nm.add_layer(fc)\ndisplay(m)\n\n# Compare the per-feature values of two properties and filter the collection\n# based on the results of various relational expressions. The two properties\n# to compare are invasive and non-invasive annual forb cover at each plot.\nleft_property = 'InvAnnForbCover_AH'\nright_property = 'NonInvAnnForbCover_AH'\n\ndisplay('Plots where invasive forb cover is...')\n\ndisplay(\n '...EQUAL to non-invasive cover',\n fc.filter(\n ee.Filter.equals(leftField=left_property, rightField=right_property)\n ),\n)\n\ndisplay(\n '...NOT EQUAL to non-invasive cover',\n fc.filter(\n ee.Filter.notEquals(leftField=left_property, rightField=right_property)\n ),\n)\n\ndisplay(\n '...LESS THAN non-invasive cover',\n fc.filter(\n ee.Filter.lessThan(leftField=left_property, rightField=right_property)\n ),\n)\n\ndisplay(\n '...LESS THAN OR EQUAL to non-invasive cover',\n fc.filter(\n ee.Filter.lessThanOrEquals(\n leftField=left_property, rightField=right_property\n )\n ),\n)\n\ndisplay(\n '...GREATER THAN non-invasive cover',\n fc.filter(\n ee.Filter.greaterThan(\n leftField=left_property, rightField=right_property\n )\n ),\n)\n\ndisplay(\n '...GREATER THAN OR EQUAL to non-invasive cover',\n fc.filter(\n ee.Filter.greaterThanOrEquals(\n leftField=left_property, rightField=right_property\n )\n ),\n)\n\ndisplay(\n '...is not greater than 10 percent different than non-invasive cover',\n fc.filter(\n ee.Filter.maxDifference(\n difference=10, leftField=left_property, rightField=right_property\n )\n ),\n)\n\n# Instead of comparing values of two feature properties using the leftField\n# and rightField parameters, you can compare a property value (left_property)\n# against a constant value (rightValue).\ndisplay(\n 'Plots where invasive forb cover is greater than 20%',\n fc.filter(ee.Filter.greaterThan(leftField=left_property, rightValue=20)),\n)\n\n# You can also swap the operands to assign the constant to the left side of\n# the relational expression (leftValue) and the feature property on the right\n# (rightField). Here, we get the complement of the previous example.\ndisplay(\n 'Plots where 20% is greater than invasive forb cover.',\n fc.filter(ee.Filter.greaterThan(leftValue=20, rightField=left_property)),\n)\n\n# Binary filters are useful in joins. For example, group all same-site plots\n# together using a saveAll join.\ngrouping_prop = 'SiteID'\nsites_fc = fc.distinct(grouping_prop)\n\njoin_filter = ee.Filter.equals(\n leftField=grouping_prop, rightField=grouping_prop\n)\n\ngrouped_plots = ee.Join.saveAll('site_plots').apply(sites_fc, fc, join_filter)\ndisplay('List of plots in first site', grouped_plots.first().get('site_plots'))\n```"]]