import ee 
from ee_plugin import Map 

# Example of FeatureCollection.reduceToImage()

# Define a feature collection with a value we want to average.
fc = ee.FeatureCollection([
  ee.Feature(
    ee.Geometry.Rectangle(
      -122.4550, 37.8035,
      -122.4781, 37.7935),
    {'value': 0}),
  ee.Feature(
    ee.Geometry.Polygon([
      [-122.4427, 37.8027],
      [-122.4587, 37.7987],
      [-122.4440, 37.7934]]),
    {'value': 1})
  ])

# Reduce the collection to an image, where each pixel
# is the mean of the 'value' property in all features
# intersecting that pixel.
image_reduced = fc.reduceToImage(['value'], 'mean')

Map.setCenter(-122.4561, 37.7983, 14)
Map.addLayer(image_reduced, {
  'min': 0,
  'max': 1,
  'palette': ['008800', '00FF00']}, "Image")
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/FeatureCollection/select_by_location.py

import ee
from ee_plugin import Map

HUC10 = ee.FeatureCollection("USGS/WBD/2017/HUC10")
HUC08 = ee.FeatureCollection('USGS/WBD/2017/HUC08')
roi = HUC08.filter(ee.Filter.eq('name', 'Pipestem'))

Map.centerObject(roi, 10)
Map.addLayer(ee.Image().paint(roi, 0, 3), {}, 'HUC08')

# select polygons intersecting the roi
roi2 = HUC10.filter(
    ee.Filter.contains(**{
        'leftValue': roi.geometry(),
        'rightField': '.geo'
    }))
Map.addLayer(ee.Image().paint(roi2, 0, 2), {'palette': 'blue'}, 'HUC10')

# roi3 = HUC10.filter(ee.Filter.stringContains(**{'leftField': 'huc10', 'rightValue': '10160002'}))
# # print(roi3)
# Map.addLayer(roi3)
示例#3
0
from ee_plugin import Map

# Feature buffer example.
# Display the area within 2 kilometers of San Francisco BART stations.

# Instantiate a FeatureCollection of BART locations in Downtown San Francisco
# (points).
stations = [
    ee.Feature(ee.Geometry.Point(-122.42, 37.77),
               {'name': '16th St. Mission (16TH)'}),
    ee.Feature(ee.Geometry.Point(-122.42, 37.75),
               {'name': '24th St. Mission (24TH)'}),
    ee.Feature(ee.Geometry.Point(-122.41, 37.78),
               {'name': 'Civic Center/UN Plaza (CIVC)'})
]
bartStations = ee.FeatureCollection(stations)

# Map a function over the collection to buffer each feature.


def func_dky(f):
    return f.buffer(2000, 100)
    # Note that the errorMargin is set to 100.


buffered = bartStations.map(func_dky)

Map.addLayer(buffered, {'color': '800080'})

Map.setCenter(-122.4, 37.7, 11)
import ee
from ee_plugin import Map

# Collection.distance example.
# Computes the distance to the nearest feature in a collection.

# Construct a FeatureCollection from a list of geometries.
fc = ee.FeatureCollection([
    ee.Geometry.Point(-72.94411, 41.32902),
    ee.Geometry.Point(-72.94411, 41.33402),
    ee.Geometry.Point(-72.94411, 41.33902),
    # The geometries do not need to be the same type.
    ee.Geometry.LineString(-72.93411, 41.30902, -72.93411, 41.31902, -72.94411,
                           41.31902)
])

# Compute distance from the dfeatures, to a max of 1000 meters.
distance = fc.distance(1000, 100)

