97 join table
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
In [2]:
Copied!
import ee
import geemap
import ee
import geemap
Add data to the map.
In [3]:
Copied!
Map = geemap.Map()
countries = ee.FeatureCollection('users/giswqs/public/countries')
Map.addLayer(countries, {}, 'Countries')
Map
Map = geemap.Map()
countries = ee.FeatureCollection('users/giswqs/public/countries')
Map.addLayer(countries, {}, 'Countries')
Map
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Display the attribute table.
In [4]:
Copied!
geemap.ee_to_df(countries)
geemap.ee_to_df(countries)
Out[4]:
name | id | |
---|---|---|
0 | Somaliland | -99 |
1 | Northern Cyprus | -99 |
2 | Afghanistan | AFG |
3 | Angola | AGO |
4 | Albania | ALB |
... | ... | ... |
174 | Yemen | YEM |
175 | South Africa | ZAF |
176 | Zambia | ZMB |
177 | Zimbabwe | ZWE |
178 | Kosovo | CS-KM |
179 rows × 2 columns
Get data to be joined to the attribute table.
In [5]:
Copied!
data = 'https://raw.githubusercontent.com/giswqs/geemap/master/examples/data/countries.geojson'
data = 'https://raw.githubusercontent.com/giswqs/geemap/master/examples/data/countries.geojson'
Join data to the attribute table.
In [6]:
Copied!
fc = geemap.ee_join_table(countries, data, src_key='id', dst_key='ISO_A3')
fc = geemap.ee_join_table(countries, data, src_key='id', dst_key='ISO_A3')
Display the new attribute table.
In [7]:
Copied!
geemap.ee_to_df(fc)
geemap.ee_to_df(fc)
Out[7]:
GDP_MD_EST | ISO_A2 | POP_RANK | CONTINENT | INCOME_GRP | POP_EST | type | SUBREGION | NAME | name | id | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 3600.0 | -99 | 10.0 | Asia | 3. Upper middle income | 265100.0 | Feature | Western Asia | N. Cyprus | Somaliland | -99 |
1 | 3600.0 | -99 | 10.0 | Asia | 3. Upper middle income | 265100.0 | Feature | Western Asia | N. Cyprus | Northern Cyprus | -99 |
2 | 64080.0 | AF | 15.0 | Asia | 5. Low income | 34124811.0 | Feature | Southern Asia | Afghanistan | Afghanistan | AFG |
3 | 189000.0 | AO | 15.0 | Africa | 3. Upper middle income | 29310273.0 | Feature | Middle Africa | Angola | Angola | AGO |
4 | 33900.0 | AL | 12.0 | Europe | 4. Lower middle income | 3047987.0 | Feature | Southern Europe | Albania | Albania | ALB |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
174 | 73450.0 | YE | 15.0 | Asia | 4. Lower middle income | 28036829.0 | Feature | Western Asia | Yemen | Yemen | YEM |
175 | 739100.0 | ZA | 16.0 | Africa | 3. Upper middle income | 54841552.0 | Feature | Southern Africa | South Africa | South Africa | ZAF |
176 | 65170.0 | ZM | 14.0 | Africa | 4. Lower middle income | 15972000.0 | Feature | Eastern Africa | Zambia | Zambia | ZMB |
177 | 28330.0 | ZW | 14.0 | Africa | 5. Low income | 13805084.0 | Feature | Eastern Africa | Zimbabwe | Zimbabwe | ZWE |
178 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | Kosovo | CS-KM |
179 rows × 11 columns
Add the new data to the map.
In [8]:
Copied!
Map.addLayer(fc, {}, 'Countries New')
Map.addLayer(fc, {}, 'Countries New')
Last update:
2022-03-14