Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detections-vehicles dataset to backend #83

Merged
merged 7 commits into from
Jan 13, 2021
2 changes: 1 addition & 1 deletion covid_api/api/api_v1/endpoints/detections.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
router = APIRouter()

# TODO: unhardcoded types and dates
MLTypes = Enum("MLTypes", [(ml, ml) for ml in ["ship", "multiple", "plane"]]) # type: ignore
MLTypes = Enum("MLTypes", [(ml, ml) for ml in ["ship", "multiple", "plane", "vehicles"]]) # type: ignore


@router.get(
Expand Down
4 changes: 3 additions & 1 deletion covid_api/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,6 @@ def site_date_to_scenes(site: str, date: str):
json.loads(row["scene_id"].replace("'", '"'))
)

return site_date_to_scenes_dict[f"{site}-{date}"]
# deduplicate scene list (in case multiple datasets contains the same
# scene id)
return list(set(site_date_to_scenes_dict[f"{site}-{date}"]))
6 changes: 5 additions & 1 deletion covid_api/db/static/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def _prep_output(self, output_datasets: dict, api_url: str):
tile.replace("{api_url}", api_url)
for tile in dataset.compare.source.tiles
]
if dataset.id in ["detections-ship", "detections-plane"]:
if dataset.id in [
"detections-ship",
"detections-plane",
"detections-vehicles",
]:
dataset.source = GeoJsonSource(
type=dataset.source.type, data=dataset.source.tiles[0]
)
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/agriculture.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"enabled": false,
"swatch": {
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/co2-diff.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"enabled": false,
"swatch": {
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/co2.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"enabled": false,
"compare": {
Expand Down
5 changes: 3 additions & 2 deletions covid_api/db/static/datasets/detections-plane.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"source": {
"type": "geojson",
"tiles": [
"{api_url}/detections/plane/{spotlightId}/{date}.geojson"
"{api_url}/detections-plane/{spotlightId}/{date}.geojson"
]
},
"background_source": {
Expand All @@ -29,7 +29,8 @@
"detection-multi",
"water-chlorophyll",
"water-spm",
"detections-ship"
"detections-ship",
"detections-vehicles"
],
"enabled": false,
"swatch": {
Expand Down
5 changes: 3 additions & 2 deletions covid_api/db/static/datasets/detections-ship.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"source": {
"type": "geojson",
"tiles": [
"{api_url}/detections/ship/{spotlightId}/{date}.geojson"
"{api_url}/detections-ship/{spotlightId}/{date}.geojson"
]
},
"background_source": {
Expand All @@ -29,7 +29,8 @@
"detection-multi",
"water-chlorophyll",
"water-spm",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"enabled": false,
"swatch": {
Expand Down
41 changes: 41 additions & 0 deletions covid_api/db/static/datasets/detections-vehicles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "detections-vehicles",
"name": "Vehicle",
"type": "inference-timeseries",
"s3_location": "detections-vehicles",
"is_periodic": false,
"time_unit": "day",
"source": {
"type": "geojson",
"tiles": [
"{api_url}/detections-vehicles/{spotlightId}/{date}.geojson"
]
},
"background_source": {
"type": "raster",
"tiles": [
"{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/detections-vehicles/background/{spotlightId}/{date}.tif"
]
},
"exclusive_with": [
"agriculture",
"no2",
"co2-diff",
"co2",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
],
"enabled": false,
"swatch": {
"color": "#C0C0C0",
"name": "Grey"
},
"info": "Vehicles detected each day in PlanetScope imagery are shown in orange."
}
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/nightlights-hd.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"swatch": {
"color": "#C0C0C0",
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/nightlights-viirs.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"swatch": {
"color": "#C0C0C0",
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/no2.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"water-chlorophyll",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"enabled": true,
"compare": {
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/water-chlorophyll.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"detection-multi",
"water-spm",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"swatch": {
"color": "#154F8D",
Expand Down
3 changes: 2 additions & 1 deletion covid_api/db/static/datasets/water-spm.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"detection-multi",
"water-chlorophyll",
"detections-ship",
"detections-plane"
"detections-plane",
"detections-vehicles"
],
"swatch": {
"color": "#154F8D",
Expand Down