Map.setCenter(-72.94, 41.32, 13)
Map.addLayer(distance, {
    'min': 0,
    'max': 1000,
    'palette': ['yellow', 'red']
}, 'distance')
Map.addLayer(fc, {}, 'Features')
# Filter to only include images intersecting Colorado or Utah.
polygon = ee.Geometry.Polygon({
    'coords': [[
        [-109.05, 37.0],
        [-102.05, 37.0],
        [-102.05, 41.0],  # Colorado
        [-109.05, 41.0],
        [-111.05, 41.0],
        [-111.05, 42.0],  # Utah
        [-114.05, 42.0],
        [-114.05, 37.0],
        [-109.05, 37.0]
    ]],
    'geodesic':
    False
})

# Create a Landsat 7 composite for Spring of 2000, and filter by
# the bounds of the FeatureCollection.
collection = ee.ImageCollection('LANDSAT/LE07/C01/T1') \
    .filterDate('2000-04-01', '2000-07-01') \
    .filterBounds(polygon)

# Compute the median in each band, in each pixel.
median = collection.median()

# Select the red, green and blue bands.
result = median.select('B3', 'B2', 'B1')
Map.addLayer(result, {'gain': [1.4, 1.4, 1.1]})
Map.setCenter(-110, 40, 5)
import ee
from ee_plugin import Map

# Load and filter the Sentinel-2 image collection.
collection = ee.ImageCollection('COPERNICUS/S2') \
    .filterDate('2016-01-01', '2016-12-31') \
    .filterBounds(ee.Geometry.Point([-81.31, 29.90]))

# Reduce the collection.
extrema = collection.reduce(ee.Reducer.minMax())
# print(extrema.getInfo())
min_image = extrema.select(0)
max_image = extrema.select(1)

Map.setCenter(-81.31, 29.90, 10)
Map.addLayer(min_image, {}, 'Min image')
Map.addLayer(max_image, {}, 'Max image')
示例#7
0
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/us_census_roads.py

import ee
from ee_plugin import Map

fc = ee.FeatureCollection('TIGER/2016/Roads')
Map.setCenter(-73.9596, 40.7688, 12)
Map.addLayer(fc, {}, 'Census roads')
import ee
from ee_plugin import Map

# Load a cloudy Landsat 8 image.
image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20130603')
Map.addLayer(image, {
    'bands': ['B5', 'B4', 'B3'],
    'min': 0,
    'max': 0.5
}, 'original image')

# Load another image to replace the cloudy pixels.
replacement = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20130416')

# Compute a cloud score band.
cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud')

# Set cloudy pixels to the other image.
replaced = image.where(cloud.gt(10), replacement)

# Display the result.
Map.centerObject(image, 9)
Map.addLayer(replaced, {
    'bands': ['B5', 'B4', 'B3'],
    'min': 0,
    'max': 0.5
}, 'clouds replaced')
示例#9
0
import ee
from ee_plugin import Map

# Load a Landsat 8 image.
image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318')

# Compute the EVI using an expression.
evi = image.expression(
    '2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', {
        'NIR': image.select('B5'),
        'RED': image.select('B4'),
        'BLUE': image.select('B2')
    })

Map.centerObject(image, 9)
Map.addLayer(evi, {
    'min': -1,
    'max': 1,
    'palette': ['FF0000', '00FF00']
}, "EVI")
import ee
from ee_plugin import Map

fromFT = ee.FeatureCollection('ft:1CLldB-ULPyULBT2mxoRNv7enckVF0gCQoD2oH7XP')
polys = fromFT.geometry()
centroid = polys.centroid()
lng, lat = centroid.getInfo()['coordinates']
print("lng = {}, lat = {}".format(lng, lat))
Map.setCenter(lng, lat, 10)
Map.addLayer(fromFT)

taskParams = {
    'driveFolder': 'image',
    'fileFormat': 'KML'  # CSV, KMZ, GeoJSON
}

# export all features in a FeatureCollection as one file
task = ee.batch.Export.table(fromFT, 'export_fc', taskParams)
task.start()

# # export each feature in a FeatureCollection as an individual file
# count = fromFT.size().getInfo()
# for i in range(2, 2 + count):
#     fc = fromFT.filter(ee.Filter.eq('system:index', str(i)))
#     task = ee.batch.Export.table(fc, 'watershed-' + str(i), taskParams)
#     task.start()
示例#11
0
import ee
from ee_plugin import Map

# Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.
ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')

# Display as default and with a custom color.
Map.addLayer(ecoregions, {}, 'default display', False)
Map.addLayer(ecoregions, {'color': 'FF0000'}, 'colored', False)

Map.addLayer(ecoregions.draw(**{
    'color': '006600',
    'strokeWidth': 5
}), {}, 'drawn', False)

# Create an empty image into which to paint the features, cast to byte.
empty = ee.Image().byte()

# Paint all the polygon edges with the same number and 'width', display.
outline = empty.paint(**{
    'featureCollection': ecoregions,
    'color': 1,
    'width': 3
})
Map.addLayer(outline, {'palette': 'FF0000'}, 'edges')
示例#12
0
import ee
from ee_plugin import Map
dataset = ee.Image('JRC/GSW1_1/GlobalSurfaceWater')
occurrence = dataset.select('occurrence')
occurrenceVis = {
    'min': 0.0,
    'max': 100.0,
    'palette': ['ffffff', 'ffbbbb', '0000ff']
}
Map.setCenter(59.414, 45.182, 6)
Map.addLayer(occurrence, occurrenceVis, 'Occurrence')
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/FeatureCollection/clipping.py

import ee 
from ee_plugin import Map 

roi = ee.Geometry.Polygon(
        [[[-73.99891354682285, 40.74560250077625],
          [-73.99891354682285, 40.74053023068626],
          [-73.98749806525547, 40.74053023068626],
          [-73.98749806525547, 40.74560250077625]]])


fc = ee.FeatureCollection('TIGER/2016/Roads').filterBounds(roi)

clipped = fc.map(lambda f: f.intersection(roi))

Map.centerObject(ee.FeatureCollection(roi), 17)
Map.addLayer(ee.Image().paint(roi, 0, 2), {'palette': 'yellow'}, 'ROI')
# Map.setCenter(-73.9596, 40.7688, 12)
Map.addLayer(ee.Image().paint(clipped, 0, 3), {'palette': 'red'}, 'clipped')
Map.addLayer(fc, {}, 'Census roads', False)




# Load a Landsat 8 image and display the thermal band.
image = ee.Image('LANDSAT/LC8_L1T_TOA/LC80440342014077LGN00').clip(geometry)
Map.setCenter(-121.51385307312012, 37.61767615130697, 14)  # SF Bay
#Map.addLayer(image, {'bands': ['B10'], 'min': 270, 'max': 310}, 'LST')
#print(image)

# Threshold the thermal band to find "hot" objects.
hotspots = image.select('B10').gt(303)

# Mask "cold" pixels.
hotspots = hotspots.mask(hotspots)
#Map.addLayer(hotspots, {'palette': 'FF0000'}, 'hotspots')

# Compute the number of pixels in each patch.
patchsize = hotspots.connectedPixelCount(100, False)
Map.addLayer(patchsize, {}, 'patch size')
largePatches = patchsize.gt(4)
largePatches = largePatches.updateMask(largePatches)
Map.addLayer(largePatches, {}, 'patch size>4')

pixelAreaAllPatches = hotspots.multiply(ee.Image.pixelArea())
pixelAreaLargePatch = largePatches.multiply(ee.Image.pixelArea())
areaAllPathces = pixelAreaAllPatches.reduceRegion(**{
    'reducer': ee.Reducer.sum(),
    'geometry': geometry
})
areaLargePatch = pixelAreaLargePatch.reduceRegion(**{
    'reducer': ee.Reducer.sum(),
    'geometry': geometry
})
示例#15
0
#     sliceVisibilityThreshold: 0  # Don't group small slices.
#   })
# print(transition_summary_chart)

###############################
# Initialize Map Location
###############################

