Springe direkt zu Inhalt

Visualization of data

Visualization of data

As you might have noticed, accessing data and adding it to the console does not mean that it will be automatically displayed in the map panel. To do so, we will have to write some code on how we want to have it visualized.

To see how this is done, we can have a look at the Docs tab on the left panel and browse to Map. Here, we can see all the commands which are in some way related to the Map Panel and the maps we want to create. To add our ImageCollection layer to the map panel, read through Map.addLayer(eeObject, visParams, name, shown, opacity) carefully.

This command consists of the following Arguments (this is mainly taken from the documentation, with some added commentary):

eeObject: The object to add to the map. This can be ImageCollections, Images and Features.

visParams: The visualization parameters. Here, we can for example choose which bands, which minimum and maximum values or which color palette to display.

name: The name of the layer. The default is ‘Layer N’.

shown: if TRUE, the layer will be turned on by default. It can be useful to turn this off if you have multiple layers that take long time to render. Once loaded, layers can be shown and hidden at any time from the Map panel.

opacity: The layers opacity represented as a number between 0 and 1. Defaults to 1.

As we can see, we will need at least 2 mandatory items to add our imagery to the map panel: an object, which is our ImageCollection, and a variable visParams that contains our visualization parameters.


Also, if we want to be directly navigated to the correct location on the map panel where our imagery will be visualized, we will need to add the command Map.centerObject. Use the Docs tab to find out more about the specific arguments.


Let’s try to apply this to the Sentinel-2 scene we accessed in the last step!

//Visualizing Data
//Define the visualizing parameters; for this example, we will only define the visualized bands and the min/max values

var visParams = {'min': 400,'max': [4000,3000,3000],   'bands':'B8,B4,B3'}; //bands 8, 4 and 3 are to be visualized; minimum value is 400 for all three bands, maximum value is 4000 for band 8, 3000 for band 4 and 3

Map.addLayer(s2a, visParams ,'Sentinel2');   // Visualize the ImageCollection in the Map panel and assign a name to it
Map.centerObject(s2a,9);              // Center the map panel on the ImageCollection; zoom level is 9

Map.addLayer(s2a_cloudfree, visParams ,'Sentinel2_cloudfree');

Map.addLayer(s2a_mean, visParams ,'Sentinel2_mean');

We now have our data visualized in the map panel. Please note that when there are layers added to your map, the icon “layers” will appear in the upper right corner of your map panel. Here, you can toggle to show or hide the individual layers, as well as change all the options you have set in the visParams-variable by clicking on the gear-symbol. The layers will be shown by the name you assigned to them during map.addLayer.