Geographic Information Systems Asked by AlbertoH on April 2, 2021
I am new to GEE. I’m working with Landsat images. First, visualizing them in the map, then downloading them and working with them afterwards in QGis 3.6 to obtain certain indexes (NDVI, NDWI, Wetness) for some dates.
They sent me a code to do this with Landsat 8 images, and it works perfect for the dates > 2013. I can visualize the Landsat images and then download them to me Drive, after making sure cloud cover is < 10.
The code is this one:
var L8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_RT"),
Zona =
/* color: #ff0000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[-69.65662957471234, -19.253174496773713],
[-69.65662957471234, -19.86525490862596],
[-68.83402825635297, -19.86525490862596],
[-68.83402825635297, -19.253174496773713]]], null, false);
//AGREGAR MANUALMENTE:
// Polígono que incluya la zona cuyas imágenes se quieren
// descargar (dibujar con el mouse)
// Parámetros visualización para el mapa
var imageVisParam = {bands: ["B7","B5","B2"], max: 18241, min: 6422}
//Fechas (ir modificando manualmente)
var date1 = ee.Date('2019-08-01');
var date2 = ee.Date('2019-08-30');
// Filtrar para la fecha requerida y para cobertura de nubes
var L8_d1 = L8
.filterBounds(Zona)
.filterDate(date1, date2)
.filterMetadata("CLOUD_COVER", "less_than", 10);
print(L8_d1)
// Cortar al área de estudio
var mask = function(image){
var cortada = image.clip(Zona);
return cortada
};
var L8clipped = L8_d1.map(mask)
var newr = L8clipped.max()
Map.addLayer(newr, imageVisParam, "landsat")
// Exportar la imagen, especificando escala y región.
Export.image.toDrive({
image: newr,
description: 'Landsat_01',
folder: 'GoogleEngine', //cambiar según su carpeta
scale: 30,
region: Zona
});
The problem is now I need more old images (~ 1985-2013), so I want to do the exact same thing, but with Landsat 5. But when I try to modify the original code in order to do this, I can’t visualize the images. All I get is a redder square.
The code I’m trying for this last thing is this one:
var L5 = ee.ImageCollection("LANDSAT/LT05/C01/T1"),
Zona =
/* color: #ff0000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[-69.89558221143109, -19.73992297777349],
[-69.89558221143109, -20.35013752032207],
[-68.78458977979047, -20.35013752032207],
[-68.78458977979047, -19.73992297777349]]], null, false);
// AGREGAR MANUALMENTE:
// Polígono que incluya la zona cuyas imágenes se quieren
// descargar (dibujar con el mouse)
// Parámetros de visualización para el mapa
var imageVisParam = {bands: ["B7","B4","B1"], max: 20000, min: 6000}
// Fechas (ir modificando manualmente)
var date1 = ee.Date('2006-07-01');
var date2 = ee.Date('2006-07-31');
// Filtrar para la fecha requerida y para cobertura de nubes
var L5_d1 = L5
.filterBounds(Zona)
.filterDate(date1, date2)
.filterMetadata("CLOUD_COVER", "less_than", 10);
print(L5_d1);
// Cortar al área de estudio
var mask = function(image){
var cortada = image.clip(Zona);
return cortada
};
var L5clipped = L5_d1.map(mask);
var newr = L5clipped.max();
Map.addLayer(newr, imageVisParam, "landsat");
// Exportar la imagen, especificando escala y región.
Export.image.toDrive({
image: newr,
description: 'Landsat_Sept06',
folder: 'GoogleEngine', //cambiar según su carpeta
scale: 30,
region: Zona
});
I’ve tried modifying the dates, the cloud cover, and the visualization parameters (bands, max and min) and nothing. And when I try downloading them, the following error appears:
Error: Exported bands must have compatible data types; found
inconsistent types: Byte and UInt16.
I don’t quite understand the max and min from the visualization, I think the error might be there.
Can someone explain what they mean and how to get them for different images (to learn how to do it in the future)?
Do you have recommendations for images sets to work with?
I don’t know which sets are available for this kind of work in GEE.
OK I edited your code slightly but this should work in a similar fashion to the code you used for Landsat 8.
The min and max in the visualization parameters specify a valid range of values to show in the map console. If your range is too high or too low, you will get an all white or all black image in the map display. In this case, Landsat 5 values are 8-bit integers and can only be from 0-255, so I adjusted the min and max values to values within that range. This only controls what you see on the map, not what is exported.
For the export issue, I used .select() to select the 7 bands of similar pixel type.
var L5 = ee.ImageCollection("LANDSAT/LT05/C01/T1"),
Zona =
/* color: #ff0000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[-69.89558221143109, -19.73992297777349],
[-69.89558221143109, -20.35013752032207],
[-68.78458977979047, -20.35013752032207],
[-68.78458977979047, -19.73992297777349]]], null, false);
// AGREGAR MANUALMENTE:
// Polígono que incluya la zona cuyas imágenes se quieren
// descargar (dibujar con el mouse)
// Parámetros de visualización para el mapa
var imageVisParam = {bands: ["B7","B4","B1"], max: 150, min: 0}
// Fechas (ir modificando manualmente)
var date1 = ee.Date('2006-07-01');
var date2 = ee.Date('2006-07-31');
// Filtrar para la fecha requerida y para cobertura de nubes
var L5_d1 = L5
.filterBounds(Zona)
.filterDate(date1, date2)
.filterMetadata("CLOUD_COVER", "less_than", 10);
print(L5_d1);
// Cortar al área de estudio
var mask = function(image){
var cortada = image.clip(Zona);
return cortada
};
var L5clipped = L5_d1.map(mask);
var newr = L5clipped.max().select(['B*.']);
Map.addLayer(newr, imageVisParam, "landsat");
Answered by rpr_mt on April 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP