Monday, April 11, 2011

Java wrapper of GDAL

This blog is about to become a tech blog in addition to everything else. This is for my benefit and the benefit of all the other intrepid voyagers journeying through the vastness of the techscape.

This post describes the setup of the Java bindings of GDAL. The basic idea was that I wanted access to other image formats, in particular ENVI, without writing a bunch of code to slice and dice the binary blobs in which ENVI stores image data. There are a lot of ways to wrap the GDAL binaries from scratch. For some examples, see here:

Call it laziness, but I just did not want to deal with SWIG and having to re-compile everything. I suspected there is an easier way and there is. Good tech samaritan Tamas Szekeres maintains this list of pre-compiled binaries, including wrappers:

So I downloaded this one, for my Windows XP 32-bit operating system: release-1600-gdal-1-8-mapserver-5-6 which is compiled with Microsoft Visual C++ 2010. In the install directory is a GDAL/java/gdal.jar file. I would like to make use of this from within the Eclipse IDE. So I add gdal.jar to the class path and try to gdal.AllRegister(); But I get an exception like:

Native library load failed. java.lang.UnsatisfiedLinkError: C:\Program Files\GDAL\gdaljni.dll: Can't find dependent libraries

So I add the following to the VM arguments:

-Djava.library.path="C:/Program Files/GDAL"

This got me a little further but still threw an UnsatisfiedLinkError. Tamas suggested that I download the Microsoft Visual C++ 2010 Redistributable Package:

