Extracting Bathymetry and Coastline Data for SeaGrid

Facts, news, and guidance about ROMS software

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Extracting Bathymetry and Coastline Data for SeaGrid

#1 Unread post by arango »

Dear All,

Many of you are not familiar with the SeaGrid tool for generating ROMS grid NetCDF. SeaGrid is powerful interactive Matlab tool for generating orthogonal grids, interpolating bathymetry, and computing Land/Sea masking. This tool was developed by Charles Denham (USGS). For information check the following link:

http://woodshole.er.usgs.gov/staffpages ... agrid.html

Before using this tool for any specific application, the user needs to build three files:
  • 1) Bathymetry (Matlab .mat file)
    2) Coastlines (Matlab .mat file)
    3) Boundary (ASCII file)
The bathymetry file contains the application grided bathymetry. This data is usually extracted from a global dataset like ETOPO5. It is recommeded to extract the bathymetry data on a grid slightly larger than the application to get a bounded interpolation. Since the curvinilear grid transformation does not depends on the bathymetry, any bathymetry data can be used in SeaGrid to generate the grid NetCDF. Recall that once the grid NetCDF file is created, it is very trivial to replace the bathymetry data.

The coastline file is a Matlab file (.mat) containing the coastline (lat,lon) coordinate pairs. It is used to generate the Land/Sea masking fields for the model. Usually, this mask requires further editing and tunning. We have a separate Land/Sea masking editing tool. See below for further details.

The boundary file defines the corner points of the grid. It also contains the data pairs for the coastlines edges. The coastline edges are not as important as the corner points. The positions of the coast edge points can be added or edited by clicking and dragging the mouse. The corner points can be added and edited in similar fashion. However, it is very difficult to mouse click the positions of the corner points in any accurate way. It is much better to type the (lon,lat) corners exactly in the boundary file. Recall that the corner points are very important for the orthogonality properties of the transformation.

In my experience, SeaGrid works correctly when the bathymetry file is loaded first, followed by the coasline file, and the boundary file.

I have several Matlab scripts to extract bathymetry, coastlines data, and post-processing the grid NetCDF. They are located in my Matlab directory tree:

Code: Select all

      matlat/bath                bathymetry extraction scritps
      matlat/coastlines          coastlines extraction scripts
      matlab/rmask               land/sea mask editing scripts
You can download my Matlab directory tree from:

http://www.myroms.org/software/Processi ... lab.tar.gz

There is an extract.m script in the bath directory to extract the bathymetry at the specified box corners from the default global ETOPO5 NetCDF file. This NetCDF file is also located in this directory. You just need to edit this script and provide the appropiate filename and (lon,lat) corners.

Similarly, there is an extract.m script in the coastlines directory to extract the coastline data at the specified box corners from the GSHHS (Global Self-consistent Hierarchical, High-resolution Shoreline) database. You need to edit this script and select the appropriate GSHHS resolution, provide output filename and (lon,lat) corners.

The GSHHS data set can be downloaded from:

http://www.myroms.org/software/datasets/gshhs.tar.gz

A sample of the boundary file boundary.dat can be found in the coastlines directory. This is a simple three columns (lon,lat,corner_flag) ASCII file. The corner_flag is one if the boundary point is a corner and zero otherwise.

Finally, the Land/Sea masking interactive tool editmask is found in the rmask directory. We highly recommend to use this tool to check the Land/Sea masking of your grid.

Good luck,

Hernan G. Arango
arango@imcs.rutgers.edu

rouf

#2 Unread post by rouf »

I am a new user. I downloaded seagrid and was able to run the seagrid tutorial successfully with Matlab.
But for specific application should i build following three files?
Arango mentioned for any specific application, the user needs to build three files:

1) Bathymetry (Matlab .mat file)
2) Coastlines (Matlab .mat file)
3) Boundary (ASCII file)
I can edit extract.m script in the bath for bathymetry. But for coastline, may i use coastline extractor (according to seagrid tutorial) to get coastline file instead of editing extract.m script in coastline directory?

In terms of Arangos process (mentioned in that thread), is it possible to get more detail steps about building the above three files (specially coastline one)?

Rouf

rouf

#3 Unread post by rouf »

Just not to wast anyones time- I understand the Arangos description above. Its simple. Edit extract.m scripts and boundary.dat files; Use edited .m scripts to convert to mat file through MATLAB and load the files from seagrid.

Rouf

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#4 Unread post by mariafattorini »

Hello All,
I would like to know if it is possible to build a 3D grid with Seagrid.
I have downloaded and opened Seagrid but I seem to see only tools to build a 2D grid (for x- e y- directions but not for z- direction (depth)).
Is the third dimension set by N variable in ocean_application.in?

Thank, maria

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#5 Unread post by kate »

