Ogłoszenie: wszystkie projekty niekomercyjne zarejestrowane do korzystania z Earth Engine przed
15 kwietnia 2025 r. muszą
potwierdzić spełnianie warunków użycia niekomercyjnego , aby zachować dostęp. Jeśli nie przejdziesz weryfikacji do 26 września 2025 r., Twój dostęp może zostać wstrzymany.
Prześlij opinię
ee.FeatureCollection.merge
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Łączy 2 kolekcje w 1. Wynik zawiera wszystkie elementy, które były w obu kolekcjach.
Elementy z pierwszej kolekcji będą miały identyfikatory z prefiksem „1”, a elementy z drugiej kolekcji będą miały identyfikatory z prefiksem „2 ”.
Uwaga: jeśli musisz scalić wiele kolekcji, umieść je wszystkie w jednej kolekcji i użyj zamiast tego funkcji FeatureCollection.flatten(). Wielokrotne użycie funkcji FeatureCollection.merge() spowoduje coraz dłuższe identyfikatory elementów i spadek wydajności.
Wykorzystanie Zwroty FeatureCollection. merge (collection2)
FeatureCollection
Argument Typ Szczegóły to: collection1
FeatureCollection Pierwsza kolekcja do scalenia. collection2
FeatureCollection Druga kolekcja do scalenia.
Przykłady
Edytor kodu (JavaScript)
// FeatureCollection of points representing forest cover.
var fcForest = ee . FeatureCollection ([
ee . Feature ( ee . Geometry . Point ([ - 122.248 , 37.238 ]),
{ 'id' : 0 , 'cover_class' : 'forest' }),
ee . Feature ( ee . Geometry . Point ([ - 122.204 , 37.222 ]),
{ 'id' : 1 , 'cover_class' : 'forest' }),
ee . Feature ( ee . Geometry . Point ([ - 122.110 , 37.199 ]),
{ 'id' : 2 , 'cover_class' : 'forest' })
]);
// FeatureCollection of points representing urban cover.
var fcUrban = ee . FeatureCollection ([
ee . Feature ( ee . Geometry . Point ([ - 121.953 , 37.372 ]),
{ 'id' : 0 , 'cover_class' : 'urban' }),
ee . Feature ( ee . Geometry . Point ([ - 121.861 , 37.308 ]),
{ 'id' : 1 , 'cover_class' : 'urban' }),
ee . Feature ( ee . Geometry . Point ([ - 121.984 , 37.372 ]),
{ 'id' : 2 , 'cover_class' : 'urban' })
]);
// Merge the two FeatureCollections into one.
var fcMerged = fcForest . merge ( fcUrban );
// Display FeatureCollections on the map.
Map . setCenter ( - 122.034 , 37.296 , 11 );
Map . addLayer ( fcForest , { color : 'green' }, 'Forest points' );
Map . addLayer ( fcUrban , { color : 'grey' }, 'Urban points' );
Map . addLayer ( fcMerged , { color : 'yellow' }, 'Protected areas merged' );
Konfiguracja Pythona
Informacje o interfejsie Python API i używaniu geemap
do interaktywnego programowania znajdziesz na stronie
Środowisko Python .
import ee
import geemap.core as geemap
Colab (Python)
# FeatureCollection of points representing forest cover.
fc_forest = ee . FeatureCollection ([
ee . Feature (
ee . Geometry . Point ([ - 122.248 , 37.238 ]),
{
'id' : 0 ,
'cover_class' : 'forest' ,
'id' : 0 ,
'cover_class' : 'forest' ,
},
),
ee . Feature (
ee . Geometry . Point ([ - 122.204 , 37.222 ]),
{
'id' : 1 ,
'cover_class' : 'forest' ,
'id' : 1 ,
'cover_class' : 'forest' ,
},
),
ee . Feature (
ee . Geometry . Point ([ - 122.110 , 37.199 ]),
{
'id' : 2 ,
'cover_class' : 'forest' ,
'id' : 2 ,
'cover_class' : 'forest' ,
},
),
])
# FeatureCollection of points representing urban cover.
fc_urban = ee . FeatureCollection ([
ee . Feature (
ee . Geometry . Point ([ - 121.953 , 37.372 ]),
{ 'id' : 0 , 'cover_class' : 'urban' , 'id' : 0 , 'cover_class' : 'urban' },
),
ee . Feature (
ee . Geometry . Point ([ - 121.861 , 37.308 ]),
{ 'id' : 1 , 'cover_class' : 'urban' , 'id' : 1 , 'cover_class' : 'urban' },
),
ee . Feature (
ee . Geometry . Point ([ - 121.984 , 37.372 ]),
{ 'id' : 2 , 'cover_class' : 'urban' , 'id' : 2 , 'cover_class' : 'urban' },
),
])
# Merge the two FeatureCollections into one.
fc_merged = fc_forest . merge ( fc_urban )
# Display FeatureCollections on the map.
m = geemap . Map ()
m . set_center ( - 122.034 , 37.296 , 11 )
m . add_layer ( fc_forest , { 'color' : 'green' }, 'Forest points' )
m . add_layer ( fc_urban , { 'color' : 'grey' }, 'Urban points' )
m . add_layer ( fc_merged , { 'color' : 'yellow' }, 'Protected areas merged' )
m
Prześlij opinię
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0 , a fragmenty kodu są dostępne na licencji Apache 2.0 . Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers . Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
Chcesz przekazać coś jeszcze?
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-26 UTC."],[],[]]