Below is the section of code I'm having trouble with. How do I designate the x and y coordinates from the (lat, lng) variable in the twittersearch for loop in the top part? These coordinates will be inserted into a feature class/shapefile to then be loaded into ArcGIS as point data.
for tweet in ts.search_tweets_iterable(tso): print( '@%s tweeted: %s' % ( tweet['user']['screen_name'], tweet['text'] ) ).encode('ascii', 'ignore') #ignore unicode here, show error on map?? if tweet['place'] is not None: (lat, lng) = geo(tweet['place']['full_name']) print 'And they said it from (' + str(lat) +', ' + str(lng) + ')' else: print "And their place wasn't specified..." with arcpy.da.InsertCursor("D:/UW/Winter_2016/501/w7_twitter/twitterSearchFC.shp", ["SHAPE@XY"]) as cursor: x = float(lat).xcor() y = float(lng).ycor() varPoint = arcpy.Point(x,y) array.add(varPoint) twitterPoint = arcpy.Point(array) cursor.insertRow([twitterPoint])
After running the script this is what I get from Twitter, if that helps.
@12voltarts tweeted: #chihuly bowl @ Chihuly Garden and Glass https://t.co/Hf0RqE5nU3 And they said it from (47.6038321, -122.3300623)
My thinking is that I will need to identify each lat and lng as a new variable and call that in the cursor piece. I'm almost positive there is an easier way to do this...
also the error:
x = float(lat).xcor() AttributeError: 'float' object has no attribute 'xcor'
from geopy import geocoders def geo(location): g = geocoders.Nominatim() loc = g.geocode(location) return float(loc.latitude), float(loc.longitude)
output is a shapefile with twitter location data (tweets) spatially referenced to be able to see it in ArcGIS