mariafattorini wrote:Hello All,
I would like to know if it is possible to build a 3D grid with Seagrid.
No, plus ROMS only reads the 2D grid.
Is the third dimension set by N variable in ocean_application.in?
Yes, exactly. The vertical dimension is defined by N and several other parameters. See https://www.myroms.org/wiki/index.php/V ... coordinate.

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#6 Unread post by mariafattorini »

Hello all,
I am trying to create the ascii boundary file for Seagrid.
The boundary file contains as following:

Code: Select all

  9.700  4.24  1
  9.700  4.29  0
  9.700  4.34  1
  1.045  4.34  0
  1.120  4.34  1
  1.120  4.29  0
  1.120  4.24  1
  1.045  4.24  0
where the first column is the longitude, the second one is the latitude and the last one is 1 for the corner points and 0 for the other points.
When I load this file on the Seagrid utility, the following lines appear in the ‘command window’ of Matlab:

Code: Select all

[ … ]

theMaskTool =

     []
theMaskToolFlag =

     []

  ## RECT Iteration 1: straightness = 93.7497 percent.
 ## RECT Iteration 2: straightness = 99.7805 percent.
and in the window ‘Seagrid’ the grid boundary does not appear.
What’s the problem of the boundary file?

Many thanks,
maria

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#7 Unread post by mariafattorini »

Hello,
I have corrected the values in the boundary ascii file (a my distraction!):

Code: Select all

  9.700  42.4  1
  9.700  42.9  0
  9.700  43.4  1
  10.45  43.4  0
  11.20  43.4  1
  11.20  42.9  0
  11.20  42.4  1
  10.45  42.4  0
and now I get the following errors (in Matlab, using Seagrid):

Code: Select all

theMaskTool =
     []

theMaskToolFlag =
     []
??? warning - tracking error

