2

I'm trying to find elevation using GEE, but I want to set boundary thickness for each country for better representation. How can I do this? Here is the link for code. You can see when two countries Pakistan and Afghanistan showed, boundary thickness is less visible

var pakistan = ee.FeatureCollection("users/Fall2019/PakistanAdministrativeBoundaries"),
    table4 = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017");

// Load Pakistan boundary and ICT 
var ICT = pakistan.filter(ee.Filter.eq("adm1_name","Islamabad"));
// Map.addLayer(ICT, {}, "ICT");
// Map.centerObject(ICT, 8); 
var Afghanistan = table4.filter(ee.Filter.eq('country_co','AF'))

// set styling
var styling = {color: 'blue', fillColor: '00000000'};
var styling2 = {color: 'red', fillColor: '00000000'};
Map.addLayer(pakistan.style(styling))
Map.addLayer(Afghanistan.style(styling2))

var srtm = ee.Image("CGIAR/SRTM90_V4");
var topography = ee.Terrain.products(srtm);
// print("Toopographic products", topography);
Map.addLayer(topography.select(2).clip(pakistan), {min:0, max:359}, 'Pakistan', true);
Map.addLayer(topography.select(2).clip(Afghanistan), {min:0, max:359}, 'Afghanistan', true);

https://code.earthengine.google.com/50aa9ad854f70894da2c94dc026d6a45

1 Answer 1

3

To change the line width, you can add width to the styling parameters:

var styling = {color: 'blue', fillColor: '00000000', width: 4};
var styling2 = {color: 'red', fillColor: '00000000', width: 4};
Map.addLayer(pakistan.style(styling));
Map.addLayer(Afghanistan.style(styling2));

However, that only visually affects the surrounding border, not the border between the countries; this is because the SRTM90_V4 image is drawn above the lines, hiding them. If you want to see all the lines, you can add the boundary layers after the image layers, instead of before:

Map.addLayer(topography.select(2).clip(pakistan), {min:0, max:359}, 'Pakistan', true);
Map.addLayer(topography.select(2).clip(Afghanistan), {min:0, max:359}, 'Afghanistan', true);

Map.addLayer(pakistan.style(styling));
Map.addLayer(Afghanistan.style(styling2));

That change produces this result, without changing the line width:

Screenshot of revised map

5
  • Thanks alot for this amazing answer Commented Feb 6, 2022 at 10:13
  • can we show names of countries above the map? Because names are just hidden Commented Feb 6, 2022 at 10:16
  • or any other way to show names of cities which we used in shapefile? Commented Feb 6, 2022 at 11:38
  • @MuhammadSobanBehzad That's a different question, and I don't have the expertise to answer it. Please post it separately, not in comments! Comments get seen by a lot fewer people.
    – Kevin Reid
    Commented Feb 6, 2022 at 16:17
  • sure I will post it Commented Feb 6, 2022 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.