Closed ghelobytes closed 2 years ago
Places
are locations shown in this list https://mangrove-atlas-api.herokuapp.com/api/v2/locations
Summary of location_type
:
{
"worldwide": 1,
"wdpa": 158,
"country": 102,
"aoi": 2
}
api/dashboard/sites
locations
table, just pass the extent of each places to the endpoint: api/dashboard/sites?extent=xmin,ymin,xmax,ymax
# sample locations data
{
"id": 993,
"iso": "AUS",
"bounds": {
"coordinates": [
[
[109.23347930458496, -58.44943438453255],
[164.69123430943776, -58.44943438453255],
[164.69123430943776, -8.881882731189767],
[109.23347930458496, -8.881882731189767],
[109.23347930458496, -58.44943438453255]
]
],
"geodesic": false,
"type": "Polygon"
}
}
from shapely.geometry import Polygon polygon = Polygon([(0, 0), (1, 1), (1, 0)]) polygon.bounds (0.0, 0.0, 1.0, 1.0)
### OR
- Accept a `location_id` parameter, query database and grab the `bounds` field: `api/dashboard/sites?location_id=999`
PR: https://github.com/globalmangrovewatch/gmw-api/pull/101 Usage:
api/v2/dashboard/sites?extent=minx,miny,maxx,maxy
api/v2/dashboard/sites?extent=-16.1868953704834,12.640254556428197,-16.183032989501953,12.64259955777063
Generate extent for testing:
>>> from shapely.geometry import shape
>>> poly = {
... "type": "Polygon",
... "coordinates": [
... [
... [
... -16.1868953704834,
... 12.640254556428197
... ],
... [
... -16.183032989501953,
... 12.640254556428197
... ],
... [
... -16.183032989501953,
... 12.64259955777063
... ],
... [
... -16.1868953704834,
... 12.64259955777063
... ],
... [
... -16.1868953704834,
... 12.640254556428197
... ]
... ]
... ]
... }
>>>
>>>
>>> poly
{'type': 'Polygon', 'coordinates': [[[-16.1868953704834, 12.640254556428197], [-16.183032989501953, 12.640254556428197], [-16.183032989501953, 12.64259955777063], [-16.1868953704834, 12.64259955777063], [-16.1868953704834, 12.640254556428197]]]}
>>> poly = shape(poly)
>>> poly
<shapely.geometry.polygon.Polygon object at 0x7fc82737e828>
>>> poly.bounds
(-16.1868953704834, 12.640254556428197, -16.183032989501953, 12.64259955777063)
Implemented. Closing.
Related ticket: https://github.com/globalmangrovewatch/gmw-users/issues/241
Tasks
area
sites.area
is extracted from question1.3
sites.area
every timeregistration_answers
is updated and update includes changes in Question1.3
(overall site area)/api/dashboard/sites?extent=xmin,ymin,xmax,ymax
extent
andsites.area
and return the resulting sites