Giter Site home page Giter Site logo

Comments (20)

HamishB avatar HamishB commented on May 28, 2024 1

Hi,

FYI my usual workflow in GRASS is to use:

g.region # to set grid bounds and resolution
r.in.xyz # to import x,y,z data into a raster map. it is very fast and can handle datasets that are many 100s of GB in size and 10s of billions of xyz points. good for lidar and multibeam bathymetry
r.surf.nnbathy # to interpolate over the gaps (an addon module *because it uses the Triangle library which is not GPL compatible)
r.mapcalc # to multiply it by -1 it so depth is positive. can also use the 'zscale' option during the r.in.xyz step
r.out.gdal # to export GeoTIFF

r.contour # to make coastline and maximum elevation limiting contour lines
v.out.ogr # to make shapefiles of those two contour lines

help pages:
https://grass.osgeo.org/grass78/manuals/g.region.html
https://grass.osgeo.org/grass78/manuals/r.in.xyz.html
https://grass.osgeo.org/grass78/manuals/addons/r.surf.nnbathy.html

If working with multibeam bathy data see also MB-Systems. It uses GMT internally to do its gridding and interpolation and can also handle truly massive datasets with grace and ease.

regards,
Hamish

from oceanmesh2d.

HamishB avatar HamishB commented on May 28, 2024 1

ps - I wrote this for contour lines -> DEM not xyz -> DEM, but it gives some good examples of how various interpolation techniques compare to each other; if it may be of interest.
https://grasswiki.osgeo.org/wiki/Contour_lines_to_DEM

from oceanmesh2d.

WPringle avatar WPringle commented on May 28, 2024

Hi @huyquangt

There is no formal way to use xyz data with the "interp" function.

It is very easy to interpolate xyz points to the mesh though:

  • scatteredInterpolant:
    F = scatteredInterpolant(x,y,z,'method'); % see help for method options
    m.b = F(m.p);
  • Inverse distance weighting (with fixed radius 'rad')
    m.b = IDW(x,y,z,m.p(:,1),m.p(:,2),-2,'fr',rad); %set IDW function attached
    IDW.m.txt

Cheers!

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Hi Williams, thanks for a prompt reply πŸ‘

Yes, I use scatterIterpolant quite often, but here during mesh generation I want to put constraints dt (timestep, CFL max,min) which require to have bathymetry data read by geodata(varargin)/ParseDEM(obj,varargin)/[xvn, yvn, zvn] = getdemvarnames(fname)...

I could convert scatter points into DEM data and write in a netcdf file, but the file would be very large as I need very a high resolution, so it is impractical for my case.

Is there another thought?

By the way, I still plan to play with your stuff, will keep you updated & stay safe!

Cheers
Huy

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

Hey Huy,

If you want to do multiscale mesh generation around a localized area, the mesh size function can be nested with finer resolution boxes. See examples/Example_ECGC.

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Hi Keith,

Thanks for that πŸ‘ ... yes what I have been doing is similar to this.

As xyz scatter points cannot be handled in geodata at the present time, I end up with writting several bathymetry files with different resolutions.... so it is fine now..

Cheers,
Huy

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

Hey Huy,

Just to clarify why we did not support xyz data from the beginning of the development of this tool is primarily because we do not want to build a mesh to build a mesh.

In the case of the unstructured xyz data, the only way to use this data for mesh generation is to form a TIN (triangulated irregular network) which is often a Delaunay triangulation. There are several downsides to doing this:

  1. Storage of the TIN is memory expensive
  2. Query time is significantly slower than a structured grid.
  3. Algorithmic complexity is more complex with a TIN. For example, the meshgen/private/smooth_outer.m relies on the topology of the structured grid to do the smoothing of nested sizing functions quickly.

and another point that we considered:

  1. Most available data are already DEMs placed on structured grids.

In my experience, survey data (xyz) tend to be less reliable.

And you point out, in your area(s) of interest you could create a structured grid and naively interpolate the xyz to the structured grid creating a DEM in a NETCDF file format. This could be done at several length scales to avoid the memory bottleneck that is inherent to structured grids. And finally, this (memory bottleneck w/ structured grids) is exactly why we developed the mutliscale meshing technique that allows nesting of several sizing function and largely disparate horizontal length scales.

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Awesome, Keith! Thank for a detailed explanation.. so I got several netcdf-DEM files with different resolutions to serve my multiscale meshes.

However, a "tidy" problem has arisen: when I specify two different regions for 2 different mesh scales, I often see a hole in the overlapping region as attached.

have you seen this before?

hole

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

Hey Huy,

yes, I've seen this before but I've never figured out why exactly it happens, to be honest. One thing that I've suspected in the past was that it was related to msh.clean(). If you could repeat the generation of the mesh without applying cleaning (set cleanup to 0 when calling mshgen) that could help us nail down the source of the bug.

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Hello Keith,

After playing with grid sizes, I found this issue often occurs when the grid size between two regions (scales) are large.. so my approach is to reduce the different in the grid size between two regions... so the unexpected holes could disappear! Do you want me to close this issue? Have a great weekend, mates!

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

Huy,

That's interesting but did you try turning off the cleaning step? I suspect the sharp mesh size gradient between the nests leads to a poor quality element that's removed for some reason while performing the cleaning step.

Could you just test your examples if you haven't already without cleanup enabled and see what happens (even if you have a steep size gradient between nests)? Thanks and have a great weekend as well.

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Hi Keith,

what do you mean by turning off the cleaning step? sorry I missed your previous reply :))
does it mean not clear all in the script?

Cheers,
Huy

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

Turn off mesh topology cleaning and error checking by setting the name value argument cleanup --> 0.
mshopts = meshgen('ef',fh,'bou',gdat,'cleanup',0);

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Thank you Keith,

Yes.. using cleanup = 0, the hole also disappeared!

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

And this was with the original setup that produced the hole?

Could you please send the mesh when you did not apply the cleanup? I'd like to run some tests with it.

from oceanmesh2d.

huyquangtranaus avatar huyquangtranaus commented on May 28, 2024

Hi Keith,

Unfortunately, I can't share files to run my case as there are the licensed bathymetry data for our project attached to it in order to run the mesh. However, as I have seen this issue somewhere before, so I will revisit some meshes I have done which can be shared with you. I will email you when it ready.... Also I could also and some files in examples very soon... Stay safe! Cheers,

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

from oceanmesh2d.

Jiangchao3 avatar Jiangchao3 commented on May 28, 2024

Hey Huy,

Just to clarify why we did not support xyz data from the beginning of the development of this tool is primarily because we do not want to build a mesh to build a mesh.

In the case of the unstructured xyz data, the only way to use this data for mesh generation is to form a TIN (triangulated irregular network) which is often a Delaunay triangulation. There are several downsides to doing this:

  1. Storage of the TIN is memory expensive
  2. Query time is significantly slower than a structured grid.
  3. Algorithmic complexity is more complex with a TIN. For example, the meshgen/private/smooth_outer.m relies on the topology of the structured grid to do the smoothing of nested sizing functions quickly.

and another point that we considered:

  1. Most available data are already DEMs placed on structured grids.

In my experience, survey data (xyz) tend to be less reliable.

And you point out, in your area(s) of interest you could create a structured grid and naively interpolate the xyz to the structured grid creating a DEM in a NETCDF file format. This could be done at several length scales to avoid the memory bottleneck that is inherent to structured grids. And finally, this (memory bottleneck w/ structured grids) is exactly why we developed the mutliscale meshing technique that allows nesting of several sizing function and largely disparate horizontal length scales.

Hi @@krober10nd and @huyquangt

Thank you very much for the discussion above, and it provided me with a good idea to solve my problem.

I am trying to build my own mesh with the Oceanmesh2d. I have the same problem as Huy, the bathymetry data I have obtained is also in the form of xyz scatter points. According to Roberts' suggestion, I should creat a structured grid and then interpolate the xyz to the grid creating a DEM in a NETCDF file format. However, there are various software or codes to do this work, as the following website shows: http://www.robertschneiders.de/meshgeneration/software.html#automesh2d. I have no idea to choose.

I want to know which tool can quickly and efficiently generate structured grids, so that I can continue to complete the interpolation and finally use it for the generation of unstructured grids with Oceanmesh2d. Can you recommend it for me? I will appreciate it very much.

Best wishes
Jiangchao

from oceanmesh2d.

krober10nd avatar krober10nd commented on May 28, 2024

So the way I've done in the past is to use grass with a weighted interpolation. See the section about sparse interpolation here https://grasswiki.osgeo.org/wiki/Interpolation then I export to a raster in netcdf format.

Maybe @HamishB can help out as he is one of the programmers of modules in GRASS.

from oceanmesh2d.

Jiangchao3 avatar Jiangchao3 commented on May 28, 2024

thanks very much, I have heard of this software, but have not used it. Let me have a try.

from oceanmesh2d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.