Untitled

dasdas
mail@pastecode.io avatar
unknown
r
2 years ago
1.4 kB
2
Indexable
Never
# -*- coding: utf-8 -*-
"""Untitled53.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1iy5fPZvYshNjklclQOfFSqIrbt35Ohwp
"""

try:
  import ee_jupyter
  print('ee_jupyter was already installed.')
except ModuleNotFoundError:
  print('ee_jupyter was not found. Installing now...')
  import os
  result = os.system('pip -q install earthengine-jupyter')

import ee
ee.Authenticate()

ee.Initialize()

#ee.Image()
#ee.Geometry()
#ee.Feature()
#ee.FeatureCollection()
import ee
from ee_jupyter.core import authenticate_if_needed
from ee_jupyter.ipyleaflet import Map

map1 = Map(center=[17.7009, 83.277], zoom=8)

# Crea
def maskS2clouds(image):
  qa = image.select('QA60')

  # Bits 10 and 11 are clouds and cirrus, respectively.
  cloudBitMask = 1 << 10
  cirrusBitMask = 1 << 11

  # Both flags should be set to zero, indicating clear conditions.
  mask = qa.bitwiseAnd(cloudBitMask).eq(0).And(qa.bitwiseAnd(cirrusBitMask).eq(0))

  return image.updateMask(mask).divide(10000)

dataset = ee.ImageCollection('COPERNICUS/S2_SR')\
            .filterDate('2020-01-01', '2020-01-30')\
            .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))\
            .map(maskS2clouds)

visualization = {
  "min": 0.0,
  "max": 0.3,
  "bands": ['B4', 'B3', 'B2'],
};
map1.addLayer(dataset.mean(), visualization, 'RGB')

map1