# Initialize Earth Engine (uncomment when running)
ee.Authenticate()
ee.Initialize(project="hs-brazilreforestation")site
Site class — geometry + identity for polygon-first analysis.
Site
The Site class is the fundamental unit of analysis in gee-polygons. It wraps a polygon geometry with temporal metadata, making it easy to extract time-series features from Google Earth Engine.
A Site represents a single spatial unit (e.g., a restoration plot, conservation area, or agricultural field) that you want to analyze over time.
Site
def Site(
feature:ee.Feature, start_year:Optional[int]=None, site_id:Optional[str]=None
):
A polygon with temporal context for GEE analysis.
The Site class wraps an ee.Feature with convenient accessors for common properties like start_year and area, plus helper methods for temporal analysis.
Loading Sites
Helper functions to load sites from common formats.
load_sites
def load_sites(
path:Union[str, Path], source_crs:Optional[str]=None
)->list[Site]:
Load sites from a GeoJSON file.
Args: path: Path to GeoJSON file source_crs: Override source CRS (auto-detected from file if present)
Returns: List of Site objects
sites_from_geodataframe
def sites_from_geodataframe(
gdf:gpd.GeoDataFrame, geometry_col:str='geometry'
)->list[Site]:
Create Sites from a GeoDataFrame.
This is the recommended way to work with filtered/sorted site data: 1. Load your GeoJSON into a GeoDataFrame 2. Filter and sort using pandas/geopandas operations 3. Convert to Sites for GEE analysis
Args: gdf: A GeoDataFrame with polygon geometries geometry_col: Name of the geometry column (default ‘geometry’)
Returns: List of Site objects
Example: >>> gdf = gpd.read_file(‘sites.geojson’) >>> # Filter for large sites that started after 2015 >>> filtered = gdf[(gdf[‘area_ha’] > 10) & (gdf[‘start_year’] > 2015)] >>> # Sort by area descending >>> filtered = filtered.sort_values(‘area_ha’, ascending=False) >>> # Convert to Sites >>> sites = sites_from_geodataframe(filtered)
Example Usage
Let’s load some restoration sites and explore a single site.
# Load sites from GeoJSON
sites = load_sites('../data/restoration_sites_subset.geojson')
print(f"Loaded {len(sites)} sites")Loaded 10 sites
# Explore a single site
site = sites[8]
print(site)
print(f"Start year: {site.start_year}")
print(f"Area: {site.area_ha:.2f} ha")
print(f"Years for analysis: {site.years(end_year=2024)}")Site(id=9368, start_year=2012)
Start year: 2012
Area: 13.19 ha
Years for analysis: [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024]
site.geometryPolygon (188 vertices)
- type:Polygon
coordinates: List (6 elements)
0: List (188 elements)
0: [-42.275210643251626, -22.514167030511306]
- 0:-42.275210643251626
- 1:-22.514167030511306
1: [-42.27548970699436, -22.514059697226372]
- 0:-42.27548970699436
- 1:-22.514059697226372
2: [-42.27559704330654, -22.51410262937128]
- 0:-42.27559704330654
- 1:-22.51410262937128
3: [-42.27574730115466, -22.51408116097226]
- 0:-42.27574730115466
- 1:-22.51408116097226
4: [-42.275639975610645, -22.51388796269542]
- 0:-42.275639975610645
- 1:-22.51388796269542
5: [-42.27582311225542, -22.513780802946762]
- 0:-42.27582311225542
- 1:-22.513780802946762
6: [-42.27598343758595, -22.513651834578887]
- 0:-42.27598343758595
- 1:-22.513651834578887
7: [-42.275983436256546, -22.51358743955051]
- 0:-42.275983436256546
- 1:-22.51358743955051
8: [-42.27594050620802, -22.513587434135154]
- 0:-42.27594050620802
- 1:-22.513587434135154
9: [-42.2758546361049, -22.513501574231505]
- 0:-42.2758546361049
- 1:-22.513501574231505
10: [-42.27570437568856, -22.513480103416555]
- 0:-42.27570437568856
- 1:-22.513480103416555
11: [-42.275639969743075, -22.51352303657724]
- 0:-42.275639969743075
- 1:-22.51352303657724
12: [-42.27585463344533, -22.513308378347354]
- 0:-42.27585463344533
- 1:-22.513308378347354
13: [-42.27583317240558, -22.513179576211694]
- 0:-42.27583317240558
- 1:-22.513179576211694
14: [-42.27619809680631, -22.51305077590233]
- 0:-42.27619809680631
- 1:-22.51305077590233
15: [-42.27604783190905, -22.512921978241284]
- 0:-42.27604783190905
- 1:-22.512921978241284
16: [-42.276112229217915, -22.51281464971927]
- 0:-42.276112229217915
- 1:-22.51281464971927
17: [-42.27621956010725, -22.512599989481448]
- 0:-42.27621956010725
- 1:-22.512599989481448
18: [-42.27619810087997, -22.512449720886305]
- 0:-42.27619810087997
- 1:-22.512449720886305
19: [-42.276262496690066, -22.51212772079941]
- 0:-42.276262496690066
- 1:-22.51212772079941
20: [-42.276262492090886, -22.51208479130618]
- 0:-42.276262492090886
- 1:-22.51208479130618
21: [-42.27604783088025, -22.51208479698881]
- 0:-42.27604783088025
- 1:-22.51208479698881
22: [-42.275940502487025, -22.512063330994096]
- 0:-42.275940502487025
- 1:-22.512063330994096
23: [-42.27596197143439, -22.51199892745188]
- 0:-42.27596197143439
- 1:-22.51199892745188
24: [-42.27602637039906, -22.51187013424813]
- 0:-42.27602637039906
- 1:-22.51187013424813
25: [-42.276133700425, -22.511805730543585]
- 0:-42.276133700425
- 1:-22.511805730543585
26: [-42.27617663266103, -22.5117198644323]
- 0:-42.27617663266103
- 1:-22.5117198644323
27: [-42.27604783431356, -22.51148373383522]
- 0:-42.27604783431356
- 1:-22.51148373383522
28: [-42.27604783478149, -22.51141933882142]
- 0:-42.27604783478149
- 1:-22.51141933882142
29: [-42.275618504095036, -22.511333471593534]
- 0:-42.275618504095036
- 1:-22.511333471593534
30: [-42.27555410249263, -22.511269069644836]
- 0:-42.27555410249263
- 1:-22.511269069644836
31: [-42.27600489988596, -22.51137640398435]
- 0:-42.27600489988596
- 1:-22.51137640398435
32: [-42.27606929687545, -22.511333471328502]
- 0:-42.27606929687545
- 1:-22.511333471328502
33: [-42.276112226499336, -22.51118320924917]
- 0:-42.276112226499336
- 1:-22.51118320924917
34: [-42.276176631008966, -22.511161741375275]
- 0:-42.276176631008966
- 1:-22.511161741375275
35: [-42.27619810101202, -22.511161743655087]
- 0:-42.27619810101202
- 1:-22.511161743655087
36: [-42.276305431000665, -22.511591067823602]
- 0:-42.276305431000665
- 1:-22.511591067823602
37: [-42.27652009695992, -22.51163400116744]
- 0:-42.27652009695992
- 1:-22.51163400116744
38: [-42.27662742342832, -22.51159107168011]
- 0:-42.27662742342832
- 1:-22.51159107168011
39: [-42.27671328827313, -22.511634000707772]
- 0:-42.27671328827313
- 1:-22.511634000707772
40: [-42.276691828239706, -22.511784264295155]
- 0:-42.276691828239706
- 1:-22.511784264295155
41: [-42.27649862381084, -22.51202039075548]
- 0:-42.27649862381084
- 1:-22.51202039075548
42: [-42.27652009656693, -22.512084788988204]
- 0:-42.27652009656693
- 1:-22.512084788988204
43: [-42.276713288755836, -22.51199892883776]
- 0:-42.276713288755836
- 1:-22.51199892883776
44: [-42.27658448883268, -22.512213595420942]
- 0:-42.27658448883268
- 1:-22.512213595420942
45: [-42.27669182119072, -22.51227799320309]
- 0:-42.27669182119072
- 1:-22.51227799320309
46: [-42.2767562179283, -22.512599986592416]
- 0:-42.2767562179283
- 1:-22.512599986592416
47: [-42.27654156081949, -22.5127717151337]
- 0:-42.27654156081949
- 1:-22.5127717151337
48: [-42.27654155813464, -22.512728783863228]
- 0:-42.27654155813464
- 1:-22.512728783863228
49: [-42.2764986226948, -22.512685850011305]
- 0:-42.2764986226948
- 1:-22.512685850011305
50: [-42.27636982792191, -22.512707321409327]
- 0:-42.27636982792191
- 1:-22.512707321409327
51: [-42.27628396516165, -22.512857578162468]
- 0:-42.27628396516165
- 1:-22.512857578162468
52: [-42.27633245250902, -22.513051535080365]
- 0:-42.27633245250902
- 1:-22.513051535080365
53: [-42.27639129690994, -22.51328691229198]
- 0:-42.27639129690994
- 1:-22.51328691229198
54: [-42.27679915263887, -22.513308369791204]
- 0:-42.27679915263887
- 1:-22.513308369791204
55: [-42.27697088673059, -22.513523038714375]
- 0:-42.27697088673059
- 1:-22.513523038714375
56: [-42.277443143756464, -22.51294344740214]
- 0:-42.277443143756464
- 1:-22.51294344740214
57: [-42.2778510120501, -22.51285757783742]
- 0:-42.2778510120501
- 1:-22.51285757783742
58: [-42.278194462292795, -22.51249265225013]
- 0:-42.278194462292795
- 1:-22.51249265225013
59: [-42.27828033273685, -22.51234238448175]
- 0:-42.27828033273685
- 1:-22.51234238448175
60: [-42.27821593162581, -22.512192122742313]
- 0:-42.27821593162581
- 1:-22.512192122742313
61: [-42.27770074145299, -22.512599982336017]
- 0:-42.27770074145299
- 1:-22.512599982336017
62: [-42.27731434627471, -22.512449717483978]
- 0:-42.27731434627471
- 1:-22.512449717483978
63: [-42.27722848058384, -22.51255705438234]
- 0:-42.27722848058384
- 1:-22.51255705438234
64: [-42.27714261426535, -22.51244971966045]
- 0:-42.27714261426535
- 1:-22.51244971966045
65: [-42.27727141057187, -22.51225652626703]
- 0:-42.27727141057187
- 1:-22.51225652626703
66: [-42.2774646146195, -22.512320922064912]
- 0:-42.2774646146195
- 1:-22.512320922064912
67: [-42.27752900961183, -22.512213591913657]
- 0:-42.27752900961183
- 1:-22.512213591913657
68: [-42.27744314399804, -22.511934526938692]
- 0:-42.27744314399804
- 1:-22.511934526938692
69: [-42.27744314844112, -22.511676934988632]
- 0:-42.27744314844112
- 1:-22.511676934988632
70: [-42.27774367755064, -22.511784260056544]
- 0:-42.27774367755064
- 1:-22.511784260056544
71: [-42.27780807666234, -22.511634000362754]
- 0:-42.27780807666234
- 1:-22.511634000362754
72: [-42.27770073802748, -22.51146226874756]
- 0:-42.27770073802748
- 1:-22.51146226874756
73: [-42.277593411358396, -22.511354942292726]
- 0:-42.277593411358396
- 1:-22.511354942292726
74: [-42.27767927651908, -22.511161744377983]
- 0:-42.27767927651908
- 1:-22.511161744377983
75: [-42.27750754562423, -22.5109256107394]
- 0:-42.27750754562423
- 1:-22.5109256107394
76: [-42.2779154010885, -22.51105441016614]
- 0:-42.2779154010885
- 1:-22.51105441016614
77: [-42.27802273647532, -22.51101147982171]
- 0:-42.27802273647532
- 1:-22.51101147982171
78: [-42.278022737347634, -22.510839749339123]
- 0:-42.278022737347634
- 1:-22.510839749339123
79: [-42.27789393411594, -22.510710946296207]
- 0:-42.27789393411594
- 1:-22.510710946296207
80: [-42.27825886382392, -22.51071095075074]
- 0:-42.27825886382392
- 1:-22.51071095075074
81: [-42.278344730359144, -22.51017428949828]
- 0:-42.278344730359144
- 1:-22.51017428949828
82: [-42.2781515370107, -22.510045490099582]
- 0:-42.2781515370107
- 1:-22.510045490099582
83: [-42.27797980234042, -22.510088425546165]
- 0:-42.27797980234042
- 1:-22.510088425546165
84: [-42.277765136842696, -22.50998109019282]
- 0:-42.277765136842696
- 1:-22.50998109019282
85: [-42.27767927029407, -22.509873764850852]
- 0:-42.27767927029407
- 1:-22.509873764850852
86: [-42.27748607926547, -22.509809361663283]
- 0:-42.27748607926547
- 1:-22.509809361663283
87: [-42.27737874353611, -22.509787895725175]
- 0:-42.27737874353611
- 1:-22.509787895725175
88: [-42.27714261805961, -22.509916693108416]
- 0:-42.27714261805961
- 1:-22.509916693108416
89: [-42.27705675511984, -22.509787893787045]
- 0:-42.27705675511984
- 1:-22.509787893787045
90: [-42.2770567491406, -22.509530301666206]
- 0:-42.2770567491406
- 1:-22.509530301666206
91: [-42.2769923543574, -22.509487366038115]
- 0:-42.2769923543574
- 1:-22.509487366038115
92: [-42.277030166315235, -22.509261044189607]
- 0:-42.277030166315235
- 1:-22.509261044189607
93: [-42.27697228974889, -22.50924001483783]
- 0:-42.27697228974889
- 1:-22.50924001483783
94: [-42.27699234943114, -22.50907950643288]
- 0:-42.27699234943114
- 1:-22.50907950643288
95: [-42.27714262108001, -22.50912244149436]
- 0:-42.27714262108001
- 1:-22.50912244149436
96: [-42.27718555229054, -22.509337098261685]
- 0:-42.27718555229054
- 1:-22.509337098261685
97: [-42.27731434960612, -22.50935856626414]
- 0:-42.27731434960612
- 1:-22.50935856626414
98: [-42.27752901408932, -22.50929417072681]
- 0:-42.27752901408932
- 1:-22.50929417072681
99: [-42.277722205601975, -22.5093585647902]
- 0:-42.277722205601975
- 1:-22.5093585647902
100: [-42.277808072673174, -22.509294167722814]
- 0:-42.277808072673174
- 1:-22.509294167722814
101: [-42.27778660759786, -22.509100969628008]
- 0:-42.27778660759786
- 1:-22.509100969628008
102: [-42.2776792731788, -22.509058038318134]
- 0:-42.2776792731788
- 1:-22.509058038318134
103: [-42.27761487384549, -22.508907777400882]
- 0:-42.27761487384549
- 1:-22.508907777400882
104: [-42.27770074208186, -22.50890777458708]
- 0:-42.27770074208186
- 1:-22.50890777458708
105: [-42.277765137292974, -22.50901510684431]
- 0:-42.277765137292974
- 1:-22.50901510684431
106: [-42.27782953489378, -22.509036577479606]
- 0:-42.27782953489378
- 1:-22.509036577479606
107: [-42.27800126823569, -22.508993642966892]
- 0:-42.27800126823569
- 1:-22.508993642966892
108: [-42.278022733860006, -22.508950704595716]
- 0:-42.278022733860006
- 1:-22.508950704595716
109: [-42.27793686875534, -22.508843372219854]
- 0:-42.27793686875534
- 1:-22.508843372219854
110: [-42.277679278144674, -22.50871457560443]
- 0:-42.277679278144674
- 1:-22.50871457560443
111: [-42.277507541318464, -22.508778975367882]
- 0:-42.277507541318464
- 1:-22.508778975367882
112: [-42.2774860768839, -22.508886308772574]
- 0:-42.2774860768839
- 1:-22.508886308772574
113: [-42.27737874513851, -22.50899364306389]
- 0:-42.27737874513851
- 1:-22.50899364306389
114: [-42.277261064146934, -22.509002726483807]
- 0:-42.277261064146934
- 1:-22.509002726483807
115: [-42.27711958846335, -22.509048354712522]
- 0:-42.27711958846335
- 1:-22.509048354712522
116: [-42.276949418787, -22.508929237499558]
- 0:-42.276949418787
- 1:-22.508929237499558
117: [-42.27690648714852, -22.50865017569264]
- 0:-42.27690648714852
- 1:-22.50865017569264
118: [-42.276648887302535, -22.508521379177477]
- 0:-42.276648887302535
- 1:-22.508521379177477
119: [-42.27606929964192, -22.508285252368754]
- 0:-42.27606929964192
- 1:-22.508285252368754
120: [-42.275854634199455, -22.508349655042135]
- 0:-42.275854634199455
- 1:-22.508349655042135
121: [-42.27583316751474, -22.50847845280262]
- 0:-42.27583316751474
- 1:-22.50847845280262
122: [-42.275597040167234, -22.508414051157605]
- 0:-42.275597040167234
- 1:-22.508414051157605
123: [-42.27557557641866, -22.50871458100443]
- 0:-42.27557557641866
- 1:-22.50871458100443
124: [-42.27572583317582, -22.508800447392296]
- 0:-42.27572583317582
- 1:-22.508800447392296
125: [-42.275940497193176, -22.509186833633283]
- 0:-42.275940497193176
- 1:-22.509186833633283
126: [-42.27632690052043, -22.50927270516431]
- 0:-42.27632690052043
- 1:-22.50927270516431
127: [-42.27638079533135, -22.509276453348317]
- 0:-42.27638079533135
- 1:-22.509276453348317
128: [-42.27639129648531, -22.509444432956133]
- 0:-42.27639129648531
- 1:-22.509444432956133
129: [-42.276369824702265, -22.50946589721381]
- 0:-42.276369824702265
- 1:-22.50946589721381
130: [-42.276305433830146, -22.509830827057467]
- 0:-42.276305433830146
- 1:-22.509830827057467
131: [-42.2763054271484, -22.50980936042605]
- 0:-42.2763054271484
- 1:-22.50980936042605
132: [-42.276069296649105, -22.510109888179386]
- 0:-42.276069296649105
- 1:-22.510109888179386
133: [-42.276069301626706, -22.51021722354472]
- 0:-42.276069301626706
- 1:-22.51021722354472
134: [-42.27572583911744, -22.5101742879929]
- 0:-42.27572583911744
- 1:-22.5101742879929
135: [-42.2757037865831, -22.510121799704176]
- 0:-42.2757037865831
- 1:-22.510121799704176
136: [-42.27509815906286, -22.509659290627898]
- 0:-42.27509815906286
- 1:-22.509659290627898
137: [-42.27503891820503, -22.50972349329539]
- 0:-42.27503891820503
- 1:-22.50972349329539
138: [-42.275021733614885, -22.509796523902565]
- 0:-42.275021733614885
- 1:-22.509796523902565
139: [-42.2749530451381, -22.51008841966306]
- 0:-42.2749530451381
- 1:-22.51008841966306
140: [-42.27501782723765, -22.510174793914544]
- 0:-42.27501782723765
- 1:-22.510174793914544
141: [-42.27508185011239, -22.510260155128893]
- 0:-42.27508185011239
- 1:-22.510260155128893
142: [-42.275139090883386, -22.510260153826845]
- 0:-42.275139090883386
- 1:-22.510260153826845
143: [-42.27514624916511, -22.510260152249852]
- 0:-42.27514624916511
- 1:-22.510260152249852
144: [-42.2752321158447, -22.510346022230422]
- 0:-42.2752321158447
- 1:-22.510346022230422
145: [-42.27536091306816, -22.51049628365846]
- 0:-42.27536091306816
- 1:-22.51049628365846
146: [-42.27532020600598, -22.51063197062635]
- 0:-42.27532020600598
- 1:-22.51063197062635
147: [-42.27529651304267, -22.510710948027214]
- 0:-42.27529651304267
- 1:-22.510710948027214
148: [-42.27527950612079, -22.510889506122737]
- 0:-42.27527950612079
- 1:-22.510889506122737
149: [-42.27518917603976, -22.510968546005387]
- 0:-42.27518917603976
- 1:-22.510968546005387
150: [-42.27521963799877, -22.51105992853934]
- 0:-42.27521963799877
- 1:-22.51105992853934
151: [-42.275253578575516, -22.51116173988567]
- 0:-42.275253578575516
- 1:-22.51116173988567
152: [-42.274695454372996, -22.51150520692635]
- 0:-42.274695454372996
- 1:-22.51150520692635
153: [-42.27465172345594, -22.511643684951327]
- 0:-42.27465172345594
- 1:-22.511643684951327
154: [-42.27456665340917, -22.511913055650734]
- 0:-42.27456665340917
- 1:-22.511913055650734
155: [-42.274588122243706, -22.511977457612172]
- 0:-42.274588122243706
- 1:-22.511977457612172
156: [-42.274631049466954, -22.511998926182862]
- 0:-42.274631049466954
- 1:-22.511998926182862
157: [-42.27480278743671, -22.511891592470047]
- 0:-42.27480278743671
- 1:-22.511891592470047
158: [-42.2749101183695, -22.51202039533575]
- 0:-42.2749101183695
- 1:-22.51202039533575
159: [-42.27489478174481, -22.51204084300142]
- 0:-42.27489478174481
- 1:-22.51204084300142
160: [-42.27478132253972, -22.512192121003018]
- 0:-42.27478132253972
- 1:-22.512192121003018
161: [-42.27478132200278, -22.51222008313133]
- 0:-42.27478132200278
- 1:-22.51222008313133
162: [-42.27478537906706, -22.512208350267443]
- 0:-42.27478537906706
- 1:-22.512208350267443
163: [-42.274792134639455, -22.51223537247311]
- 0:-42.274792134639455
- 1:-22.51223537247311
164: [-42.274796023960675, -22.512231349216602]
- 0:-42.274796023960675
- 1:-22.512231349216602
165: [-42.274781322133435, -22.512250388612784]
- 0:-42.274781322133435
- 1:-22.512250388612784
166: [-42.27478132124345, -22.512298477660472]
- 0:-42.27478132124345
- 1:-22.512298477660472
167: [-42.274781316903095, -22.512739705603746]
- 0:-42.274781316903095
- 1:-22.512739705603746
168: [-42.27480278862771, -22.51294344256925]
- 0:-42.27480278862771
- 1:-22.51294344256925
169: [-42.27469545813433, -22.513007844342997]
- 0:-42.27469545813433
- 1:-22.513007844342997
170: [-42.27460958587823, -22.513136645115935]
- 0:-42.27460958587823
- 1:-22.513136645115935
171: [-42.274588119620184, -22.513179572933268]
- 0:-42.274588119620184
- 1:-22.513179572933268
172: [-42.27460958324118, -22.51322250651747]
- 0:-42.27460958324118
- 1:-22.51322250651747
173: [-42.274759856672944, -22.51335130468111]
- 0:-42.274759856672944
- 1:-22.51335130468111
174: [-42.27476801791958, -22.513359466751375]
- 0:-42.27476801791958
- 1:-22.513359466751375
175: [-42.274781323699514, -22.513372771814254]
- 0:-42.274781323699514
- 1:-22.513372771814254
176: [-42.274738383409606, -22.513501566660718]
- 0:-42.274738383409606
- 1:-22.513501566660718
177: [-42.27473838371716, -22.513630368318474]
- 0:-42.27473838371716
- 1:-22.513630368318474
178: [-42.274867179899275, -22.513737699105203]
- 0:-42.274867179899275
- 1:-22.513737699105203
179: [-42.27493158135024, -22.513737705511794]
- 0:-42.27493158135024
- 1:-22.513737705511794
180: [-42.2751247797216, -22.51378062858033]
- 0:-42.2751247797216
- 1:-22.51378062858033
181: [-42.275060385111374, -22.513930896851722]
- 0:-42.275060385111374
- 1:-22.513930896851722
182: [-42.27506038597645, -22.513995292737828]
- 0:-42.27506038597645
- 1:-22.513995292737828
183: [-42.27506037925776, -22.514038231930602]
- 0:-42.27506037925776
- 1:-22.514038231930602
184: [-42.27491011799394, -22.51429582561586]
- 0:-42.27491011799394
- 1:-22.51429582561586
185: [-42.27507370965564, -22.514405669996638]
- 0:-42.27507370965564
- 1:-22.514405669996638
186: [-42.275275043584585, -22.51431729322403]
- 0:-42.275275043584585
- 1:-22.51431729322403
187: [-42.275210643251626, -22.514167030511306]
- 0:-42.275210643251626
- 1:-22.514167030511306
1: List (4 elements)
0: [-42.275511172239035, -22.513823562640546]
- 0:-42.275511172239035
- 1:-22.513823562640546
1: [-42.27561850275632, -22.5136303685588]
- 0:-42.27561850275632
- 1:-22.5136303685588
2: [-42.27570437568856, -22.513480103416555]
- 0:-42.27570437568856
- 1:-22.513480103416555
3: [-42.275511172239035, -22.513823562640546]
- 0:-42.275511172239035
- 1:-22.513823562640546
2: List (4 elements)
0: [-42.276885022286095, -22.511913064626548]
- 0:-42.276885022286095
- 1:-22.511913064626548
1: [-42.277056752651134, -22.511848667586033]
- 0:-42.277056752651134
- 1:-22.511848667586033
2: [-42.276713288755836, -22.51199892883776]
- 0:-42.276713288755836
- 1:-22.51199892883776
3: [-42.276885022286095, -22.511913064626548]
- 0:-42.276885022286095
- 1:-22.511913064626548
3: List (4 elements)
0: [-42.276970886536674, -22.509251235728623]
- 0:-42.276970886536674
- 1:-22.509251235728623
1: [-42.27688502296862, -22.509208307867446]
- 0:-42.27688502296862
- 1:-22.509208307867446
2: [-42.27697228974889, -22.50924001483783]
- 0:-42.27697228974889
- 1:-22.50924001483783
3: [-42.276970886536674, -22.509251235728623]
- 0:-42.276970886536674
- 1:-22.509251235728623
4: List (4 elements)
0: [-42.275259678303726, -22.51343725784634]
- 0:-42.275259678303726
- 1:-22.51343725784634
1: [-42.27519838810252, -22.513608878265188]
- 0:-42.27519838810252
- 1:-22.513608878265188
2: [-42.2751247797216, -22.51378062858033]
- 0:-42.2751247797216
- 1:-22.51378062858033
3: [-42.275259678303726, -22.51343725784634]
- 0:-42.275259678303726
- 1:-22.51343725784634
5: List (4 elements)
0: [-42.27527503988412, -22.513394243721432]
- 0:-42.27527503988412
- 1:-22.513394243721432
1: [-42.27536091311331, -22.513179572966447]
- 0:-42.27536091311331
- 1:-22.513179572966447
2: [-42.275259678303726, -22.51343725784634]
- 0:-42.275259678303726
- 1:-22.51343725784634
3: [-42.27527503988412, -22.513394243721432]
- 0:-42.27527503988412
- 1:-22.513394243721432
# Get buffered geometry for context
buffer_1km = site.buffer(1000)
print(f"Buffered geometry created")Buffered geometry created
Loading Sites from GeoDataFrame
For workflows where you need to filter or sort sites before analysis, it’s more efficient to: 1. Load the GeoJSON into a GeoDataFrame 2. Filter and sort using pandas/geopandas operations (fast, in-memory) 3. Convert only the sites you need to Site objects
This avoids creating Earth Engine features for sites you’ll filter out anyway.
# Load GeoJSON into GeoDataFrame for fast filtering
gdf = gpd.read_file('../data/restoration_sites_subset.geojson')
print(f"Loaded {len(gdf)} sites into GeoDataFrame")
print(f"CRS: {gdf.crs}")
gdf.head()Loaded 10 sites into GeoDataFrame
CRS: EPSG:5880
| category | source | has_project | project_name | executing_institution | managing_institution | financing_institution | main_method | combined_method | strategy | ... | project_total_area_ha | project_mean_site_area_ha | project_mean_dispersion_km | project_max_dispersion_km | centroid_lon | centroid_lat | perimeter_m | shape_complexity | rid | geometry | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | restauracao | Aliança pela Restauração na Amazônia | Sim | Programa de recuperacao de areas degradadas - ... | Onca Puma Mineracao | nao identificado | nao identificado | enriquecimento | controle das plantas competidoras | Regeneração Natural com Manejo | ... | 86.704527 | 28.901509 | 2.699984e+04 | 4.030311e+04 | 5.322801e+06 | 9.280290e+06 | 2713.351189 | 4.455536 | 3107 | POLYGON Z ((5322649.663 9279737.977 0, 5322649... |
| 1 | restauracao | Pacto pela Restauração da Mata Atlântica | Sim | Mata Atlantica, das encostas as areas alagadas... | SPVS | nao identificado | FUNBIO,MMA,KFW | enriquecimento | nao identificado | Regeneração Natural com Manejo | ... | 651.186341 | 10.853106 | 6.590103e+05 | 2.725318e+06 | 5.525798e+06 | 7.183378e+06 | 3136.600149 | 6.355574 | 3153 | POLYGON Z ((5525444.601 7183290.446 0, 5525444... |
| 2 | restauracao | Pacto pela Restauração da Mata Atlântica | Sim | nao identificado | nao identificado | SEMIL-SP | nao identificado | adensamento | nao identificado | Regeneração Natural com Manejo | ... | 228.300262 | 5.435721 | 2.400005e+07 | 4.269652e+07 | 5.791646e+06 | 7.431742e+06 | 6347.796596 | 9.286339 | 3226 | POLYGON Z ((5790809.752 7431272.341 0, 5790776... |
| 3 | restauracao | Pacto pela Restauração da Mata Atlântica | Sim | nao identificado | nao identificado | SEMIL-SP | nao identificado | adensamento | nao identificado | Regeneração Natural com Manejo | ... | 104.184078 | 14.883440 | 1.902321e+07 | 2.225268e+07 | 5.187825e+06 | 7.531541e+06 | 7300.762070 | 12.221759 | 4210 | POLYGON Z ((5187930.677 7531850.711 0, 5187971... |
| 4 | restauracao | Pacto pela Restauração da Mata Atlântica | Sim | nao identificado | nao identificado | SEMIL-SP | nao identificado | plantio de mudas | nao identificado | Plantio em Área Total | ... | 204.103345 | 2.685570 | 2.713580e+07 | 4.506196e+07 | 5.619900e+06 | 7.654089e+06 | 2602.480123 | 7.461996 | 5461 | POLYGON Z ((5620178.276 7654188.507 0, 5620178... |
5 rows × 36 columns
# Filter for sites larger than 20 hectares
filtered = gdf[gdf['area_ha'] > 20].copy()
print(f"Filtered to {len(filtered)} sites with area > 10 ha")
# Sort by area (largest first)
filtered = filtered.sort_values('area_ha', ascending=False)
# Convert filtered GeoDataFrame to Sites
sites = sites_from_geodataframe(filtered)
print(f"Created {len(sites)} Site objects")
# Check the first site
print(sites[0])Filtered to 5 sites with area > 10 ha
Created 5 Site objects
Site(id=3226, start_year=2021)
# You can also create a single Site from a specific row
row = gdf.iloc[0] # Get first row
single_site = Site.from_geodataframe_row(row, source_crs=str(gdf.crs))
print(f"Single site: {single_site}")Single site: Site(id=3107, start_year=2016)
Visualizing Sites
Now that we have a site loaded, we’d like to see it on a map. Let’s add a show() method using geemap’s interactive mapping.
Site.show
def show(
zoom:int=14, basemap:str='SATELLITE', color:str='blue', fill_color:str='#0000ff33'
)->geemap.Map:
Display the site on an interactive map.
Args: zoom: Initial zoom level (default 14) basemap: Basemap type - ‘SATELLITE’, ‘ROADMAP’, ‘TERRAIN’, ‘HYBRID’ color: Outline color (default ‘blue’) fill_color: Fill color with alpha (default semi-transparent blue)
Returns: A geemap.Map object centered on the site
# View the site on a satellite map
site.show()