From 2afd46700d68fc84c9a7777984c26d4d3e5b1b25 Mon Sep 17 00:00:00 2001 From: Rodrigo Principe Date: Mon, 6 Aug 2018 09:20:09 -0300 Subject: [PATCH] instance a FeatureCollection using a GeoJSON dict --- python/ee/featurecollection.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/ee/featurecollection.py b/python/ee/featurecollection.py index 4f8791070..997974421 100644 --- a/python/ee/featurecollection.py +++ b/python/ee/featurecollection.py @@ -33,7 +33,8 @@ def __init__(self, args, opt_column=None): 2) A geometry. 3) A feature. 4) An array of features. - 5) A computed object - reinterpreted as a collection. + 5) A GeoJSON FeatureCollection. + 6) A computed object - reinterpreted as a collection. opt_column: The name of the geometry column to use. Only useful with the string constructor. @@ -69,6 +70,12 @@ def __init__(self, args, opt_column=None): apifunction.ApiFunction.lookup('Collection'), { 'features': args }) + elif isinstance(args, dict) and args.get('type') == 'FeatureCollection': + # A GeoJSON FeatureCollection + super(FeatureCollection, self).__init__( + apifunction.ApiFunction.lookup('Collection'), { + 'features': [feature.Feature(i) for i in args.get('features')] + }) elif isinstance(args, computedobject.ComputedObject): # A custom object to reinterpret as a FeatureCollection. super(FeatureCollection, self).__init__(