DigitalGlobe / gbdxtools

(Deprecated) Python SDK for using GBDX
MIT License
74 stars 57 forks source link

CatalogImage.ndvi() isn't working for WV4 #762

Closed chizou closed 4 years ago

chizou commented 5 years ago

GBDXTools New Issue

CatalogImage.ndvi() isn't working for WV4 imagery over WinterPark, CO

GBDX Account Tier

GBDXTools Version

Name: gbdxtools
Version: 0.16.7
Summary: API wrapper and imagery access for the GBDX Platform
Home-page: https://github.com/DigitalGlobe/gbdxtools
Author: DigitalGlobe
Author-email: UNKNOWN
License: MIT
Location: /anaconda/envs/gbdx_py3/lib/python3.6/site-packages
Requires: bumpversion, dask, boto3, configparser, requests, shapely, cloudpickle, pytest-runner, pyproj, toolz, affine, mock, gbdx-auth, six, future, pycurl, scikit-image, vcrpy, cachetools, requests-futures, numpy, mercantile, ephem, pytest
Required-by: 

Environment

Description

The code in the Example is producing a TypeError exception from dask. However, uncommenting the WV3 catalog works.

Expected behavior:

ndvi values to be generated

Actual behavior:

TypeError exception is thrown

Example

from gbdxtools.task import env
from gbdxtools import CatalogImage
import dask
!pip install --upgrade gbdxtools > /dev/null
%matplotlib inline

# WV4
catalog_id = env.inputs.get('catalog_id', '7a36ef24-e4a5-446d-8582-64ceca52f0a1-inv')
bbox = (-105.86151123046876, 39.83174093314556, -105.7643508911133, 39.92369224734411)

# WV3
#catalog_id = env.inputs.get('catalog_id', '1030010082740C00')
#bbox = (-105.324, 40.03820344665364, -105.30435238033535, 40.056)

image = CatalogImage(catalog_id, band_type="MS", bbox=bbox)
ndvi = image.ndvi()
chizou commented 5 years ago

Sorry if this is a stupid question as I'm just starting out learning about remote sensing, but Shouldn't _ndvi_bands for WV04 return bands 2 (red) and 3 (NIR) ? It looks like it's returning 1 (green) and 3 (NIR). https://github.com/DigitalGlobe/gbdxtools/blob/a9005d70f309c28e4bea7545aeb6f8786f14a117/gbdxtools/images/worldview.py#L151

drwelby commented 5 years ago

Good catch on the ndvi_bands. We'll investigate why Dask is throwing the TypeError with the WV04 imagery.

drwelby commented 5 years ago

_ndvi_bands is missing its @property decorator in the WV04 image class.

You can manually set it (and to the correct values) with:

image._ndvi_bands = [2,3]

drwelby commented 5 years ago

Addressed in https://github.com/DigitalGlobe/gbdxtools/pull/763, to be included in 0.17.0