Where is the middle of Brazil?

310 views
Skip to first unread message

JuciÊ Andrade

unread,
Nov 30, 2019, 8:30:33 PM11/30/19
to golang-nuts

When I was a kid I asked my teacher why my country capital had been moved from Rio de Janeiro to Brasilia. She said the reason was Brasilia is right in the middle of our territory, that way our president could take care of our entire country more effectively. I accepted that answer. Many years later, contemplating a map, I doubted Brasilia is right in the middle.


Where is the middle of Brazil?


            MD5                             SHA-1

4c021557d057327f2977dd739b67da6b b3913154ca0c5f48f3555c536fc987322169e607 ihavetheanswer.txt

Michael Jones

unread,
Nov 30, 2019, 8:44:01 PM11/30/19
to JuciÊ Andrade, golang-nuts

14°35'03.5"S 53°03'51.3"W
-14.584305, -53.064239

Not an official national answer, just my own. (That said, I invented Google Earth's technology and was the CTO of Google's Geo team from its inception...so I have some minor street cred in such things. ;-)

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com.


--
Michael T. Jones
michae...@gmail.com

andrey mirtchovski

unread,
Nov 30, 2019, 8:48:45 PM11/30/19
to JuciÊ Andrade, golang-nuts
i think JuciÊ wants us to crack the md5. i'm fresh off a CTF
competition so i don't have any more resources to throw at warming the
universe and increasing entropy, unfortunately...
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CALoEmQwBJudMkah7eWRG9mhfCLjuJM%2B42LGdnP1BEAayH57EiA%40mail.gmail.com.

Michael Jones

unread,
Nov 30, 2019, 8:57:32 PM11/30/19
to andrey mirtchovski, JuciÊ Andrade, golang-nuts
Sigh. I overlooked the riddle and took it as a straight question. Typical for me all my life. (once considered making a T-shirt saying "answers rhetorical questions"). Mild chagrin here... (P.S. sorry for bad typing. Keyboard's B and SHIFT keys are roken broken.)

Rodolfo Azevedo

unread,
Nov 30, 2019, 9:32:55 PM11/30/19
to golang-nuts
Bixo vai dormir, isso né hora pra loucura não...  hehehehehe

Liam

unread,
Dec 1, 2019, 12:40:00 AM12/1/19
to golang-nuts
"considered making a T-shirt saying "answers rhetorical questions"

Thank you for the LOL :-)

On Saturday, November 30, 2019 at 5:57:32 PM UTC-8, Michael Jones wrote:
Sigh. I overlooked the riddle and took it as a straight question. Typical for me all my life. (once considered making a T-shirt saying "answers rhetorical questions"). Mild chagrin here... (P.S. sorry for bad typing. Keyboard's B and SHIFT keys are roken broken.)

On Sat, Nov 30, 2019 at 5:48 PM andrey mirtchovski <mirtc...@gmail.com> wrote:
i think JuciÊ wants us to crack the md5. i'm fresh off a CTF
competition so i don't have any more resources to throw at warming the
universe and increasing entropy, unfortunately...

On Sat, Nov 30, 2019 at 6:43 PM Michael Jones <michae...@gmail.com> wrote:
>
>
> My answer is this place.
> 14°35'03.5"S 53°03'51.3"W
> -14.584305, -53.064239
>
> Not an official national answer, just my own. (That said, I invented Google Earth's technology and was the CTO of Google's Geo team from its inception...so I have some minor street cred in such things. ;-)
>
> On Sat, Nov 30, 2019 at 5:30 PM JuciÊ Andrade <oju...@gmail.com> wrote:
>>
>> When I was a kid I asked my teacher why my country capital had been moved from Rio de Janeiro to Brasilia. She said the reason was Brasilia is right in the middle of our territory, that way our president could take care of our entire country more effectively. I accepted that answer. Many years later, contemplating a map, I doubted Brasilia is right in the middle.
>>
>>
>> Where is the middle of Brazil?
>>
>>
>>             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 golan...@googlegroups.com.

>> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/850ccd64-5c85-4c91-9438-bd28c4320b8a%40googlegroups.com.
>
>
>
> --
> Michael T. Jones
> michae...@gmail.com
>
> --
> 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 golan...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CALoEmQwBJudMkah7eWRG9mhfCLjuJM%2B42LGdnP1BEAayH57EiA%40mail.gmail.com.

--
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 golan...@googlegroups.com.

JuciÊ Andrade

unread,
Dec 1, 2019, 4:39:14 AM12/1/19
to Liam, golang-nuts
Michael, let me tell you I feel very much honored because you answered my question right away. Thank you very much. To be honest, that was not exactly the position I was after. Maybe my question should have been more clear. To be effectively in the middle of our territory, the position would divide Brazil so that half of our country area would be to the north and half to the south, while half would be to the west and half to the east.

Andrew, the solution doesn't involve cracking the digest at all. As I said above, maybe I should have been clearer in my question. That digest is only to prove I already have the solution. In case someone challenges me to show it I can send to this person a file that produced the digest.

Rodolfo, I am not crazy, man, LOL. That is a programming challenge.

Thank you my friends for your attention. Have a nice day.

Dan Kortschak

unread,
Dec 1, 2019, 4:45:23 AM12/1/19
to JuciÊ Andrade, Liam, golang-nuts
This looks like a job for geocrypt :)

https://godoc.org/github.com/kortschak/geocrypt

JuciÊ Andrade

unread,
Dec 7, 2019, 8:30:12 AM12/7/19
to golang-nuts
OK, people. It has been nearly a week since I left the programming challenge here, so let me show my approach.