Once this was installed, gdal.AllRegister() runs without an exception, even if I remove the virtual machine argument. The GDAL test code also runs (, no problem (given the data types that are checked in the code). I have now made a similar installation on a Windows 7 64-bit OS that works. However, I did discover that if GeoTools 2.7 is installed (with imageio-ext 1.0.6), GDAL and GeoTools will not play well together. As soon as I took GeoTools off the classpath, everything worked fine. Otherwise, I got an UnsatisfiedLinkError. Out of superstition, I also added the location of the GDAL binaries to the system "path" variable, just in case windows starts hunting around for something.

The other thing that I have experienced on both XP and Windows 7 is that the JNI wrapper broke, possibly after a recent update. After some gnashing of teeth, a reinstallation of either the VC++ redistributable or GDAL, everything started working again.

Wednesday, March 23, 2011

Chinese Bourgeoisie

From the Communist Manifesto:

"The bourgeoisie, by the rapid improvement of all instruments of production, by the immensely facilitated means of communication, draws all, even the most barbarian, nations into civilisation. The cheap prices of commodities are the heavy artillery with which it batters down all Chinese walls, with which it forces the barbarians’ intensely obstinate hatred of foreigners to capitulate. It compels all nations, on pain of extinction, to adopt the bourgeois mode of production; it compels them to introduce what it calls civilisation into their midst, i.e., to become bourgeois themselves. In one word, it creates a world after its own image. "

"The bourgeoisie has subjected the country to the rule of the towns. It has created enormous cities, has greatly increased the urban population as compared with the rural, and has thus rescued a considerable part of the population from the idiocy of rural life."

"The bourgeoisie keeps more and more doing away with the scattered state of the population, of the means of production, and of property. It has agglomerated population, centralised the means of production, and has concentrated property in a few hands. The necessary consequence of this was political centralisation."

"Subjection of Nature’s forces to man, machinery, application of chemistry to industry and agriculture, steam-navigation, railways, electric telegraphs, clearing of whole continents for cultivation, canalisation of rivers, whole populations conjured out of the ground..."

Sound familiar?

Monday, November 10, 2008


Now that the Olympics dog and pony show is over, the cameras are gone, and the commies got their phony message out, the Olympic park is opened to riff-raff like me. My buddy Yang Jun showed me around the other day. I admired the tower, but he poo-poo'ed my accolades on based on the price of the damn thing. While I do agree that the money could have been spent better elsewhere (like providing heat or fresh drinking water to Chinese people), what's wrong with a nice tower? As I pointed out, how many nice towers could we have gotten for all the money that got spent in Iraq? Probably one in every US city, was Jun's estimate. Another interesting thing we noticed was that the signs have three languages, Chinese, English, and French. French? I said. Why? (Sorry, Mom, but really...) Could it be that IOC president Jacques Rogge is Belgian? Can there be any more shameless example of blatant ass kissing? You can almost smell the shit on the collective nose of BOCOG. Anyhooo, I diverge.

The park itself is very striking. (Jun claims it was designed by American landscape architects. Why don't we get nice parks?) Here are some photos.

The main promenade by day. I just love those lights.

The promenade by night.

The tower. I don't care how much it cost, it looks fucking cool!

Rubberneckers at the Bird's Nest.

I love this statue. I'm not sure what it means to balance a sailboat on the leg of a humanoid with no arms, but I generated some amusement of the onlookers by mimicking this bizarre pose. And it makes for a great photo!

Friday, November 7, 2008


The Olympic park, for all its stark beauty, dramatic shapes, and post-modern contours, is basically deserted. I'm told that the bird's nest will become a mall, and eventually shops will move into the buildings along the promenade, but for now, it is eerily empty. There is a subway stop quite close to my place (奥林皮克公园) so I decided to investigate the convenience of taking the subway home. I was greeted with a big surprise: an empty train! For anyone who has never taken the subway in Beijing, you get used to squeezing in with a shitload of people, at virtually ever hour of the day. So it was quite odd to switch to the Olympic park line and find myself sharing an entire train with two other dudes. Shortly before I took this shot, one of the other guys was also getting a photo, in appreciation of the weirdness of it:

A random building outside Bei's house. A street scene in Beijing. Note the cluster of guys playing Chinese checkers:

I love this one. We were in a really cool little bar in the Hutong, the old part of Beijing. Really good German beer on tap. Cute couple, eh?

Thursday, October 30, 2008


Greetings from Beijing! I never thought I would find myself here again so soon, but girls can make you do all sorts of strange things. Bei met me at the airport and as soon as I saw her, my heart just melted. It was the nicest reception I ever had. She's awesome!

Anyway, Beijing is the same, yet not the same. All the gates, roads, restaurants, etc. that were closed during the Olympics are now open again. The air smells like China, there is more traffic on the roads, everything is back to normal... and I love it! This whole place had taken on a sort of Disneyland like feeling during the Olympics. Today was a gorgeous, blue sky, fall day in Beijing. I ate 茶鸡蛋 (cha ji dan, or eggs cooked in tea. Sounds gross, but they are delicious) for breakfast and drank instant coffee. Mmmmmm!

Wednesday, October 1, 2008

Maltese Falcon

中国朋友,你们好!我要给你门看看几张照片所以你们能知道住在加州怎么样。 我对不起我的语法很不好。我希望我的意思明白。


这个人是我的老朋友叫Dan Stark。我跟他很多年以前学林科学。现在我们常常一起喝酒。

在Berkeley大学,有一个学生酒吧叫The Bear's Lair (熊的家)。这个酒吧只有啤酒。你能看起来他们有很多种啤酒。可能有二十多种啤酒。很好喝!

这是别的酒吧,可是真的一个酒吧。他们卖很多种酒。 在中国,我没看到这个酒。









两点钟,我们去出旧金山,在金门桥下边等最大的帆船叫Maltese Falcon。天气非常好,暖和。


很多别的船也去出找Maltese Falcon。

在大海上热闹!都要欢迎Maltese Falcon!


Maltese Falcon 太快了!我们不可以跟那个船坐帆船去。开船的人是我的老朋友叫Sam Herrick。我们一起在中学。


Sunday, September 7, 2008

Back in the USA




这是船的双人床 (非常舒服):



前天,我去出开帆船!我有两个月没开帆船, 所以我回来美国以后,这是第一次。因为我没有找到人帮忙我,我得自己开船。自己开船有一点难,可是很好完!我去出的时候,这个人进出。他好像很高兴,对不对?



这个东西是一个开船的自动的机。(Sorry for the English. It's a machine that automatically steers the boat. So I can do other things (put the sails up or down) while it steers).
金门桥 (Golden Gate Bridge in English):

I really like this next picture. I took this from the bowsprit on the way back. I like the way the motion of the boat is somehow captured by the appearance of the water. You can see the windlass, dock lines, bumpers, hardware and a nice piece of flapping rigging tape as well (whoops). Anyway, when I look at this shot, I can almost feel the boat carrying me somewhere.
最后的照片. 可能,我更喜欢这张照片因为你可以看起来这是一个动的船.