[JAVA] Save Twitter's tweets with Geo in CSV and plot them on Google Map.

For the time being, I don't know how to narrow down the locale from the STREAMING API due to lack of knowledge. So I usually use Search to pick up "Nau" and "i'm at" and plot them.

    1. Create CSV data with the previously created Python script for Twitter search
  1. Map display in Javascript using GoogleMap API
    1. Plot there

I did it like that.

for tweet in tweets["statuses"]:
	User = (tweet["user"]["screen_name"].encode("utf-8"))
		try:
			Place = (tweet["place"]["bounding_box"]["coordinates"])
					
			flat_list = []
			for e in Place:
				flat_list.extend(e)
    	
			flat_list2 = []
			for b in flat_list:
				flat_list2.extend(b)
 
			flat_list3 = []
			for c in flat_list:
				flat_list3.extend(c)
    	
			geolng = flat_list3[0]
			geolat = flat_list3[1]
		except:
			pass

Well, like this, let's open only Place with try.

Place = (tweet["place"]["bounding_box"]["coordinates"])

If you fetch it with, the list will be nested, so use flat_list to cancel the nesting. No, it's not really beautiful ...

Export the acquired data as CSV and plot it on a map.

alt

As expected, there are many metropolitan areas. Do local people not tweet with a lot of positions, or is the Twitter population itself small?

Oh, is the keyword to narrow down useless?

Recommended Posts

Save Twitter's tweets with Geo in CSV and plot them on Google Map.
Download the images and videos included in the tweets you liked on Twitter and upload them to Google Drive
Get tweets with Google Cloud Function and automatically save images to Google Photos
Verify coordinates on Google Map with Geocoder
Implement Sign In With Google on the backend side
Shuffle the images in any directory with Python and save them in another folder with serial numbers.
[python] Use DataFrame to label arbitrary variables and arrays together and save them in csv [pandas]
A Python program that collects tweets containing specific keywords daily and saves them in csv
[Ruby on Rails] Multiple pins, balloons, and links on Google map
Deep Learning with Shogi AI on Mac and Google Colab