Skip to content

TUTORIAL 5

scale in web mercator

This tutorial aims to introduce concepts and methods for working with proximity and zonal statistics in Earth Engine.

Our practical goal is to make a map of Tissot’s Indicatrix and then compute the area and number of pixels contained by each circle through a zonal overlay method. By the end, your script should reproduce the layers shown in the app below.

In addition, you should be able to interpret your results by using the Inspector tool to compare how pixel scale changes with respect to the area and pixel count of Tissot’s indicatrix.

open app in new tab

workflow


00 start script

/*    
// ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

    AUTHOR:   
    DATE:     10/7/2024
    TITLE:    Scale in web mercator

// ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
*/

var geo = require("users/jhowarth/eePatterns:modules/geo.js");

print("geo methods dictionary", geo.help);    // Prints dictionary of all tools in module.  
print("geo palettes", geo.iPalettes);         // Prints dictionary of all palettes in module. 

01 set up map

// -------------------------------------------------------------
//  1. Set up map
// -------------------------------------------------------------

// 1.1. Center map on prime meridian and equator at zoom level 2.  

Map.setCenter(0,0,2);

// 1.2. Set base map to hybrid.



// 1.3. Compute Map scale at Map zoom 

var scale = Map.getScale();

print("Map scale", scale);

02 visualize pixel area

// -------------------------------------------------------------
//  2. Visualize change in pixel area across Map.
// -------------------------------------------------------------

// 2.1. Make a layer that stores area of each pixel in square kilometers.

var pixel_area = ee.Image.pixelArea().divide(1e6);

// 2.2. Draw a rectangle from equator to pole.

var test_extent = ee.Geometry.Polygon(
        [[[-139.54012012783244, 16.927790310290327],
          [-139.54012012783244, -85.91090722591649],
          [52.41300487216755, -85.91090722591649],
          [52.41300487216755, 16.927790310290327]]]);

// 2.3. Calculate min and max of area image with test_extent rectangle at scale of zoom level. 



 // 2.4. Define viz parameters with palette: geo.iPalettes.iDistance.inferno



// 2.5. Display pixel_area as layer on Map.



// 2.6. Make legend of pixel area layer. 



// 2.7. Add legend to Map.  

03 create Tissot’s indicatrix

// -------------------------------------------------------------
//  3. Create Tissot's Indicatrix. 
// -------------------------------------------------------------

// 3.1. Gather tissot grid.

var grid = geo.projections.tissot_grid;

print("3.1. grid", grid);

// 3.2. Display grid as Map layer.



// 3.3 Buffer each point in grid by 600,000 meters. 



// 3.4 Add buffered points (Tissot's Indicatrix) as Map Layer. 

Map.addLayer(indicatrix, {color: 'gold'}, "3.4. Tissot's Indicatrix");

04 visualize area of indicatrix

// -------------------------------------------------------------
//  4. Visualize area of Tissot's indicatrix
// -------------------------------------------------------------

// 4.1 Zonal statistic for sum of pixel area at scale 5000.




// 4.2 Convert 4.1 output to image



// 4.3 Define viz parameters.



// 4.4 Display as Map layer.



// 4.5. Make legend of tissot area layer. 



// 4.6. Add legend to Map.  

05 visualize count of indicatrix

// -------------------------------------------------------------
//  5. Visualize count of indicatrix
// -------------------------------------------------------------

// 5.1 Zonal statistic for count of pixel area at scale 5000.



// 5.2 Convert to image. 



// 5.3 Define viz parameters. 




// 5.4 Display as Map layer.  




// 5.5. Make legend of tissot area layer. 


// 5.6. Add legend to Map.  

06 inspect your results

Click on the Inspector tab on the right panel of the Code Editor. Moving from the equator towards the poles, clock on the Tissot Indicatrix and note the Scale (approx. m/px) that GEE reports. This number should report the distance on the ground represented by the length of one pixel side.

HINT: You may need to click on the Point header in order to see the scale reports.

Try to answer these questions:

  1. How does scale change with latitude?
  2. How does this jive with the area and count statistics that you calculated for each circle?
  3. How do you explain these results?

This work is licensed under CC BY-NC-SA 4.0