Iām trying to work out how to extract the data along a transect in Google Earth Engine - ideally at defined intervals. Using the Python
API
in a Jupyter notebook
I've mapped some data, buffered a point (to define the region of interest), and mapped a transect. I don't know whether I should use an ee method to extract data constrained along the lineString
(which I assume isn't a shape?), or whether I'm heading in the wrong direction and should be exporting the buffered area as a GeoTIFF to process the transect in QGIS/ArcGIS
.
import ee
ee.Initialize()
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)
centre = ee.Geometry.Point(-115.435272, 35.584001,)
centreBuffer = centre.buffer(5000)
dataset = ee.ImageCollection('COPERNICUS/S2_SR') \
.filterDate('2020-07-01', '2020-07-31') \
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20)) \
.map(maskS2clouds)
visualization = {
'min': 0.0,
'max': 0.3,
'bands': ['B4', 'B3', 'B2'], # Red, Green, BLue. 10m resolution.
}
Map.setCenter(-115.435272, 35.584001, 12)
# Map = geemap.Map(center=[35.584001, -115.435272], zoom=14)
Map.addLayer(dataset.mean(), visualization, 'RGB')
Map.addLayer(centre,
{'color': 'black'},
'Geometry [black]: point');
Map.addLayer(centreBuffer,
{'color': 'red'},
'Result [red]: point.buffer')
transect = ee.Geometry.LineString([[-115.4, 35.584001], [-115.45, 35.584001]]);
Map.addLayer(transect, {'color': 'Green'}, 'transect');
Map