Skip to content

Implement the ogrread solution #453

Closed

Description

@joa-quim

Recover the bit bellow from #445. This work rises questions that we need to discuss. For example right now I would like to know what's better way to transfer the data points into the nested GMT structs. As is or in a *xyz single array?

Start the work of reading the OGR vector formats directly via GDAL. The gmt_ogrread() uses a design inherited from it's Matlab ancestor in Mirone and hence it's structure must be improved to fit better with the GMT needs. But as it is we can already load data directly. We still need to write code to parse its contents and feed the corresponding GMT data structures, so as it is we can't use it yet but as a proof o concept I added one such type of function parser in Julia that converts the gmt_ogrread() output into a GMTdataset. It works like this.

# Create an API session
API = GMT.GMT_Create_Session("GMT", 2, GMT.GMT_SESSION_NOEXIT + GMT.GMT_SESSION_EXTERNAL + GMT.GMT_SESSION_COLMAJOR);

# Read a shape file directly from ... wherever it is
ex = GMT.gmt_ogrread(API, "/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.shp");

# Plot it
plot(GMT.ogr2GMTdataset(ex), show=1, fmt=:png)

gmtjl_tmp

Activity

  1. PaulWessel commented on Mar 1, 2019

    @PaulWessel
    Contributor

    Since this is clearly work in progress, would not a WIP branch be much better than adding #if etc in master?

  2. joa-quim commented on Mar 1, 2019

    @joa-quim
    MemberAuthor

    The trouble (for me) with it is that with time the branch will start to diverge more and more from master and become boring to always change branch/rebuild to allow me to use it from Julia. As is, it only includes two extra functions in master that are not yet used.

  3. PaulWessel commented on Mar 1, 2019

    @PaulWessel
    Contributor

    Perhaps, but it takes 1-2 clicks to merge any change to master into the branch. I do that all the time with the nicerectclip branch until it is ready. At some point you will need to make changes that cannot be under #if - #endif or the code with all those statements gets unreadable.

  4. joa-quim commented on Mar 1, 2019

    @joa-quim
    MemberAuthor

    Ah, but the code is not #ifdefed the #if GDAL_VERSION_MAJOR >= 2 only protects for breaking the build on the Ubuntus of this life.

  5. leouieda commented on Mar 1, 2019

    @leouieda
    Member

    I kind of agree with @PaulWessel that it's better not to merge things that are still not "done", documented, or covered by tests. This kind of thing has a way of biting us in the ass later on.

    only protects for breaking the build on the Ubuntus of this life

    With Ubuntu it might be a very long life indeed 👴

  6. joa-quim commented on Mar 1, 2019

    @joa-quim
    MemberAuthor

    As I said in the beginning, I'm doing this on GMT and Julia at same time. Sure it can be done from a branch, but if the level of cumbersomeness raises above the threshold ...

    BTW, what about my question in first paragraph of first post?

  7. PaulWessel commented on Mar 1, 2019

    @PaulWessel
    Contributor

    OK, in regards to first paragraph: Ideally, you would return a GMT_DATASET struct since you may need to assign trailing text from aspatial items.

  8. joa-quim commented on Mar 1, 2019

    @joa-quim
    MemberAuthor

    But that's exactly the work that remains to be done. If I had that already, then the work would be finished. One of the issues is that the OGR features model has a lot more that we can encode in GMT_DATASET. I just checked (perhaps too quickly) that if we read a .gmt file, the aspatial info does not show up in the GMT_DATASET. At least when it lands in Julia (ML would be the same).

  9. PaulWessel commented on Mar 1, 2019

    @PaulWessel
    Contributor

    I think stuff ends up in the OGR structures hooked to the DATASET.

  10. joa-quim commented on Mar 1, 2019

    @joa-quim
    MemberAuthor

    GMT_DATASET has no provision for attribute names for example. That's why I'm looking at -L -I or -T in header lines for alternatives to storing them. #213 seems related to this.

  11. PaulWessel commented on Mar 1, 2019

    @PaulWessel
    Contributor

    Unless we change the entore GMT/OGR machinery (which we probably cannot) I think you have to see what happens when OGR data is read and what structures are filled to hold the attributes names and types. This is in a GMT_OGR structure in the GMT main struct and then data are stored in similar struct per segment I think. These are filled in by the two ogr parsers in gmt_io.c

  12. stale commented on Mar 31, 2019

    @stale

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions.

  13. added
    stale
    on Mar 31, 2019
  14. added
    longterm
    and removed
    stale
    on Mar 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    longterm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions