Visualize social pulse data form Open Data challenge with KML and Google Earth

This small visualization IDEA is about the social pulse data we have download in "How to collect social data from the Dandelion API." Now we will try to visualize it in a original way. A nice tool for this is also Google Earth. For making the data visualizable in Google Earth we have to wrap it in the KML markup language

First thing first we have to make a Java filter code for the social dataset. Then we need to make a java wrapper that will print a kml file with the placemarks where each placemark will represent the location of a tweet


The best data structure for this task is the List. You can read more about it here "Java List" You need no other special package for it but you need the social pulse dataset.

Basically we have to:

1 - read the social pulse dataset and load the List with the coordinates of the tweets

2 - make a method that will wrap the coordinates in KML placemarks and print the KML file to be oppened with Google Earth

Bellow there is the method for loading the data. It will read line by line the social pulse dataset and load the list. By setting the counter it is possible to take only counter rows of tweet data

	  public static void load (Listl, String file)throws Exception{
		BufferedReader br = new BufferedReader(new FileReader(new File(file)));
		String line; 
		int counter = 0;
		int counter2 = 0; 
		while((line = br.readLine())!=null){

			String [] r = line.split("\t\t\t");
			String ts = r[5];

			String p = r[6];
			String point = p.substring(r[6].indexOf("(")+1, p.indexOf(")"));
			String rec = ts+", "+point;
			if(counter2 == 4000)break;


And of course the print() method that prints the KML file.


And the results are already in the picture you see in the top of the page.

3-Run and check the results : simply run the java code in Eclipse. At the end the code will print the file social-placemarks.kml .Once you finish and open the kml file in Google Earth you will see a map that looks like the picture in the top of the page.

If you missed something in puting the pieces together then you can download the working project from here.

And if you enjoyed this article guide dont forget to share


or follow ..

Follow @datamap2t