# Uncomment one of the following statements to center the map on
# a particular location.
# Map.setCenter(-90.162, 29.8597, 10)   # New Orleans, USA
# Map.setCenter(-114.9774, 31.9254, 10) # Mouth of the Colorado River, Mexico
# Map.setCenter(-111.1871, 37.0963, 11) # Lake Powell, USA
# Map.setCenter(149.412, -35.0789, 11)  # Lake George, Australia
Map.setCenter(105.26, 11.2134, 9)  # Mekong River Basin, SouthEast Asia
# Map.setCenter(90.6743, 22.7382, 10)   # Meghna River, Bangladesh
# Map.setCenter(81.2714, 16.5079, 11)   # Godavari River Basin Irrigation Project, India
# Map.setCenter(14.7035, 52.0985, 12)   # River Oder, Germany & Poland
# Map.setCenter(-59.1696, -33.8111, 9)  # Buenos Aires, Argentina
# Map.setCenter(-74.4557, -8.4289, 11)  # Ucayali River, Peru

###############################
# Map Layers
###############################

Map.addLayer(water_mask, VIS_WATER_MASK, '90% occurrence water mask', False)
Map.addLayer(occurrence.updateMask(occurrence.divide(100)), VIS_OCCURRENCE,
             "Water Occurrence (1984-2015)", False)
Map.addLayer(change, VIS_CHANGE, 'occurrence change intensity', False)
Map.addLayer(transition, {}, 'Transition classes (1984-2018)')
示例#16
0
import ee
from ee_plugin import Map

# Load a pre-computed Landsat composite for input.
input = ee.Image('LANDSAT/LE7_TOA_1YEAR/2001')

# Define a region in which to generate a sample of the input.
region = ee.Geometry.Rectangle(29.7, 30, 32.5, 31.7)

# Display the sample region.
Map.setCenter(31.5, 31.0, 8)
Map.addLayer(ee.Image().paint(region, 0, 2), {}, 'region')

# Make the training dataset.
training = input.sample(**{'region': region, 'scale': 30, 'numPixels': 5000})

# Instantiate the clusterer and train it.
clusterer = ee.Clusterer.wekaKMeans(15).train(training)

# Cluster the input using the trained clusterer.
result = input.cluster(clusterer)

# Display the clusters with random colors.
Map.addLayer(result.randomVisualizer(), {}, 'clusters')
# %%
'''
## Add Earth Engine Python script 

'''

# %%
import ee
from ee_plugin import Map

states = ee.FeatureCollection('TIGER/2018/States')
# print(states.first().getInfo())

# Select states with land area between 200,000 km2 and 300,000 km2
selected = states.filter(
    ee.Filter.rangeContains("ALAND", 200000000000, 300000000000))
Map.centerObject(selected, 6)
Map.addLayer(ee.Image().paint(selected, 0, 2), {'palette': 'yellow'},
             'Selected')

# %%
'''
## Display Earth Engine data layers 

'''

# %%
Map.setControlVisibility(layerControl=True,
                         fullscreenControl=True,
                         latLngPopup=True)
Map
import ee
from ee_plugin import Map

collection = ee.ImageCollection('USDA/NAIP/DOQQ')

fromFT = ee.FeatureCollection('ft:1CLldB-ULPyULBT2mxoRNv7enckVF0gCQoD2oH7XP')
polys = fromFT.geometry()
centroid = polys.centroid()
lng, lat = centroid.getInfo()['coordinates']
print("lng = {}, lat = {}".format(lng, lat))

# lat = 46.80514
# lng = -99.22023
lng_lat = ee.Geometry.Point(lng, lat)
# naip = collection.filterBounds(lng_lat)
naip = collection.filterBounds(polys)
naip_2015 = naip.filterDate('2015-01-01', '2015-12-31')
ppr = naip_2015.mosaic().clip(polys)

# print(naip_2015.size().getInfo())
vis = {'bands': ['N', 'R', 'G']}
Map.setCenter(lng, lat, 10)
# Map.addLayer(naip_2015,vis)
Map.addLayer(ppr, vis)
# Map.addLayer(fromFT)

