{"id":1153,"date":"2023-10-03T14:28:23","date_gmt":"2023-10-03T18:28:23","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/?post_type=chapter&#038;p=1153"},"modified":"2025-10-31T05:17:56","modified_gmt":"2025-10-31T09:17:56","slug":"getting-bathymetry","status":"publish","type":"chapter","link":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/chapter\/getting-bathymetry\/","title":{"raw":"Tutorial: Making a base map (bathymetry)","rendered":"Tutorial: Making a base map (bathymetry)"},"content":{"raw":"<p style=\"font-weight: 400\">One of the first steps for setting up an Ecospace scenario is to get a depth base map along with cell water area. Here\u2019s a short example of how you may access bathymetry and cell water area maps.<\/p>\r\nWe here use publicly available bathymetry data sets obtained from the GEBCO <a href=\"https:\/\/www.gebco.net\/data_and_products\/gridded_bathymetry_data\/\">website<\/a>. GEBCO provides a global terrain model for ocean and land, providing elevation data, in meters, on a 15 arc-second interval grid. It is accompanied by a Type Identifier (TID) Grid that gives information on the types of source data that the GEBCO_2023 Grid is based on. The data set is updated annually.\r\n<ul>\r\n \t<li>Go to GEBCO\u2019s global ocean and land terrain models\u2019 <a href=\"https:\/\/www.gebco.net\/data_and_products\/gridded_bathymetry_data\/\">website<\/a>, then <a href=\"https:\/\/download.gebco.net\/\">download data<\/a> for area of interest. The resolution at the GEBCO website is 15 arc-seconds, so about 463 m N-S for each cell. Select a custom area, then <em>Esri ASCII,<\/em> <em>Grid<\/em> format, and add to basket. View and download the data.<\/li>\r\n \t<li>In the downloaded folder, there will be an .asc file, that\u2019s the one we want for Ecospace. Here\u2019s an example of how this can be done,<\/li>\r\n \t<li>Open R-Studio and create a new R script file, save the file<\/li>\r\n \t<li>Load the terra package\r\n<ul>\r\n \t<li>library(terra)<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>Set your working directory, e.g.,\r\n<ul>\r\n \t<li>work.dir = dirname(rstudioapi::getActiveDocumentContext()$path)<\/li>\r\n \t<li>setwd(work.dir)<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>Read in the map, e.g.,\r\n<ul>\r\n \t<li>map = -rast (filename)\r\n<ul>\r\n \t<li>where filename is the name of the downloaded .asc file<\/li>\r\n \t<li>For Ecospace we want depths to be positive, hence the minus sign in front of raster<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>The map is fairly high resolution, so you\u2019ll likely want to aggregate it. Aggregation is by default by averaging, so we need to get rid of the land values before aggregating,\r\n<ul>\r\n \t<li>map[map&lt;0] = NaN<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>You can see the map using,\r\n<ul>\r\n \t<li>plot(map)\r\n<ul>\r\n \t<li>See Figure 1.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<div class=\"textbox\"><strong><img class=\"size-full wp-image-1155 aligncenter\" src=\"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high.png\" alt=\"\" width=\"984\" height=\"953\" \/>\r\nFigure 1<\/strong>. High resolution raster map as extracted from the GEBCO website. The area shown is the central part of Howe Sound near Vancouver BC. For each cell, the water area is a GIS parameter that is used in the R calculations.<\/div>\r\n&nbsp;\r\n<ul>\r\n \t<li>To aggregate the map, decide on how many times (X) you want to reduce the number of rows and how many times (Y) you want to reduce the number of cols. (or try till you have something suitable), e.g.,\r\n<ul>\r\n \t<li>facto = c(X,Y)<\/li>\r\n \t<li>low_res_map = aggregate(map, facto, FUN=mean, na.rm=TRUE, na.action=NULL)\r\n<ul>\r\n \t<li>excluding land cells from averaging with na.rm<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>plot(low_res_map)\r\n<ul>\r\n \t<li>See Figure 2.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<div class=\"textbox\"><strong><img class=\"size-full wp-image-1156 aligncenter\" src=\"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low.png\" alt=\"\" width=\"984\" height=\"953\" \/>\r\nFigure 2<\/strong>. Low resolution raster map as calculated using the R code in this tutorial. The map is aggregated with a 4 by 4 factor, so it has 1\/16 of the resolution of Figure 1. For each aggregated cell, the water area is calculated based on water area in each cell in the high resolution that was extracted from the GEBCO website.<\/div>\r\n&nbsp;\r\n<ul>\r\n \t<li>Calculate the proportion of cells that have water\r\n<ul>\r\n \t<li>prop_water_cells = aggregate(not.na(map), facto, fun=sum) \/ facto[1] \/ facto[2]<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>Get the cell area; it is in m<sup>2<\/sup>, so change to km<sup>2<\/sup>\r\n<ul>\r\n \t<li>cell_area = cellSize(low_res_map)\/10^6<\/li>\r\n \t<li>water_area = prop_water_cells * cell_area<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>Finally save to asc file\r\n<ul>\r\n \t<li>writeRaster(low_res_map, \u2018my_depth_map.asc\u2019, overwrite=TRUE)<\/li>\r\n \t<li>writeRaster(water_area, \u2018my_water_area_map.asc\u2019, overwrite=TRUE)<\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>Open the .asc file with Excel, and read the number of rows and cols from the header<\/li>\r\n \t<li>Now open EwE, and create a new Ecospace scenario<\/li>\r\n \t<li>Open <em>Ecospace &gt; Input &gt; Maps<\/em>\r\n<ul>\r\n \t<li>Click <em>Edit basemap<\/em>, and set the rows and cols to the same as in the .asc file<\/li>\r\n \t<li>Double click the <em>Depth layer<\/em><\/li>\r\n \t<li>The values will likely all be 1, click the top-left corner and set all to 0 (=land), this is because the Ecospace import will not always overwrite water with land<\/li>\r\n \t<li>Click <em>Import &gt; From ASCII grid &gt; import your asc file &gt; OK<\/em><\/li>\r\n<\/ul>\r\n<\/li>\r\n \t<li>Water area is used in calculations of results across the map, so not for displaying densities on maps, but for extraction of, e.g., catches or biomasses for functional groups<\/li>\r\n \t<li>That should be it.<\/li>\r\n<\/ul>\r\n<div class=\"textbox shaded\">\r\n\r\n<strong><span style=\"text-align: initial;font-size: 0.9em\">Attribution (data)<\/span><\/strong>\r\n<div class=\"textbox__content\">\r\n<p style=\"text-align: left\">GEBCO Compilation Group (2023) GEBCO 2023 Grid \u00a0<a href=\"https:\/\/www.gebco.net\/\">https:\/\/www.gebco.net\/<\/a><\/p>\r\n\r\n<\/div>\r\n<\/div>","rendered":"<p style=\"font-weight: 400\">One of the first steps for setting up an Ecospace scenario is to get a depth base map along with cell water area. Here\u2019s a short example of how you may access bathymetry and cell water area maps.<\/p>\n<p>We here use publicly available bathymetry data sets obtained from the GEBCO <a href=\"https:\/\/www.gebco.net\/data_and_products\/gridded_bathymetry_data\/\">website<\/a>. GEBCO provides a global terrain model for ocean and land, providing elevation data, in meters, on a 15 arc-second interval grid. It is accompanied by a Type Identifier (TID) Grid that gives information on the types of source data that the GEBCO_2023 Grid is based on. The data set is updated annually.<\/p>\n<ul>\n<li>Go to GEBCO\u2019s global ocean and land terrain models\u2019 <a href=\"https:\/\/www.gebco.net\/data_and_products\/gridded_bathymetry_data\/\">website<\/a>, then <a href=\"https:\/\/download.gebco.net\/\">download data<\/a> for area of interest. The resolution at the GEBCO website is 15 arc-seconds, so about 463 m N-S for each cell. Select a custom area, then <em>Esri ASCII,<\/em> <em>Grid<\/em> format, and add to basket. View and download the data.<\/li>\n<li>In the downloaded folder, there will be an .asc file, that\u2019s the one we want for Ecospace. Here\u2019s an example of how this can be done,<\/li>\n<li>Open R-Studio and create a new R script file, save the file<\/li>\n<li>Load the terra package\n<ul>\n<li>library(terra)<\/li>\n<\/ul>\n<\/li>\n<li>Set your working directory, e.g.,\n<ul>\n<li>work.dir = dirname(rstudioapi::getActiveDocumentContext()$path)<\/li>\n<li>setwd(work.dir)<\/li>\n<\/ul>\n<\/li>\n<li>Read in the map, e.g.,\n<ul>\n<li>map = -rast (filename)\n<ul>\n<li>where filename is the name of the downloaded .asc file<\/li>\n<li>For Ecospace we want depths to be positive, hence the minus sign in front of raster<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>The map is fairly high resolution, so you\u2019ll likely want to aggregate it. Aggregation is by default by averaging, so we need to get rid of the land values before aggregating,\n<ul>\n<li>map[map&lt;0] = NaN<\/li>\n<\/ul>\n<\/li>\n<li>You can see the map using,\n<ul>\n<li>plot(map)\n<ul>\n<li>See Figure 1.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"textbox\"><strong><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1155 aligncenter\" src=\"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high.png\" alt=\"\" width=\"984\" height=\"953\" srcset=\"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high.png 984w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high-300x291.png 300w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high-768x744.png 768w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high-65x63.png 65w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high-225x218.png 225w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-high-350x339.png 350w\" sizes=\"auto, (max-width: 984px) 100vw, 984px\" \/><br \/>\nFigure 1<\/strong>. High resolution raster map as extracted from the GEBCO website. The area shown is the central part of Howe Sound near Vancouver BC. For each cell, the water area is a GIS parameter that is used in the R calculations.<\/div>\n<p>&nbsp;<\/p>\n<ul>\n<li>To aggregate the map, decide on how many times (X) you want to reduce the number of rows and how many times (Y) you want to reduce the number of cols. (or try till you have something suitable), e.g.,\n<ul>\n<li>facto = c(X,Y)<\/li>\n<li>low_res_map = aggregate(map, facto, FUN=mean, na.rm=TRUE, na.action=NULL)\n<ul>\n<li>excluding land cells from averaging with na.rm<\/li>\n<\/ul>\n<\/li>\n<li>plot(low_res_map)\n<ul>\n<li>See Figure 2.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"textbox\"><strong><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1156 aligncenter\" src=\"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low.png\" alt=\"\" width=\"984\" height=\"953\" srcset=\"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low.png 984w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low-300x291.png 300w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low-768x744.png 768w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low-65x63.png 65w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low-225x218.png 225w, https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-content\/uploads\/sites\/1902\/2023\/10\/howe-sound-low-350x339.png 350w\" sizes=\"auto, (max-width: 984px) 100vw, 984px\" \/><br \/>\nFigure 2<\/strong>. Low resolution raster map as calculated using the R code in this tutorial. The map is aggregated with a 4 by 4 factor, so it has 1\/16 of the resolution of Figure 1. For each aggregated cell, the water area is calculated based on water area in each cell in the high resolution that was extracted from the GEBCO website.<\/div>\n<p>&nbsp;<\/p>\n<ul>\n<li>Calculate the proportion of cells that have water\n<ul>\n<li>prop_water_cells = aggregate(not.na(map), facto, fun=sum) \/ facto[1] \/ facto[2]<\/li>\n<\/ul>\n<\/li>\n<li>Get the cell area; it is in m<sup>2<\/sup>, so change to km<sup>2<\/sup>\n<ul>\n<li>cell_area = cellSize(low_res_map)\/10^6<\/li>\n<li>water_area = prop_water_cells * cell_area<\/li>\n<\/ul>\n<\/li>\n<li>Finally save to asc file\n<ul>\n<li>writeRaster(low_res_map, \u2018my_depth_map.asc\u2019, overwrite=TRUE)<\/li>\n<li>writeRaster(water_area, \u2018my_water_area_map.asc\u2019, overwrite=TRUE)<\/li>\n<\/ul>\n<\/li>\n<li>Open the .asc file with Excel, and read the number of rows and cols from the header<\/li>\n<li>Now open EwE, and create a new Ecospace scenario<\/li>\n<li>Open <em>Ecospace &gt; Input &gt; Maps<\/em>\n<ul>\n<li>Click <em>Edit basemap<\/em>, and set the rows and cols to the same as in the .asc file<\/li>\n<li>Double click the <em>Depth layer<\/em><\/li>\n<li>The values will likely all be 1, click the top-left corner and set all to 0 (=land), this is because the Ecospace import will not always overwrite water with land<\/li>\n<li>Click <em>Import &gt; From ASCII grid &gt; import your asc file &gt; OK<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Water area is used in calculations of results across the map, so not for displaying densities on maps, but for extraction of, e.g., catches or biomasses for functional groups<\/li>\n<li>That should be it.<\/li>\n<\/ul>\n<div class=\"textbox shaded\">\n<p><strong><span style=\"text-align: initial;font-size: 0.9em\">Attribution (data)<\/span><\/strong><\/p>\n<div class=\"textbox__content\">\n<p style=\"text-align: left\">GEBCO Compilation Group (2023) GEBCO 2023 Grid \u00a0<a href=\"https:\/\/www.gebco.net\/\">https:\/\/www.gebco.net\/<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"author":1909,"menu_order":7,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[49],"contributor":[],"license":[],"class_list":["post-1153","chapter","type-chapter","status-publish","hentry","chapter-type-numberless"],"part":418,"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/chapters\/1153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/wp\/v2\/users\/1909"}],"version-history":[{"count":12,"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/chapters\/1153\/revisions"}],"predecessor-version":[{"id":4147,"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/chapters\/1153\/revisions\/4147"}],"part":[{"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/parts\/418"}],"metadata":[{"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/chapters\/1153\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/wp\/v2\/media?parent=1153"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/pressbooks\/v2\/chapter-type?post=1153"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/wp\/v2\/contributor?post=1153"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/ewemodel\/wp-json\/wp\/v2\/license?post=1153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}