Comments (22)
from mb-system.
Dave, just let me add that I'm sad that you decided to go into the C++ way. C++ is simply no good neighbor. Now the possibility of having the MB programs adapted to be GMT modules. like mbcontour for example, and hence be easily accessible from other languages like Matlab or Julia is definitively gone.
from mb-system.
from mb-system.
Dave,
All GMT modules end up as shared libraries. Shared libraries in C++ suffer from the name mangling issue and are not callable by other languages (not even C). That is why C++ is no good neighbor.
Regarding the GeoTiffs, sorry I don't get. grdimage
does that since the option to write GeoTiffs was added many years ago.
from mb-system.
I think Dave is particular about what is written to the geotiff. THe easy solution would be to rip out most of mbgrdtiff and simply do a module call to GMT_grdimage and return a GMT_IMAGE, which mbgrdtiff can then write out as it sees fit.
from mb-system.
from mb-system.
Ok, this is a simple example with geotiff grids. Tried to project it to make it more clear but some shit in propagating the proj coords metadata is happening
grdimage
does not create geotiffs with other than the image. I.e., not images with vector lines. But psconvert
does it.
grdmath -R0/20/30/50 -I0.1 X Y MUL = lixo.grd
grdedit lixo.grd -J+proj=longlat
grdconvert lixo.grd lixo.tif=gd:GTiff
gdalinfo lixo.tif
Driver: GTiff/GeoTIFF
Files: lixo.tif
Size is 201, 201
Coordinate System is:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
...
from mb-system.
from mb-system.
Dave, you'll excuse me but I don't remember that we have done that failed test. I will be making a PR in GMT to fix some bugs related to the non-propagation in some cases of the CRS info when writing either nc or GTiff files. But that is a separate issue. With those fixes one can do
(But maybe it will work for you because the bugs occurred when one uses the -J+proj=utm+zone=32
and the necessary space before +zone
was not introduced in some part of the code)
gmt grdmath -R0/20/30/50 -I0.1 X Y MUL = lixo.grd
gmt grdproject lixo.grd -J"+proj=utm +zone=32" -Glixo_utm.grd
gmt grdconvert lixo_utm.grd lixo_utm.tiff=gd:GTiff
gmt grdimage lixo_utm.grd -JX8c -I+d -Ba -BWSen -P -K > gimg_tif.ps
echo 10 40 | mapproject -J"+proj=utm +zone=32" | gmt psxy -JX8c -Rlixo_utm.grd -Sc1c -Gwhite -O -K >> gimg_tif.ps
gmt grdimage lixo_utm.tiff -JX8c -I+d -Ba -BwSen -X8.5c -O -K >> gimg_tif.ps
echo 10 40 | mapproject -J"+proj=utm +zone=32" | gmt psxy -JX8 -Rlixo_utm.tiff -Sc1c -Gwhite -O -K >> gimg_tif.ps
gmt grdimage lixo_utm.grd -I+d -Agrdimg.tiff # This is a shaded GTiff IMAGE, not a GRID
gmt grdimage grdimg.tiff -JX8c -X-8.5c -Y8.5c -Ba -BWseN -O -K >> gimg_tif.ps
echo 10 40 | gmt mapproject -J"+proj=utm +zone=32" | gmt psxy -JX8c -Rgrdimg.tiff -Sc1c -Gwhite -O >> gimg_tif.ps
from mb-system.
PR submitted in GMT. But with this we hijacked the original issue. Sorry.
from mb-system.
BTW, I am this close to having redone mbgrdtiff via a call to GMT_grdimage.
from mb-system.
I have hacked up a new version of mbgrdtiff.c that uses a call to GMT_grdimage to do the work. Since I am unable to use your github version directly [there must be something that is brew-specific about the configure process], I did this with 5.7.5. Since the new version adds a few new things and deletes most of the old grdimage-lookalike code I think you can easily do this with what is attached and insert into your master version. Here are the steps:
- The main differences is a new static function called mbgrdtiff_get_image that takes your options and builds a command string and then calls grdimage and receives the image. Just insert that code into your mbgrdtiff.c above the main function.
- Instead of the old image calculations, just keep the new call to that new function and the next three lines, i.e., everything between
/*---------------------------- This is the mbgrdtiff main code ----------------------------*/
and
/*------------------------- Write out the GeoTiff and world files -------------------------*/
- Compile with -Wall and remove all the unused variables. I tested this and both the new and old 5.7.5 mbgrdtiff gives me the same tiff file.
One caveat is that this requires GMT 6.x since I had to fix some issues in grdimage to make this work.
from mb-system.
Note the old mbgrdtiff lists options in the usage message that are not available in that module (-B, -K, -P, -X, etc). I deleted all of those.
Also, looks like 5.7.5 version crashes since it is accessing Grid_orig[0] in a fprintf (stderr message long after Grid_orig has been destroyed.
from mb-system.
Ok, thanks. I will try it out. Jumping back to the beginning of the thread, I've duplicated the build error you found when building with prerequisites installed through MacPorts.
from mb-system.
And I fixed the build error that died at mbsvpselect. I needed to add libproj_CPPFLAGS to AM_CPPFLAGS in src/utilities/Makefile.am, and then resconstruct the build system. This fix has been merged into master.
from mb-system.
Great, I will give it a try. if that works, would you want me to submit a PR for the tiff stuff instead?
from mb-system.
Does this work with the GMT 6.0.0 release?
from mb-system.
No, since it doing this I found a bug. This was the first time we called GMT_grdimage and wanted a memory reference to an image back, so had not been tested before. Minor bug, but not in 6.0.0.
from mb-system.
So, no, don't put it into a PR. You've given me the code - I need to wrap it in conditionals so we can still build and work with GMT 6.0.0, and for the time being, GMT 5.4.5. I'll try to do it moderately cleanly. I take it the required mods to GMT are merged into your master branch, correct?
Thanks. This is definitely an improvement.
from mb-system.
OK, that is fine. Yes, the fix has ben committed to our master branch. Let me know if anything fails.
from mb-system.
from mb-system.
Dave, just let me add that I'm sad that you decided to go into the C++ way. C++ is simply no good neighbor. Now the possibility of having the MB programs adapted to be GMT modules. like mbcontour for example, and hence be easily accessible from other languages like Matlab or Julia is definitively gone.
I strongly disagree with your blanket statement about C++.
C++ doesn't impact the ABI if used from a C API. e.g. gdal and lots of other open source projects. IMHO, C++ ( > 11 ) makes for much more robust internals to libraries. I did nothing with C++ in MB-System that impacts the ABI. If it was up to me, all of MB-System would be C++ >= 17 with a C APIs for basic use by others. The reliability and standardization of basic functionality is such a huge win.
from mb-system.
Related Issues (20)
- Unit test failures for Ubuntu Xenial build on Travis-CI HOT 5
- OSRExportToProj4 should not allocate a GMT variable and let GMT free it. That's a Boom on Windows. HOT 3
- mblevitus is broken HOT 3
- mblist command doesn't like filenames with spaces
- Problem compiling Pre-release 5.7.6beta38 HOT 3
- Data corruption while reading Kmall data with version 0 #MWC datagrams HOT 4
- Format of gridded data
- MB System installation on Mac OS Big Sur HOT 3
- configure and build mb-stystem on headless server with no X dependencies HOT 3
- mb_rt raytrace trajectory HOT 3
- Time conversion issue
- Raytracing integrated range
- s7k datafile with 1024 beams HOT 2
- Problem compiling MB-System: fatal error: gmt_common_byteswap.h: No such file or directory HOT 8
- Add mbgrd2gltf standalone program HOT 5
- configuere error on linux (ubuntu) can't find tirpc/rpc/types.h HOT 22
- Unable to apply time latency to kmall/mb261 survey data with mbpreprocess HOT 6
- 5.7.9 (beta) and Debian 11 HOT 1
- MB-System PDAL - mbio (ro) driver update
- Cannot install MB-System using home-brew HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mb-system.