# image = ee.Image('USDA/NAIP/DOQQ/m_4609915_sw_14_1_20100629')
# Map.setCenter(lng, lat, 12)
# Map.addLayer(image,vis)
###############################

# Create a water mask layer, and set the image mask so that non-water areas
# are opaque.
water_mask = occurrence.gt(90).selfMask()

###############################
# Initialize Map Location
###############################

# Uncomment one of the following statements to center the map.
# Map.setCenter(-90.162, 29.8597, 10)   # New Orleans, USA
# Map.setCenter(-114.9774, 31.9254, 10) # Mouth of the Colorado River, Mexico
# Map.setCenter(-111.1871, 37.0963, 11) # Lake Powell, USA
# Map.setCenter(149.412, -35.0789, 11)  # Lake George, Australia
# Map.setCenter(105.26, 11.2134, 9)     # Mekong River Basin, SouthEast Asia
# Map.setCenter(90.6743, 22.7382, 10)   # Meghna River, Bangladesh
# Map.setCenter(81.2714, 16.5079, 11)   # Godavari River Basin Irrigation Project, India
# Map.setCenter(14.7035, 52.0985, 12)   # River Oder, Germany & Poland
# Map.setCenter(-59.1696, -33.8111, 9)  # Buenos Aires, Argentina
Map.setCenter(-74.4557, -8.4289, 11)  # Ucayali River, Peru

###############################
# Map Layers
###############################

Map.addLayer(occurrence.updateMask(occurrence.divide(100)), VIS_OCCURRENCE, "Water Occurrence (1984-2018)")
Map.addLayer(water_mask, VIS_WATER_MASK, '90% occurrence water mask', False)


# get standard deviation
def stdValue(img, scale=30):
    std_value = img.reduceRegion(**{
        'reducer': ee.Reducer.stdDev(),
        'geometry': img.geometry(),
        'scale': scale,
        'maxPixels': 1e9
    })
    return std_value


dataset = ee.Image('USGS/NED')
dem = dataset.select('elevation')
# dem = ee.Image('srtm90_v4')
vis_params = {'min': 0, 'max': 3000}
Map.addLayer(dem, vis_params, 'NED', False)

roi = ee.Geometry.Polygon(
    [[[-120.18204899532924, 38.53481618819663],
      [-120.18204899532924, 36.54889033300136],
      [-116.75431462032924, 36.54889033300136],
      [-116.75431462032924, 38.53481618819663]]])

image = dem.clip(roi)
Map.centerObject(image, 9)
Map.addLayer(image, vis_params, 'DEM')

scale = image.projection().nominalScale()
print("Resolution: ", scale.getInfo())

scale = 30
        # Get the sample from the polygons FeatureCollection.
        'collection': polygons,
        # Keep this list of properties from the polygons.
        'properties': ['class'],
        # Set the scale to get Landsat pixels in the polygons.
        'scale': 30
    })

# Create an SVM classifier with custom parameters.
classifier = ee.Classifier.svm(**{
    'kernelType': 'RBF',
    'gamma': 0.5,
    'cost': 10
})

# Train the classifier.
trained = classifier.train(training, 'class', bands)

# Classify the image.
classified = image.classify(trained)

# Display the classification result and the input image.
Map.setCenter(-62.836, -9.2399, 9)
Map.addLayer(image, {'bands': ['B4', 'B3', 'B2'], 'max': 0.5, 'gamma': 2})
Map.addLayer(polygons, {}, 'training polygons')
Map.addLayer(classified, {
    'min': 0,
    'max': 1,
    'palette': ['red', 'green']
}, 'deforestation')
示例#22
0
import ee
from ee_plugin import Map

point = ee.Geometry.Point([1.5, 1.5])
Map.addLayer(point, {'color': '1eff05'}, 'point')

lineString = ee.Geometry.LineString([[-35, -10], [35, -10], [35, 10],
                                     [-35, 10]])
Map.addLayer(lineString, {'color': 'FF0000'}, 'lineString')

linearRing = ee.Geometry.LinearRing([[-35, -10], [35, -10], [35, 10],
                                     [-35, 10], [-35, -10]])
Map.addLayer(linearRing, {'color': 'ee38ff'}, 'linearRing')

rectangle = ee.Geometry.Rectangle([-40, -20, 40, 20])
Map.addLayer(rectangle, {'color': 'ffa05c'}, 'rectangle')

polygon = ee.Geometry.Polygon([[[-5, 40], [65, 40], [65, 60], [-5, 60],
                                [-5, 60]]])

planarPolygon = ee.Geometry(polygon, None, False)

Map.addLayer(polygon, {'color': 'FF0000'}, 'geodesic polygon')
Map.addLayer(planarPolygon, {'color': '000000'}, 'planar polygon')

Map.centerObject(polygon)
# An example finding linear features using the HoughTransform.

# Load an image and compute NDVI.
image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_033032_20170719')
ndvi = image.normalizedDifference(['B5', 'B4'])

# Apply a Canny edge detector.
canny = ee.Algorithms.CannyEdgeDetector({
    'image': ndvi,
    'threshold': 0.4
}).multiply(255)

# Apply the Hough transform.
h = ee.Algorithms.HoughTransform({
    'image': canny,
    'gridSize': 256,
    'inputThreshold': 50,
    'lineThreshold': 100
})

# Display.
Map.setCenter(-103.80140, 40.21729, 13)
Map.addLayer(image, {'bands': ['B4', 'B3', 'B2'], 'max': 0.3}, 'source_image')
Map.addLayer(canny.updateMask(canny), {
    'min': 0,
    'max': 1,
    'palette': 'blue'
}, 'canny')
Map.addLayer(h.updateMask(h), {'min': 0, 'max': 1, 'palette': 'red'}, 'hough')
示例#24
0
import ee 
from ee_plugin import Map 

# dataset = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017')
# styleParams = {
#   'fillColor': 'b5ffb4',
#   'color': '00909F',
#   'width': 3.0,
# }
# countries = dataset.style(**styleParams)
# Map.addLayer(countries, {}, 'USDOS/LSIB_SIMPLE/2017')


dataset = ee.FeatureCollection('USDOS/LSIB/2013')
visParams = {
  'palette': ['f5ff64', 'b5ffb4', 'beeaff', 'ffc0e8', '8e8dff', 'adadad'],
  'min': 0.0,
  'max': 894.0,
  'opacity': 0.8,
}
image = ee.Image().float().paint(dataset, 'iso_num')
Map.addLayer(image, visParams, 'USDOS/LSIB/2013')
# Map.addLayer(dataset, {}, 'for Inspector', False)
示例#25
0
import ee 
from ee_plugin import Map 

# Image.ConnectedPixelCount example.

# Split pixels of band 01 into "bright" (arbitrarily defined as
# reflectance > 0.3) and "dim". Highlight small (<30 pixels)
# standalone islands of "bright" or "dim" type.
img = ee.Image('MODIS/006/MOD09GA/2012_03_09') \
              .select('sur_refl_b01') \
              .multiply(0.0001)

# Create a threshold image.
bright = img.gt(0.3)

# Compute connected pixel counts; stop searching for connected pixels
# once the size of the connected neightborhood reaches 30 pixels, and
# use 8-connected rules.
conn = bright.connectedPixelCount({
  'maxSize': 30,
  'eightConnected': True
})

# Make a binary image of small clusters.
smallClusters = conn.lt(30)

Map.setCenter(-107.24304, 35.78663, 8)
Map.addLayer(img, {'min': 0, 'max': 1}, 'original')
Map.addLayer(smallClusters.updateMask(smallClusters),
         {'min': 0, 'max': 1, 'palette': 'FF0000'}, 'cc')
