Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
Then, generate two sets of different random points containing 25 points each. We
ensure that the points are different by using a different seed, namely 12 and 1,
to generate each set.
Let's add all the ee.FeatureCollections to the map. First, we set the center
of the map to the coordinates defined below and set the zoom level to 6.
Map.setCenter(-111.445,39.251,6);
Now, we add all the layers, specifying the layer labels as text strings (for
example, 'New Features') and colors to display each layer in. We will also
print the results.
Map.addLayer(newFeatures,{},'New Features');Map.addLayer(moreNewFeatures,{color:'red'},'More New Features');Map.addLayer(combinedFeatureCollection,{color:'yellow'},'Combined FeatureCollection');print(newFeatures,moreNewFeatures,combinedFeatureCollection);
Bonus Points
What happens if you change the zoom level in Map.setCenter to 3 or to 12?
Try changing the layer label of 'More New Features' to 'Red Points'. Run
the script again to see if it worked.
[[["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 2022-02-18 UTC."],[[["\u003cp\u003eThis tutorial demonstrates how to combine two \u003ccode\u003eee.FeatureCollection\u003c/code\u003e objects in Google Earth Engine into a new, single \u003ccode\u003eee.FeatureCollection\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial uses randomly generated points within a specified geometry (Utah) as an example dataset.\u003c/p\u003e\n"],["\u003cp\u003eUsers learn to visualize the original and combined \u003ccode\u003eee.FeatureCollection\u003c/code\u003es on a map with custom colors and labels.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial provides a basic framework for merging feature collections, applicable to various geospatial data analysis tasks.\u003c/p\u003e\n"],["\u003cp\u003eBonus points encourage users to experiment with map visualization and layer customization for enhanced understanding.\u003c/p\u003e\n"]]],["The tutorial demonstrates how to combine two `ee.FeatureCollection` objects in Earth Engine. First, it defines a geometry for Utah and generates two distinct sets of 25 random points within it, using different seeds. Next, it merges these two point sets into a new `ee.FeatureCollection`. Finally, it visualizes all three feature collections on a map, assigning different colors and labels to each and printing the results to the console. The tutorial provides challenges that modify zoom levels and labels.\n"],null,["# Combining FeatureCollections\n\n[Edit on GitHub](https://github.com/google/earthengine-community/edit/master/tutorials/combining-feature-collections/index.md \"Contribute to this article on GitHub.\") \n[Report issue](https://github.com/google/earthengine-community/issues/new?title=Issue%20with%20tutorials/combining-feature-collections/index.md&body=Issue%20Description \"Report an issue with this article on GitHub.\") \n[Page history](https://github.com/google/earthengine-community/commits/master/tutorials/combining-feature-collections/index.md \"View changes to this article over time.\") \nAuthor(s): [sabrinaszeto](https://github.com/sabrinaszeto \"View the profile for sabrinaszeto on GitHub\")\nTutorials contributed by the Earth Engine developer community are not part of the official Earth Engine product documentation. \nThis basic tutorial shows how users can combine two `ee.FeatureCollection`s into a new `ee.FeatureCollection`.\n\n\u003cbr /\u003e\n\nCreate two `ee.FeatureCollection` objects\n-----------------------------------------\n\nLet's begin by generating two sets of random points within the boundary of Utah\nstate in the USA. First, define the boundary of Utah as a geometry. \n\n var utahGeometry = ee.Geometry.Polygon([\n [-114.05, 37],\n [-109.05, 37],\n [-109.05, 41],\n [-111.05, 41],\n [-111.05, 42],\n [-114.05, 42]\n ]);\n\nThen, generate two sets of different random points containing 25 points each. We\nensure that the points are different by using a different seed, namely 12 and 1,\nto generate each set. \n\n var newFeatures = ee.FeatureCollection.randomPoints(utahGeometry, 25, 12);\n var moreNewFeatures = ee.FeatureCollection.randomPoints(utahGeometry, 25, 1);\n\nCombine the `ee.FeatureCollection` objects\n------------------------------------------\n\nNext, create a new `ee.FeatureCollection` by merging `newFeatures` and\n`moreNewFeatures`. \n\n var combinedFeatureCollection = newFeatures.merge(moreNewFeatures);\n\nVisualize the Results\n---------------------\n\nLet's add all the `ee.FeatureCollection`s to the map. First, we set the center\nof the map to the coordinates defined below and set the zoom level to 6. \n\n Map.setCenter(-111.445, 39.251, 6);\n\nNow, we add all the layers, specifying the layer labels as text strings (for\nexample, `'New Features'`) and colors to display each layer in. We will also\nprint the results. \n\n Map.addLayer(newFeatures, {}, 'New Features');\n Map.addLayer(moreNewFeatures, {color: 'red'}, 'More New Features');\n Map.addLayer(combinedFeatureCollection, {color: 'yellow'}, 'Combined FeatureCollection');\n\n print(newFeatures, moreNewFeatures, combinedFeatureCollection);\n\nBonus Points\n------------\n\n- What happens if you change the zoom level in `Map.setCenter` to 3 or to 12?\n- Try changing the layer label of `'More New Features'` to `'Red Points'`. Run the script again to see if it worked."]]