Error in ==> mexrect2grid at 98
			zrect = feval('mexrect', zrect, length(zrect), ...

Error in ==> seagrid.gridcalc at 179
[w, err] = feval(theFcn, zti, [], ci, [m n]);   % <===

Error in ==> seagrid.dogrid at 64
	gridcalc(self)   % <== Calculate grid.

Error in ==> seagrid.doupdate at 92
dogrid(self, needsUpdate);   % <== Step #2 <==

Error in ==> seagrid.doevent at 253
	doupdate(self, 1)

Error in ==> psevent at 25
	doevent(ps(gcbf), theEvent, theMessage);

??? Error while evaluating uimenu Callback.
Please, is there someone that understands what is wrong in this boundary file?
Many thanks, maria

zhaoqian
Posts: 45
Joined: Tue Nov 11, 2008 5:45 pm
Location: National Marine Environmental Mornitoring Center

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#8 Unread post by zhaoqian »

Dear arango and other roms users:

I also meet the problem metioned above when calling boundary file using seagrid. The following is the matlab executing information.

>> seagrid

thePoints =

117.5000 41.0000 1.0000
117.5000 36.5000 1.0000
127.0000 36.5000 1.0000
127.0000 41.0000 1.0000


theOrthogonalityFlag =

[]


theBathymetryFlag =

[]


theMaskingFlag =

[]


theMaskTool =

[]


theMaskToolFlag =

[]

??? Error using ==> mexrect
warning - tracking error

Error in ==> mexrect2grid at 98
zrect = feval('mexrect', zrect, length(zrect), ...

Error in ==> seagrid.gridcalc at 179
[w, err] = feval(theFcn, zti, [], ci, [m n]); % <===

Error in ==> seagrid.dogrid at 64
gridcalc(self) % <== Calculate grid.

Error in ==> seagrid.doupdate at 92
dogrid(self, needsUpdate); % <== Step #2 <==

Error in ==> seagrid.doevent at 253
doupdate(self, 1)

Error in ==> psevent at 25
doevent(ps(gcbf), theEvent, theMessage);

??? Error while evaluating uimenu Callback

My operation system is winxp with matlab R2007b, and my boundary file is as follows.

117.5 41 1
117.5 36.5 1
127 36.5 1
127 41 1

In my another PC with win vista and matlab R2007b, it passed when calling boundary file. I am so confuse about it. Would someone help me? Thank you very much.

angelolemos
Posts: 34
Joined: Wed Mar 11, 2009 4:24 pm
Location: UFES

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#9 Unread post by angelolemos »

Hi dears,

I followed what is write in the file MAIN_grid.m.
I created my grid file, using all the packages mentioned, including seagrid.

My problem appear when a typed:

unix(['vi ',configfile]);
grd=rnt_gridload(nameit);


My matlab just give the mensage:

[54;1HError detected while processing /home/angelolemos/.vimrc:


line 1:


E492: Not an editor command: et background=dark


Press ENTER or type command to continue


The operation don't work when I press ENTER, just stop.
I agreee that the problem is with the command unix(['vi ',configfile]);, but in my directory /home/angelolemos/ there is a file called vimrc and vimrc_example.vim.

I changed the command to unix(['vim ',configfile]) and unix(['vimrc ',configfile]), but don't worked.
My operational system is Linux/Debian.

Anyone can help me?! please.

Thanks a lot!

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#10 Unread post by kate »

What is in your .vimrc file? Is "et background=dark" there? Maybe try adding an initial "s" to get "set".

angelolemos
Posts: 34
Joined: Wed Mar 11, 2009 4:24 pm
Location: UFES

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#11 Unread post by angelolemos »

It worked! Thanks a lot.

Other problem persist.

h=rnt_griddata(lon,lat,topo,grd.lonr,grd.latr,'cubic');
??? Invalid MEX-file '/home/angelolemos/src/ROMS/roms-grid/rnt_hindicesTRI_mex.mexglx': libifport.so.5: cannot open shared object file: No such file or directory.

Error in ==> rnt_hindicesTRI at 41
[Ipos,Jpos,triX,triY,Ival,Jval]=rnt_hindicesTRI_mex(Xpos,Ypos,Xgrd,Ygrd);

Error in ==> rnt_griddata at 35
[Ipos,Jpos]=rnt_hindicesTRI(lon(:),lat(:),Xgrd,Ygrd);


I have the file rnt_hindicesTRI_mex.mexglx in my directory and in the set path of matlab.
This file I downloaded from the Arango package.
Is there other version of the file which I can to download ?

Thanks again!

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#12 Unread post by kate »

Anything with .mex??? is a compiled file. You should probably compile it yourself with the mex command.

angelolemos
Posts: 34
Joined: Wed Mar 11, 2009 4:24 pm
Location: UFES

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#13 Unread post by angelolemos »

Thanks Kate, but other problem appeared:

>> mex rnt_hindicesTRI_mex.f
Warning: You are using gcc version "4.4.2-9)". The earliest gcc version supported
with mex is "4.0.0". The latest version tested for use with mex is "4.2.0".
To download a different version of gcc, visit http://gcc.gnu.org
g95: Unrecognized option '-c'

mex: compile of 'rnt_hindicesTRI_mex.f' failed.

??? Error using ==> mex at 206
Unable to complete successfully.


I don't know how to install a new version of the gcc.
My system is Debian.
The Debian work with 4.1 version or newest.

It's a big problem!

Thanks again

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#14 Unread post by kate »

You might have better luck with gfortran, which comes with gcc-4, at least as an option.

Installing free software is fun! You download it from the net, get it somewhere on your path, and then it's yours to use. Instructions (of sorts) should be on the net where you got the package in question. Most packages have a configure script and you can just:

Code: Select all

configure --prefix=$(HOME)    # or wherever (it defaults to /usr/local)
make
make check                  # runs tests if there are any
make install

tony1230
Posts: 87
Joined: Wed Mar 31, 2010 3:29 pm
Location: SKLEC,ECNU,Shanghai,China

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#15 Unread post by tony1230 »

which one is good to generate the grid for ROMS, delft3d or seagrid ? i used to use the 3d and , i know that the seagrid also can generate the grid , but i never used that. someone used both of them?

angelolemos
Posts: 34
Joined: Wed Mar 11, 2009 4:24 pm
Location: UFES

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#16 Unread post by angelolemos »

Kate, I had installed correctly the libgfortran.
So, I think that the file mex can't be changed, because the following error appeared:

>> mex rnt_hindicesTRI_mex.f
g95: Unrecognized option '-c'

mex: compile of 'rnt_hindicesTRI_mex.f' failed.

??? Error using ==> mex at 206
Unable to complete successfully.


What can I do?

Regards!

ThanosG
Posts: 14
Joined: Mon May 27, 2013 11:02 pm

Re: Extracting Bathymetry and Coastline Data for SeaGrid

#17 Unread post by ThanosG »

Dear users,

I am a new ROMS user and I am trying to build my area bathymetry netcdf file. I am using the USGS seagrid and I am facing the problem that I will describe.
I am providing the bathymetry file in .mat form, exactly how I want it. Meaning that I have checked it in almost all points, it has the depths in the straights that I want it to have (based in maps), the exact resolution that the model will have and of course it is perfectly aligned with the coastline. The coastline as well as the boundary points, are also provided.
When I calculate depth and mask through seagrid, I get a result with significantly altered depths (in some points with 2,000.00m, even 3,000.00m difference) and the mask is considerably changed in many areas. Sea turned into land and vice versa.
There are two explanations, either I am doing something in the wrong way, or Seagrid simply is designed to alter the initially provided file.
After providing the files, I put the grid resolution in the setup (same as provided), min depth (3m), max depth (inf or the proper max depth) and I put > Calculate Depths and Land.
Is there a way, either to just have the seagrid.mat (and of course through seagrid2mat, the final netcdf file), containing the exact same bathymetry and mask as I provided it? Or from what I describe, do you believe that I am making a mistake somewhere in the process? Anyone else faced the same problem and managed to solve it?

Thank you for your time in advance,
Thanos

Post Reply