byProperty#
- static geetools.ee_join.JoinAccessor.byProperty(primary, secondary, field, outer=False)#
Join 2 collections by a given property field.
It assumes ids are unique so uses
ee.Join.saveFirst().- Parameters:
primary (ee.FeatureCollection) – The first collection.
secondary (ee.FeatureCollection) – The second collection.
outer (bool) – Whether to keep non-matching features.
- Returns:
The joined collection.
- Return type:
Example
import ee, geetools from geetools.utils import initialize_documentation initialize_documentation() # build fake featureCollections on the same point point = ee.Geometry.Point([0,0]) prop1 = {'id': 1, 'prop_from_fc1': 'I am from fc1'} prop2 = {'id': 1, 'prop_from_fc2': 'I am from fc2'} fc1 = ee.FeatureCollection([ee.Feature(point, prop1)]) fc2 = ee.FeatureCollection([ee.Feature(point, prop2)]) # join them together in the same featureCollection joined = ee.Join.geetools.byProperty(fc1, fc2, 'id') joined.getInfo()
{'type': 'FeatureCollection', 'columns': {}, 'features': [{'type': 'Feature', 'geometry': {'type': 'Point', 'coordinates': [0, 0]}, 'id': '0', 'properties': {'id': 1, 'prop_from_fc1': 'I am from fc1', 'prop_from_fc2': 'I am from fc2'}}]}