I'm going to plot some positions of ships, and thus see which areas (out at sea) where there is no vessels, however, if I do this in an ordinary geographical area defined by a square, all the land area will be defined as an area without ships. This is ofc true, but how do I avoid it?

I have lots of lat/long coordinates of ship positions, and are primarily doing this in Python, but don't worry, a pseudocode will suffice.

  • 1
    If you're not using any GIS software and data then you're pretty much hosed. With GIS tools and data the task is trivial.
    – Vince
    Commented Jun 26, 2015 at 13:18

1 Answer 1


@Vince is right, this would be trivial in GIS software. But if I can assume you are always working in the same area and you have access to GIS to get started:

A raster data file is essentially an array of data with a few lines of header on top. If you build a "land mask" you will end up with an array of presence/absence of land (or water, depending on which direction you build the mask from). Once you have this layer for your study area you can manipulate it in python by calling it as a numpy array.

You would then need to create a "ships present" raster using your lat/long points. These will be generalized down to the resolution of your land mask layer, but that's the trade off you choose between processing time and quality of result.

Using a logical operator you can then determine which water cells are not occupied by ships.

  • Thank you for your answer (I do not hold enough points to upvote). The reason for my Python exclusivity is that the points are saved in a SQLite database, and all other computations is done in Python. Thank you again for your insight.
    – bjornasm
    Commented Jun 26, 2015 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.