示例#26
0
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Visualization/ndvi_symbology.py

import ee
from ee_plugin import Map

# This function gets NDVI from Landsat 5 imagery.


def getNDVI(image):
    return image.normalizedDifference(['B4', 'B3'])


image1 = ee.Image('LANDSAT/LT05/C01/T1_TOA/LT05_044034_19900604')

# Compute NDVI from the scene.
ndvi1 = getNDVI(image1)

ndviParams = {
    'palette': [
        '#d73027', '#f46d43', '#fdae61', '#fee08b', '#d9ef8b', '#a6d96a',
        '#66bd63', '#1a9850'
    ]
}

Map.centerObject(image1, 10)
Map.addLayer(ndvi1, ndviParams, 'NDVI')
示例#27
0
import ee 
from ee_plugin import Map 

geometry = ee.Geometry.Point([5.7788, 52.7005])

# Get the VV collection.
collectionVV = ee.ImageCollection('COPERNICUS/S1_GRD') \
    .filter(ee.Filter.eq('instrumentMode', 'IW')) \
    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV')) \
    .filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING')) \
    .select(['VV'])

# Create a 3 band stack by selecting from different periods (months)
im1 = ee.Image(collectionVV.filterDate('2016-04-01', '2016-05-30').mean())
im2 = ee.Image(collectionVV.filterDate('2016-06-01', '2016-08-31').mean())
im3 = ee.Image(collectionVV.filterDate('2016-09-01', '2016-11-30').mean())

Map.centerObject(geometry, 13)
Map.addLayer(im1.addBands(im2).addBands(im3), {'min': -25, 'max': 0}, 'VV stack')

# Get the VH collection.
collectionVH = ee.ImageCollection('COPERNICUS/S1_GRD') \
    .filter(ee.Filter.eq('instrumentMode', 'IW')) \
    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH')) \
    .select(['VH'])
# Collection max.  Zoom to Shanghai for an interesting visualization.
Map.addLayer(collectionVH.max(), {'min': -25, 'max': 0}, 'max value', False)

from ee_plugin import Map
import ee

image = ee.ImageCollection('COPERNICUS/S2') \
  .filterDate('2018-01-01', '2018-01-02').median() \
  .divide(10000).visualize(**{'bands': ['B12', 'B8', 'B4'], 'min': 0.05, 'max': 0.5})

Map.addLayer(image, {}, 'Sentinel-2 images January, 2018')
示例#29
0
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/us_cropland.py

# Metadata: https://developers.google.com/earth-engine/datasets/catalog/USDA_NASS_CDL

import ee
from ee_plugin import Map

dataset = ee.ImageCollection('USDA/NASS/CDL') \
                  .filter(ee.Filter.date('2017-01-01', '2018-12-31')) \
                  .first()
cropLandcover = dataset.select('cropland')
Map.setCenter(-100.55, 40.71, 4)
Map.addLayer(cropLandcover, {}, 'Crop Landcover')
示例#30
0
import ee
from ee_plugin import Map

# This example demonstrates the use of the Landsat 8 QA band to mask clouds.


# Function to mask clouds using the quality band of Landsat 8.
# maskL8 = function(image) {
def maskL8(image):
    qa = image.select('BQA')
    #/ Check that the cloud bit is off.
    # See https:#www.usgs.gov/land-resources/nli/landsat/landsat-collection-1-level-1-quality-assessment-band
    mask = qa.bitwiseAnd(1 << 4).eq(0)
    return image.updateMask(mask)


# }

# Map the function over one year of Landsat 8 TOA data and take the median.
composite = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA') \
    .filterDate('2016-01-01', '2016-12-31') \
    .map(maskL8) \
    .median()

# Display the results in a cloudy place.
Map.setCenter(114.1689, 22.2986, 12)
Map.addLayer(composite, {'bands': ['B4', 'B3', 'B2'], 'max': 0.3}, "Image")