1
$\begingroup$

I have this map showing the geography of Europe (below), and I wish to convert it to a matrix in python that would be a 2D approximation of this image where 0's would represent the ocean and 1's would represent landmasses. I plan to subsequently to do a biased random-walk on the resulting grid where walkers are more likely to travel on land than water. Right now I just need help converting this image to 0's and 1's as mentioned, what would be the most straightforward way to do this in Python?

The resolution of the resulting matrix representation of 0's and 1's does not need to astoundingly high, although I would like to distinguish between high and low elevations (presumably I would need to account for higher elevations by maybe noting them as entries of 2's in the matrix representation).

enter image description here

$\endgroup$
3
  • $\begingroup$ Do you have the color map for this image? $\endgroup$
    – nicoguaro
    Commented Jun 16, 2015 at 2:27
  • $\begingroup$ Unfortunately not. I just found this image somewhere off google. $\endgroup$
    – Loonuh
    Commented Jun 16, 2015 at 2:29
  • $\begingroup$ I think that this color mapping is common. So you can compute the inverse mapping as well. $\endgroup$
    – nicoguaro
    Commented Jun 16, 2015 at 2:31

1 Answer 1

1
$\begingroup$

The picture you have is a poor starting point because it shows rivers as blue even though they are typically well above sea level and are, therefore, most likely to be considered part of the "land" region.

I think you'd be better off using the original data set from which maps such as these were generated. Data that has the information you're looking for can, for example, be obtained from the SRTM data set for which the wikipedia site also has links to the place where you can get the data set. SRTM data is already rastered and so should serve your purpose much better: every topography point with an elevation greater than zero will get a one in your notation, every topography point with an elevation of zero or below will get a zero. (Unless you take the few depressions such as the Dead Sea or Death Valley into account, which are part of land but lie below sea level.)

$\endgroup$

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.