First, let me tell you guys I sent the aforementioned challenge to a few programming groups and it went like this:
. some very knowledgeable people in this group tried to find a solution. That made me proud, as I told you;
. brazilian C++ group: a bunch of guys fiercely tried to solve the problem and a few succeeded to some extent;
. brazilian Go group: too small a group, people prefer interacting thru Slack. So, no responses;
. Rust official users group right away classified my message as "off topic", hide it, and not so politely said I should "post it elsewhere";

My next message will show the answer. So, if you wanna keep trying please stop here.


JuciÊ Andrade

unread,
Dec 7, 2019, 8:34:13 AM12/7/19
to golang-nuts
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:


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:

The github repo:

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

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

Jan Mercl

unread,
Dec 7, 2019, 9:30:42 AM12/7/19
to JuciÊ Andrade, golang-nuts
On Sat, Dec 7, 2019 at 2:34 PM JuciÊ Andrade <oju...@gmail.com> wrote:

> 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.

This method resembles determining the CG, but only very approximately.
How is your "middle" actually defined?

JuciÊ Andrade

unread,
Dec 7, 2019, 11:26:32 AM12/7/19
to golang-nuts
Hi, Jan.

As you can imagine, there are several ways to define "middle". So, to get rid of the ambiguity I picked this one: "the position would divide Brazil so that half of our country area would be to the north and half to the south, while half would be to the west and half to the east."

JuciÊ Andrade

unread,
Dec 7, 2019, 11:31:56 AM12/7/19
to golang-nuts
If one wants to improve precision she may use a bigger map.
The resulting position would be the same, only more accurate.

andrey mirtchovski

unread,
Dec 7, 2019, 11:38:27 AM12/7/19
to JuciÊ Andrade, golang-nuts
this is quickly becoming off-topic. however, from
https://en.wikipedia.org/wiki/Geographical_centre:

"As noted in a USGS document "There is no generally accepted
definition of geographic center, and no completely satisfactory method
for determining it."[1]

In general, there is room for debate around various details such as
whether or not to include islands and similarly, large bodies of
water, how best to handle the curvature of the Earth (a more
significant factor with larger regions) and closely related to that
issue, which map projection to use."
--
[1]: https://pubs.er.usgs.gov/publication/70039437

On Sat, Dec 7, 2019 at 9:32 AM JuciÊ Andrade <oju...@gmail.com> wrote:
>
> If one wants to improve precision she may use a bigger map.
> The resulting position would be the same, only more accurate.
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/270e41e1-5dd5-4351-be8a-1ba683bdd6a8%40googlegroups.com.

Michael Jones

unread,
Dec 7, 2019, 1:13:24 PM12/7/19
to andrey mirtchovski, JuciÊ Andrade, golang-nuts
...now this is something that I know a great deal about (resulting in label placement in Google Maps and Google Earth, discussions with colleagues in USGS, the US Census Bureau, DoD, the United Nations GGIM experts group, UK Ordnance Survey, Survey of India, etc.) 

Indeed most of the issues Andrey shared are significant, though the final note about "which map projection to use" is very odd. The "geographic center" however one might define it, is a geographic concept concerning place and not a cartographic concept concerning boundaries after projection. The computation only has its natural meaning on the globe.

The typical choice is the lat-lon midpoint of the contiguous landmass (easy) or major aggregate areas (more handwavy) such as would be the case in Michigan in the United States. Note that the link shows the two major areas as well as a large Isle Royale National Park to the north. The question being to include it or not. The same issue arises with Stewart Island in New Zealand.

There is a pragmatic issue as well--the center may not be in the geographic entity at all! Imagine a 'C' shaped land. Such a land mass will have a center, computed by any reasonable means, that is in the empty center and not in the surrounding ring. Does this happen? Yes, thousands of times. Note the placement of "Molokini Shoal Marine Life Conservation District" compared to the "Molokini" point of interest label--any "center" is along the line segment between these yet most are offshore. Same in Ecuador with its Galápagos Islands, where the midpoint is in the ocean. (The same thing happens with 'L' shaped regions, such as Florida in the United States, and hook or curved places including Cuba, Laos, Vietnam, and Norway.)

The story of Richard Feynman's travels to the center of Asia is chronicled in Ralph Leighton's delightful book "Tuva or Bust." (Note that at least three places are claimed as the center of Asia.) 

JuciÊ Andrade

unread,
Dec 7, 2019, 2:04:35 PM12/7/19
to golang-nuts
Yes, I understand it is impossible to chose the "correct way" of determining the center. This week I learnt there are at least a handful of places claiming to be the "center" of Brazil, with monuments and whatnot.

The search for a solution is an interesting endeavor per se. Programming is supposed to be fun after all.

Several things amazed me:
. the variety of proposed methods. A guy in Germany collected the position and area of every county in Brazil and proceeded with the math. Another guy proposed to draw a map on carton paper, cut it and find the center of gravity. Etc;
. the rich geographical data available for anyone to use;
. the language packages and libraries to handle geographical data;
. the enviable knowledge some people have on the matter;
. the willing to learn a new topic just for the sake of it;
. the unwillingness to learn a new topic just for the sake of it;

Anyway, it was a delightful experience. Thanks

Marcin Romaszewicz

unread,
Dec 7, 2019, 6:12:28 PM12/7/19
to JuciÊ Andrade, golang-nuts
As a bonus challenge, try to compute the population center of Brazil :) One way of finding the center is minimizing the integral of all distances to a point, but for population, these points now have weight.

Like Michael above, I spent years working on Google Earth, and the code running in the latest Earth client app for doing label placement, polygon placement and center finding is my code. It's fun stuff!

-- Marcin



--
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...@googlegroups.com.

JuciÊ Andrade

unread,
Dec 11, 2019, 4:56:43 PM12/11/19
to golang-nuts
A Brazilian friend from the C++ group accepted your challenge and found the population center. It's here:

Reply all
Reply to author
Forward
0 new messages