Interpreting shape parts

Home Forums Natural Earth Map Data Physical Vectors Ocean Interpreting shape parts

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3482

    marcelocantos
    Participant

    (I’m a novice when it comes to dealing with shapefiles, so please excuse a possibly dumb question…)

    I’m trying to render an ocean bitmap using the ocean shapefile, but I’ve noticed that it contains overlapping parts, and simply rendering each part as a filled polygon fills the entire region. It doesn’t leave islands such as Australia punched out of the bitmap. How do I identify which shapes to interpret as “ocean” and which ones are “holes” in the ocean (i.e., land)?

    In case it’s of any relevance, I use pyshp to read the files.

    #4261

    Nathaniel
    Keymaster

    Can you post an example image?

    #4262

    marcelocantos
    Participant

    I’ve uploaded an image at http://oi40.tinypic.com/690pk6.jpg. It contains (zero-based) shape 41 from 10m_ocean, which represents parts of the Indian and South Atlantic Oceans around Southern Africa. Africa, which extends outside the zone, is black. However, Madagascar, which should also be black is filled in, since my code simply fills in all the shapes, assuming they all represent tracts of ocean. How do I infer that the parts for Madagascar and the surrounding islands represent tracts of land, not ocean?

    This only just occurred to me now: should I simply draw all the polygons together, with an even-odd rule, or something similar?

    #4263

    Nathaniel
    Keymaster

    Yes, even-odd is normal for SHP files. You’re seeing the ring bits draw. Now you just need to wind them.

    #4264

    marcelocantos
    Participant

    Thank you for confirming this, Nathaniel. I was amazed at how difficult it is to locate drawing libraries that apply the even-odd rule, but I eventually managed to get OpenGL’s tessellation routines to perform the necessary work, and the result was perfect!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.