geopy

How to cluster Latitude and longitude data in python (or remove unwanted data)?

独自空忆成欢 提交于 2019-12-24 07:16:08
问题 I have a Latitude and Longitude data of size (34000 * 2) in pandas df df = Index Latitude Longitude 0 66.36031097267725 23.714807357485936 1 66.36030099322495 23.71479548193769 2 . . . . 34000 66.27918383581169 23.568631229948359 Important Note : The above Lat & Long route has been covered twice which means if I cover the route only once, then my Latitude and Longitude data will be of size (34000/2, 2) for example. Problem I just want Lat and Long Data for a particular selected area. So i

Python Pandas 'apply' returns series; can't convert to dataframe

喜夏-厌秋 提交于 2019-12-23 09:46:28
问题 OK, I'm at half-wit's end. I'm geocoding a dataframe with geopy. I've written a simple function to take an input - country name - and return the latitude and longitude. I use apply to run the function and it returns a Pandas series object. I can't seem to convert it to a dataframe. I'm sure I'm missing something obvious, but I'm new to python and still RTFMing. BTW, the geocoder function works great. # Import libraries import os import pandas as pd import numpy as np from geopy.geocoders

Geopy error: GeocoderServiceError: HTTP Error 500: Internal Server Error using pandas apply function with str concat

风流意气都作罢 提交于 2019-12-22 17:55:59
问题 Working function (see code Python Pandas 'apply' returns series; can't convert to dataframe) has stopped working. Only difference is I'm passing it a string concatenation. # Get geocode, return LAT and LON def locate(x): geolocator = Nominatim() print("'" + x + "'") location = geolocator.geocode(x) # Get geocode print(location) lat = location.latitude lon = location.longitude try: #Get geocode location = geolocator.geocode(x, timeout=8, exactly_one=True) lat = location.latitude lon = location

Convert between coordinate systems with GeoDjango

丶灬走出姿态 提交于 2019-12-22 08:15:23
问题 I'm trying to add coordinate information to my database, adding django.contrib.gis support to my app. I'm writing a south data migration that takes the addresses from the database, and asks Google for the coordinates (so far I think my best bet is to use geopy for this). Next I need to convert the returned coordinates from WGS84:4326 , Google's coordinate system, to WGS84:22186 , my coordinate system. I'm lost among the GeoDjango docs trying to find a way to do this. This far, I gather I need

Best way to pass repeated parameter to a Numpy vectorized function

守給你的承諾、 提交于 2019-12-20 02:13:33
问题 So, continuing from the discussion @TheBlackCat and I were having in this answer, I would like to know the best way to pass arguments to a Numpy vectorized function. The function in question is defined thus: vect_dist_funct = np.vectorize(lambda p1, p2: vincenty(p1, p2).meters) where, vincenty comes from the Geopy package. I currently call vect_dist_funct in this manner: def pointer(point, centroid, tree_idx): intersect = list(tree_idx.intersection(point)) if len(intersect) > 0: points = pd

How to fill missing geo location in datasets? [closed]

隐身守侯 提交于 2019-12-13 08:11:34
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I have a set of dataset with missing geo location names and coordinates at same time. I want to fill in the gaps so that I can proceed with the future analysis of the data. The data set is harvested from twitter so it is not a created data but this is how the data has come and I

How to check that a point is inside the given radius?

时间秒杀一切 提交于 2019-12-11 06:37:09
问题 I have the following code that takes very long time to execute. The pandas DataFrames df and df_plants are very small (less than 1Mb). I wonder if there is any way to optimise this code: import pandas as pd import geopy.distance import re def is_inside_radius(latitude, longitude, df_plants, radius): if (latitude != None and longitude != None): lat = float(re.sub("[a-zA-Z]", "", str(latitude))) lon = float(re.sub("[a-zA-Z]", "", str(longitude))) for index, row in df_plants.iterrows(): coords_1

Python sum lat/lon points within geographic radius and sum to grid

℡╲_俬逩灬. 提交于 2019-12-10 21:19:57
问题 Basically, my experimental program is trying to find the number of points that fall within a (e.g., 50km) radius of a valid point at a given time. My data is structured (but I can restructure if need-be) in three separate arrays such: 1_LAT,1_LON,1_TIM Where 1_LAT,1_LON,1_TIM all contain roughly ~250 values corresponding to Latitude, Longitude (decimal degrees), and time respectively. I have 20 sets of these arrays (i.e., 1_LAT,1_LON,1_TIM...20_LAT,20_LON,20_TIM). Here is what I would like to

How to use geopy vicenty distance over dataframe columns?

前提是你 提交于 2019-12-10 19:18:29
问题 I have a dataframe with location column which contains lat,long location as follows deviceid location 1102ADb75 [12.9404578177, 77.5548244743] How to get the distance between consecutive rows using geopy's vicenty function? I tried following code from geopy.distance import vincenty vincenty(df['location'].shift(-1), df['location']).miles It returns following error - TypeError: __new__() takes at most 4 arguments (5 given) EDIT - where df is a Pandas dataframe containing deviceId & Location

Geocoding with Geopy and big data

点点圈 提交于 2019-12-10 12:36:38
问题 I have this CSV file which i'm feeding with this python script import csv from geopy.geocoders import OpenCage geolocator = OpenCage() #here some parameters are needed with open('/Users/Ian/Desktop/Test02/151213_2015_martyrs_year_filtered_areas.csv', 'rb') as csvinput: with open('151213_locations_filtered_opencage.csv', 'w') as csvoutput: output_fieldnames = ['Province','Area', 'Country','Latitude','Longitude'] writer = csv.DictWriter(csvoutput, delimiter=',', fieldnames=output_fieldnames)