-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from openearthplatforminitiative/feat/text-abo…
…ut-deforestation-api feat: add deforestation description and examples
- Loading branch information
Showing
3 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
async function getProfile(accessToken) { | ||
let accessToken = localStorage.getItem('access_token'); | ||
const response = await fetch( | ||
'https://api-test.openepi.io/deforestation/basin?' + | ||
new URLSearchParams({ | ||
lon: '30.0619', | ||
lat: '-1.9441', | ||
start_year: '2010', | ||
end_year: '2019', | ||
}) | ||
); | ||
const data = await response.json(); | ||
|
||
const response = await fetch('https://developer.openepi.io/v1/me', { | ||
headers: { | ||
Authorization: 'Bearer ' + accessToken, | ||
}, | ||
}); | ||
// Get the total forest cover loss within the returned river basin over the time period | ||
const loss = json.features[0].properties.daterange_tot_treeloss; | ||
|
||
const data = await response.json(); | ||
} | ||
console.log(`Total forest cover loss: ${loss} km^2`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from httpx import Client | ||
|
||
with Client() as client: | ||
response = client.get( | ||
url="https://api-test.openepi.io/deforestation/basin", | ||
params={"lon": 30.0619, "lat": -1.9441, "start_year": 2010, "end_year": 2019}, | ||
) | ||
|
||
# Get the total forest cover loss within the returned river basin over the time period | ||
json = response.json() | ||
loss = json["features"][0]["properties"]["daterange_tot_treeloss"] | ||
|
||
print(f"Total forest cover loss: {loss} km^2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters