You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wei Ji, the fact is that GMT can already read them (see gmt_ogrread.c) but it lacks the ability to convert the data into its internal data structures. So in practice this feature is not yet accessible. Except from Julia where I do the data parsing in the Julia side.
Just following up on this because I'm working on a PR at GenericMappingTools/pygmt#1000. What is required to convert GeoJSON (or any OGR format) data to GMT's internal data structures? I had a read through #3013 again but couldn't really understand what needs to be done.
Thought I'd give some test cases too (remove the .txt extension after downloading):
gmt info data.geojson -C
# gmtinfo [ERROR]: No data columns to work with - exiting
# gmtinfo [ERROR]: Data file only has trailing text. GMT expects numerical columns followed by optional trailing text
Wei Ji, #3013 is only marginally related to support reading all the OGR formats. It's something we need if we want to keep information about geometries but we could live without it. The big issue is that the GMT IO is complicated and by GMT's internal data structures I mean having to do programming like this and below. That is, to get the data from GDAL and translate it to fill all of those Dataset->table, Dataset->Segments, ...
Should we reconsider this feature request, considering that GeoJSON is a commonly used format?
Ideally we should read the GeoJSON file and convert it to GMT's internal data structure, as mentioned above, but it's technically challenging. Shapefiles are supported by converting shapefiles to OGR_GMT format via ogr2ogr calls. The same approach can be applied to GeoJSON files. I've submitted a PR at #8719.
Activity
joa-quim commentedon Dec 23, 2020
Wei Ji, the fact is that GMT can already read them (see
gmt_ogrread.c) but it lacks the ability to convert the data into its internal data structures. So in practice this feature is not yet accessible. Except from Julia where I do the data parsing in the Julia side.weiji14 commentedon Mar 5, 2021
Just following up on this because I'm working on a PR at GenericMappingTools/pygmt#1000. What is required to convert GeoJSON (or any OGR format) data to GMT's internal data structures? I had a read through #3013 again but couldn't really understand what needs to be done.
Thought I'd give some test cases too (remove the
.txtextension after downloading):data.gmt.txt
data.geojson.txt
joa-quim commentedon Mar 5, 2021
Wei Ji, #3013 is only marginally related to support reading all the OGR formats. It's something we need if we want to keep information about geometries but we could live without it. The big issue is that the GMT IO is complicated and by GMT's internal data structures I mean having to do programming like this and below. That is, to get the data from GDAL and translate it to fill all of those
Dataset->table,Dataset->Segments, ...joa-quim commentedon Mar 5, 2021
And BTW, in Julia I get this
joa-quim commentedon Mar 16, 2024
This is a know issue that needs a more general approach.
seisman commentedon Apr 23, 2025
Should we reconsider this feature request, considering that GeoJSON is a commonly used format?
Ideally we should read the GeoJSON file and convert it to GMT's internal data structure, as mentioned above, but it's technically challenging. Shapefiles are supported by converting shapefiles to OGR_GMT format via
ogr2ogrcalls. The same approach can be applied to GeoJSON files. I've submitted a PR at #8719.anbj commentedon Apr 23, 2025
I agree - but doesnt this apply to all formats not supported by GMT, but supported by ogr2ogr?
Why not do this with all formats understood by ogr2ogr?
anbj commentedon Apr 23, 2025
Maybe we should remove support for shapefiles instead.. http://switchfromshapefile.org/.
joa-quim commentedon Apr 23, 2025
We could add more (gpkg for instance) but I'm not particular proud in this GMT solution and a bit reluctant in advertising it for more formats.