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.Collection) – the first collection

  • secondary (ee.Collection) – the second collection

  • field (str | ee.String) – the field to join by

  • outer (bool) – whether to keep non matching features

Returns:

the joined collection

Return type:

ee.Collection

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'}}]}