Last active
April 12, 2021 16:59
-
-
Save M3nin0/0e9002a38ed9d88e994e97a50514d267 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import numpy | |
from wtss import WTSS | |
service = WTSS('https://brazildatacube.dpi.inpe.br/', access_token='seu-token') | |
cbers4_coverage = service['CB4_64_16D_STK-1'] | |
# | |
# bandas | |
# | |
red_band = 'BAND15' | |
nir_band = 'BAND16' | |
cmask = "CMASK" | |
# | |
# recuperando as séries (Incluindo red, nir, cmask) | |
# | |
time_series = cbers4_coverage.ts(attributes=(red_band, nir_band, cmask), | |
latitude=-16.817, longitude=-52.079, | |
start_date="2017-01-01", end_date="2019-12-31") | |
# | |
# transformando os valores | |
# | |
cmask_arr = numpy.array(time_series.CMASK) | |
# | |
# transformando as nuvens em NAN | |
# | |
# nuvem (valor 4) | |
cmask_arr[cmask_arr == 4] = numpy.nan | |
# sombra de nuvem (valor 2) | |
cmask_arr[cmask_arr == 2] = numpy.nan | |
# tudo o que não é nuvem vai para valor 1 | |
cmask_arr[~numpy.isnan(cmask_arr)] = 1 | |
# | |
# aplicando a mascara (Banda 15) | |
time_series.BAND15 * cmask_arr | |
# | |
# aplicando a mascara (Banda 16) | |
time_series.BAND16 * cmask_arr | |
## Neste exemplo, os valores com nuvem irão ficar com valor NAN. Isto permite interpolação e outras operações |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment