Showing posts with label Geography. Show all posts
Showing posts with label Geography. Show all posts

Tuesday, January 5, 2016

Travels Visualized

If you've read my post on my Data visualization of Facebook data, you may have learned that I have this odd hobby of playing with personal data. However you are unlikely to know that I have kept a spreadsheet of where I have spent every night since 2008. But it's true, and it hasn't even been remotely onerous. I have noted the date in which i entered a city and the date in which I left. I've kept the detail mainly to the city level, so there is no record of meanderings throughout urban bedrooms, if that had theoretically happened. There is no record of day trip cities I've visited without spending the night, so sorry Nara, Krebs and Brookline. I also did not stress about whether I reached a city before or after midnight - with the exception of red eye flights, if I flew from Hong Kong on a Friday night and reached my room in Taipei 2am Saturday morning, I recorded myself as spending Friday night in Taipei.

I started this list in the margins of my notebook in a Geography lecture in University College Dublin in the fall of 2008, mainly because I was bored in class. It was far more interesting for me to think about the places I'd traveled to in that very epic year of 2008. Through memory I filled in most of the dates, and eventually I went through my gmail archives and filled in my whole year. It would not be possible for me to fill in 2007 and before because of lack of memory and records. But starting from that fall, I created a spreadsheet and it has survived 4 computers and is now safely on the cloud. I started this blog in 2008 and I feel that I became a very different person starting from that year so I find this data very fitting.

For me, trawling back through this data just brings me pure joy. I had not planned on ever analyzing the data as I am doing now - just scrolling through it had been enough. I'm not sure if anyone else would enjoy it so much going through their own life, and they certainly wouldn't find it so interesting going over mine. But these data visualizations directly take me back to trips I had forgotten.
In terms of the visualization nitty gritty, I had a lot of cleaning up to do. I hadn't even heard of R when I began these records, so I didn't really have a thought to how I should format the data or the scheme of the database in technical speak.
Once I fixed name inconsistencies and date formatting, I decided to focus on the chronological part of my data first. I found the ten cities I'd spent the most time in, then realized many cities were tied and expanded the list to top 15. Without worrying about a y-axis at all, I plotted the dates I'd been in these cities and assigned a nice color palette to them.
And immediately I was pleased. As familiar with my own life story as I am, I could see a lot of stories in those dots. I was at first surprised to see what cities made it. Civate and Osaka are on there on the strength of one trip each, which were both for World's ultimate tournaments. Ultimate tournament trips to Manila are also clearly regular, spaced out evenly starting in 2012. My move from DC, where trips to New York and Newton (my hometown outside Boston) to Hong Kong in late 2011 is also quite obvious. My lengthier stays in Dublin and Beijing which are well-documented in this blog are also visible. Irregular trips to Shanghai, Taipei, Shenzhen and Bangkok pop up. Lastly, I may never spend another night in Newton after we sold our family home, and instead nights in the city of Boston show up instead.

These cities appear low to high in order of appearance (starting from 2008), which is really quite arbitrary. I played around with making the order completely random. I actually liked that better, because in the original version, all the long stays are at the bottom and the top seems very bare, giving the image a sense of imbalance.  My friend points out that at this point I enter data art, because the randomization serves no functional purpose. Here is that graph with even more cities.

Now this has more little stories and might be too cluttered. I don't think I could possibly fit all of my stops in there. Because I go back to places multiple times, I don't know how to provide a sense of chronological order to the cities. There isn't a sense in either graph really of many sequential trips.

Skipping this thought, I considered graphing the latitudes on the y-axis. As the data points were all geographic this was the logical next step. If you didn't recognize the names of these cities, the graph loses a lot of meaning. However, adding longitude and latitude coordinates was tricky. I hadn't been inputting that data in along the way, but the Maps package in R comes with a nice database of world cities. The database comes with population and coordinate information for just about every city of more than 40,000 people in the world (as of 2006). However the naming of some of the cities is bizarre, full of colonial-era names (Rangoon, Bombay), out-of-vogue spelling choices (Cracow, Soul), and a full pinyin rendering of Macau and Hong Kong, with Hong Kong being split into the Sai Kung, Kowloon and Hong Kong Island (xigong, jiulong and xianggangdao). Some of my travels had taken me to places of less than 40,000 people. For the names that didn't match, I didn't know of any better solution that editing all the names individually. If there is a more common sense laden database out there, please let me know. For the cities not on the database, I googled their coordinates. I'm not quite a good enough programmer to build a scraper to do this automatically, but I aspire to get to that level soon. Here's the same graph re-run with latitudes on the y-axis. I added in the names by hand where I saw fit, otherwise they'd bleed over each other.
This graph doesn't do much for me. It's very cluttered and it's hard to organize time and space coordinates together in my mind. The points give the illusion of coordinates, but they're not, they're only one dimensionally coordinates. It is interesting to see that so many of the places I've been are on the same latitude (Beijing is nearly the same as New York), and places that actually are near each other (Hong Kong and Shenzhen, Newton and Boston) now appear so on the map. And it's also cool to see that these cities range as south Bangkok to as north as Dublin, a thought I'd never made on my own. Still, I think there is limited use to this visualization attempt.

Well with all the coordinates in hand, it was time to put them on a real map. I've learned that with maps it's easy to control the size and color overlaid points. R has some in-built plotting functions, which I'd been using for 5 years, and they're pretty great. But people serious about data visualization seem to use a lot of ggplot2 and ggmap, packages developed by the Kiwi statistician Hadley Wickham, who should probably be knighted. I decided it was high time to learn some ggmap. Here's my first attempt:

This map visualization is much more of a classic representation and was equally delightful to me. I particularly liked the lack of borders in this version. It requires more deductive efforts in identifying all the points. I decided to color the points by the year that I first visited that point. Blue represents 2008 and takes up a lot of real estate. The size was set to the number of days I spent in each city. Note that the sizes are not scaled linearly, and in fact I haven't figured out how to control this properly. I actually am rather alright with the outcome though, otherwise Hong Kong and Washington, DC would drown out other cities. I could see more stories here, such as two separate trips to Europe. I could see the "outlier" travels of 2010 that took me to India and Peru. I saw two points from 2008 in western US and was confused as to what they might represent until I remembered I went to Las Vegas and Los Angeles many months apart that year. This truly shows the power of visualization, the ability to convey so much more in so little space. I could also see a bug in my data in this black dot in western America. Investigating further, I'd inputted the coordinates for Littleton, Colorado instead of Littleton, New Hampshire by mistake. Some of the years were also incorrect.

My second go at the map fixed these bugs and added borders just for kicks. I don't really like these large borders, which seem to drown out and minimize my destinations. But for the most part, I was very happy with this map. All I needed was a legend. Turns out this was way harder than I realized, because I had been using ggmap incorrectly this whole time. Hours of debugging later, I finally converted my years into factors and got this to popup.

As a conclusion, these Travels of Cal are about to get a lot more interesting. After 4 years and 3 months at Arup in Hong Kong, my last day will be January 8, 2016. I will be adding some data points in Southeast Asia and building on these visualizations. There's a greater purpose here than documenting my own life, rest assured.


Saturday, February 15, 2014

Geographic Analogies

For no reason at all, I am going to do a post examining analogies between geographic entities, where the relationship between two cities for example is compared to the relationship between two other cities. I will look at how the analogy makes sense and where it falls apart. I'm not entirely sure if there's anything to be learned from this exercise, but I think it should be fun. Very often you hear people call a place "The Paris of South America" or the "Harvard of the South," which means nothing except a guarantee that this city is not as beautiful as Paris nor the school as good as Harvard. Sometimes however, comparing two knowns to two unknowns can be very helpful in explaining regional dynamics.

Delhi is to Mumbai as Beijing is to Shanghai



How it works: 
Beijing and New Delhi are the capitals of the two most populous countries in the world, countries that share much in common just due to their innumerable citizenry. Both cities are immense and inland and contain much historical and cultural importance. Shanghai and Mumbai are the largest cities of their respective countries and are the economic capitals, with both on the coast. Shanghai and Mumbai both have stock exchanges, lots of finance and shipping and tall buildings. In contrast, Beijing and Delhi are centers of policy making.  The analogy holds under even historical scrutiny, as Delhi, while ages old, was for many years ruled over by Afghan and Turkic rules and came to prominence under the Turko-Mongol-Persian Mughal Dynasty. Beijing is also as old as time and the capital under Mongol rule during the Yuan Dynasty and under Manchu rule during the Qing.  Shanghai and Mumbai were never capitals of a united China or India, and are much younger cities with their histories more closely tied to colonialism. Shanghai historically spoke Shanghainese, related but different from Mandarin of Beijing, and people of Bombay historically spoke Marathi, related but different from Hindi of Delhi, yet in modern times you can get by with Mandarin in Shanghai and Hindi in Mumbai. The capital cities are also considered to have better universities than their financial city rivals.

How it falls apart: 
For starters, a lot of countries have a big capital city and an even bigger second financial city (Russia, Germany, Spain, US etc.) With China and India being such different countries, it's hard to get too extended with any analogies between them. Delhi has one of India's 3 metro systems and appears to have a better public transportation than Mumbai, which runs on a large but overcrowded rail system. Shanghai is considered the better developed Chinese city and arguably has less traffic issues. Delhi is considered much less of a party city than Mumbai, while Beijing is arguably more of a party city. And I haven't even mentioned how New Delhi is actually the capital city of India. The real flaw in the analogy though is that Mumbai is considered a city with soul and culture and an edge, the home of the thriving Bollywood industry. Please never mistake Shanghai for a city with a soul, Beijing is China's cultural capital, and China's  movie industry is not good enough to have a city associated with it. Also fun fact: Connaught Place is an area in both Delhi and Hong Kong.

United Kingdom is to Europe as Japan is to Asia

How it works: 
Both are island nations off the mainland of their respective continents, together bookmarking the Eurasia landmass. Isolated from the mainland, they both developed cultures quite distinct from the continental countries nearby and still sometimes find difficulty deciding to what extent to align themselves with the larger continent (i.e. UK not adopting the Euro, Japan and its disputes with China). Both countries have had extensive history of war with continental rivals, especially England with France and Spain, and Japan with China and Korea. They have also long been one of the dominant powers of their respective regions, and formed the extensive empires behind the strength of their navies. The English are the dominant ethnic group in the UK and descend from the Anglo-Saxons, who migrated from continental Europe to eventually displace the Celts as rulers of the land. The history of the Japanese people is not as well understood, but it is possible that the ancestors of modern day Japanese people or Wajin, migrated to the islands and displaced the ancestors of the modern day Ainu people. The capitals of these respective nations, Tokyo and London, are two of the world's true alpha cities. Also both the British and the Japanese love tea.

How it falls apart: 
The Imperial histories seem to be one of the biggest similarities between the two nations, but in reality they weren't very similar empires. The British Empire's main holdings were outside of Europe, geographically disparate and extensive and lasted for centuries whereas the Japanese Empire seized the areas nearest them, Korea and Taiwan, before massive expanding throughout East and Southeast Asia for a short period during World War II. Japan also has a much more isolated history, resisting foreign influences for centuries, and as a result is even today objectively more culturally removed from its continental neighbors. It is a very homogenous nation, with the Ainu barely a distinct contemporary ethnic group and with 1.5% of the population foreign citizens. 8.3% of the UK is foreign born, and I think a fleeting glimpse to either nation is suffice to prove that the UK is much more multicultural and diverse than Japan. As such, the essential relationship between the UK and Europe is nothing like the relationship between Japan to Asia. English operates as a lingua franca among Europeans (and the world) among whom it is not uncommon to study at British schools. Japanese is a studied language in Asia and people do study in Japanese universities, but it is more specialized and undertaken primarily among those with a unique interest in Japan. In addition, I haven't gotten to how England, Wales, Scotland & Northern Ireland make up the United Kingdom, and the role of Ireland in all this. And really, who doesn't love tea?

East Germany is to West Germany as North Korea is to South Korea


How it works: 
The end of World War II and the start of the Cold War divided these two nations. One nation became communist (with planned economies and state-owned enterprises and the like), the other capitalist, and decades later the capitalist one was a thriving economic powerhouse with global car brands and the communist one was a struggling starving poor piece of land. A sharp symbolic boundary divided the split nations, with the Berlin Wall in Germany and the Demilitarized Zone in Korea. The splits were dramatic, separating families and creating sharp enmity. The two countries treated each other with suspicion and espionage, though there was always a confusing overhanging cloud of reunion. The golden goal for both situations, reunion could occur peacefully or forcefully. The capitalist countries allied themselves with the western powers, while the communist countries relied on their big strong communist neighbor, Soviet Union and China respectively.  All the countries had fancy names for themselves that took the focus off the split: German Democratic Republic (East), Federal Republic of Germany (West), Democratic People's Republic of Korea (North), and Republic of Korea (South).

How it falls apart:
One is a East-West split and the other is a North-South split.  No just kidding. The main difference is that East Germany was much smaller than West Germany (16 mill to 63 mill in 1990), and largely controlled by the Soviet Union. North Korea is more comparable to South Korea in size (24 million to 50 million present day) and adhere to the principle of self-reliance, Juche, despite all that China helps them with.  East Germany was poorer than West Germany, but it was one of the more successful Eastern Bloc countries and the GDP/capita was over $10,000 USD a year. In comparison, the GDP/capita in North Korea was $1,800 USD/year in 2011. Perhaps the East/West Germany and North/South Korea economic divide were comparable in the late 80s, but now the split is so much wider in the Koreas than it ever was in the Germanies. 

I don't think I need to elaborate too much further on this because I think most people are more familiar with these two situations than perhaps others on this post. But Jon Stewart adds this other analogy: "Dakota, like Korea, has a rather mild south and a north that hates the world."

Many Chinese Cities to US Cities
How it works:

I don't know who did this but somebody bothered to give each Chinese province and most major cities a US equivalent. It's a huge effort worth applauding, but some of the choices are very peculiar. Beijing is labeled LA, probably because of its large population, urban sprawl and smog. It is certainly not an appropriate comparison in terms of its history, culture, weather or transportation. Shanghai is New York, which is the only suitable choice. Some comparisons are pretty nifty. If Beijing is going to be LA, then it makes sense that Tianjin will be San Diego. Nanjing is paired with Philadelphia, and giving their histories as former capitals, that seems fair. Qingdao as Seattle and Dalian as Boston both get seals of approval from me. Hainan is where Chinese people go for their beaches so that'll obviously be Florida. Taipei is Atlanta....maybe because Atlanta was one of the major cities of the Confederate South? I'll run with it. I was very confused about the association of New Orleans, one of the most interesting cities in the US, with Zhanjiang, a town I hadn't even heard of, until I did some research and learned that Zhanjiang was a French colony for 50 years. Wuhan is Chicago and Chengdu is Dallas by virtue of size, and it seems that Chongqing is completely omitted from the map. Inner Mongolia is given the associates of North Dakota, South Dakota and Nebraska, which I'm sure should thrill everyone from all those places. In this map, the old Chinese name for San Francisco (旧金山) seems to be assigned to Hong Kong, and as two cities that I love, that sounds perfect.

My biggest issue from this map is Kunming being labeled as Phoenix (and Yunnan as Arizona, wtf, entirely a southwesterly geographic choice). Yunnan is a mountainous region that's much cooler than even Beijing in the summertime, whereas Arizona is one of the hottest places in America. Kunming is actually a really good match with Denver in my opinion. Their size and importance relative to the country is comparable, they are both at over a mile in altitude, and are home to the hippies of their respective countries. Also, neither Kunming nor Denver were able to participate in Super Bowl 48.


Shenzhen is to Hong Kong as Johor Bahru is to Singapore

How it works: 

Hong Kong and Singapore are both Asian city states  with many similarities including histories as important British colonial ports, centers of major economic might, Chinese populaces and small territories with lots of people. The Chinese and Malaysian cities across the border form their economies primarily around trade with their neighboring city states and contrast starkly with their lower quality of life. JB is primarily a Malay speaking city compared to quadrilingual but English-dominated Singapore, while Mandarin dominates in SZ due to large scale internal Chinese migration compared to two-languages-three-vernaculars but Cantonese-dominated Hong Kong. Both Hong Kong and Singapore draw water and power from their larger neighbors and face issues with immigration from those same countries. Many Hong Kong and Singaporean residents treat SZ and JB as their playgrounds to the north, places to go for a spa or amusement park fling (SZ has Windows of the World, JB has Legoland Malaysia), for a short time to avoid dealing too long with the perceived lower quality service.

How it falls apart: 

Hong Kong is technically part of China, while Singapore are separate sovereign nations. This distinction has important consequences. Hong Kong doesn't keep a standing army, with its waters patrolled by the Chinese navy. Meanwhile, mandatory service is required for all Singaporean men, so that in case of invasion by Malaysia and Indonesia, Singapore won't get completely wiped out. Water supply is also a huge issue. While Hong Kong draws the majority of its water from the Dong river in Guangdong, it sees little problem with this relationship (even though it should since it doesn't totally control the pollution that the river is subjected to). On the other hand, Singapore's treaty to receive raw water from Malaysia expires in 2061, and they are preparing themselves to be self-reliant on water by then. As Malaysia is under no obligation to renew the contract and has previously asked for a hike in prices, Singapore is aggressively pursuing a plan of water conservation, manmade reservoirs, desalination and reclaimed water (branded NEWater). 

Also, Johor Bahru's initial expansion occurred in the mid 1800s under Sultan Abu Bakar and has a distinguished history of its own right. Shenzhen on the contrary can trace its entire modern history to the 1979 establishment of a Special Economic Zone. While both economies are now inexorably tied to their adjacent city-states, JB's came about naturally while SZ's was established explicitly so. SZ has grown exponentially though, developing into one of China's major cities and its port may soon eclipse Hong Kong's in net traffic.


Canada is to the United States as Ireland is to the United Kingdom as New Zealand is to Australia


How it works:

It seems all the major English-speaking countries in the world have an English-speaking neighbor that is much smaller in population and economic weight but while possibly being better places to live. Can you guess which population ratios correspond to which pair of countries - 1:9, 1:14 and 1:4?  Hint: they're in the same order as the section title. 

How it falls apart:
I have never told this analogy without someone getting offended.