I am pretty sure there are other ways to do it, but the method I devised is 
simple and produces a good enough result. If somebody can put a hole in my 
reasoning, feel free to do so.

All the info I need are in a map, OK? So I downloaded a map from the 
Internet. I choose a map that shows only the territory I am interested in 
and nothing else:

http://www.temasactuales.com/temasblog/wp-content/Images/mapa_do_brasil.gif

The method goes like this: I scan the image counting every pixel that is 
not background color. It gives my territory area. Then I divide that by 2 
to obtain half the area.

I scan the image again from top to bottom, stopping when I reach half the 
area. I draw a horizontal line dividing north and south. Finally I scan the 
image from left to right stopping at half area and draw a vertical line 
dividing east from west. The point I am interested in is in the 
intersection of those two lines.

My Go program has some small optimizations so that I don't have to actually 
scan the image so many times, but the idea is the same.

The resulting image:
https://drive.google.com/file/d/163K79BWKRTmI3BOIMUsPf7ziISwt-R3z/view?usp=sharing

The github repo:
https://github.com/jucie/geomedian

The file I used to calculate the digest in the first message is attached.

Thank you, my friends, I hope you enjoyed the challenge.

            MD5                             SHA-1

------------------------------

4c021557d057327f2977dd739b67da6b b3913154ca0c5f48f3555c536fc987322169e607 
ihavetheanswer.txt

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4af4cd54-5994-49b4-9f48-e9cfd3e7271a%40googlegroups.com.
The geographic median of Brazil is in Para's south region, as can be verified 
using my program geomedian, available in github.

Reply via email to