How to use the geopy.Point function in geopy

To help you get started, we’ve selected a few geopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github milo2012 / osintstalker / geostalker.py View on Github external
root = lxml.html.fromstring(content)
			
		doc = lxml.html.document_fromstring(content)
		photoLat = doc.xpath('//*[@id="main"]/div[2]/table[2]/tbody/tr[26]/td/text()')
		photoLng= doc.xpath('//*[@id="main"]/div[2]/table[2]/tbody/tr[27]/td/text()')

		if photoLat and 'deg' in str(photoLat[0]) and 'deg' in str(photoLng[0]):
			newPhotoLat = photoLat[0].replace('deg','').replace("'","").replace('"','').split(' ')
			newPhotoLng = photoLng[0].replace('deg','').replace("'","").replace('"','').split(' ')
			photoLatStr = str(float(newPhotoLat[0])+float(newPhotoLat[2])/60+float(newPhotoLat[3])/3600)
			photoLngStr = str(float(newPhotoLng[0])+float(newPhotoLng[2])/60+float(newPhotoLng[3])/3600)

			#photoLatStr = str(float(newPhotoLat[0])+float(newPhotoLat[2])/60+float(newPhotoLat[3])/3600)
			#photoLngStr = str(float(newPhotoLng[0])+float(newPhotoLng[2])/60+float(newPhotoLng[3])/3600)

			pt1 = geopy.Point(lat, lng)
			pt2 = geopy.Point(photoLatStr, photoLngStr)
			dist = geopy.distance.distance(pt1, pt2).meters

			outputStr = '[*] Found Matching Geocoordinates in Flickr Data: ('+str(photoLatStr)+','+str(photoLngStr)+')\t'+str(dist)+' meters'
			report += '\n'+outputStr
			#print geoLocUrl
		
			userName = soup.find('span',attrs={'class':'photo-name-line-1'})
			#print userName.text
			
			cameraModel = root.cssselect("html body.zeus div#main.clearfix div.photo-data table tbody tr.lookatme td a")
			if cameraModel:
				cameraModelText = cameraModel[0].text
			else:
				cameraModelText = ''
github CopterExpress / clever / clever / src / global_local.py View on Github external
position_global = rospy.wait_for_message('mavros/global_position/global', NavSatFix, timeout=0.5)
    except rospy.exceptions.ROSException:
        raise Exception('No global position')

    try:
        pose = rospy.wait_for_message('mavros/local_position/pose', PoseStamped, timeout=0.5)
    except rospy.exceptions.ROSException:
        raise Exception('No local position')

    d = math.hypot(pose.pose.position.x, pose.pose.position.y)

    bearing = math.degrees(math.atan2(-pose.pose.position.x, -pose.pose.position.y))
    if bearing < 0:
        bearing += 360

    cur = geopy.Point(position_global.latitude, position_global.longitude)
    origin = VincentyDistance(meters=d).destination(cur, bearing)

    _origin = origin.latitude, origin.longitude
    olat_tlon = origin.latitude, lon
    tlat_olon = lat, origin.longitude

    N = vincenty(_origin, tlat_olon)
    if lat < origin.latitude:
        N = -N

    E = vincenty(_origin, olat_tlon)
    if lon < origin.longitude:
        E = -E

    return E.meters, N.meters
github lbud / run_sf / utils / finding_fns.py View on Github external
def find_miles(x1, x2):
    """ Finds distance, in miles, between two node or intersection objects """
    pt1 = Point(x1.lat, x1.lon)
    pt2 = Point(x2.lat, x2.lon)
    dist = distance.distance(pt1, pt2).miles
    return dist
github DFO-Ocean-Navigator / Ocean-Data-Map-Project / data / geo.py View on Github external
lon1 = end.longitude

    if constantvalue and np.isclose(lat0, lat1):
        latitude = np.ones(numpoints) * lat0
        longitude = np.linspace(lon0, lon1, num=numpoints)
        for lon in longitude:
            distance.append(vincenty(start, geopy.Point(lat0, lon)).km)
        if lon1 > lon0:
            b = 90
        else:
            b = -90
    elif constantvalue and np.isclose(lon0, lon1):
        latitude = np.linspace(lat0, lat1, num=numpoints)
        longitude = np.ones(numpoints) * lon0
        for lat in latitude:
            distance.append(vincenty(start, geopy.Point(lat, lon0)).km)
        if lat1 > lat0:
            b = 0
        else:
            b = 180
    else:
        total_distance = vincenty(start, end).km
        distance = np.linspace(0, total_distance, num=numpoints)
        b = bearing(lat0, lon0, lat1, lon1)

        for d in distance:
            p = VincentyDistance().destination(start, b, d)
            latitude.append(p.latitude)
            longitude.append(p.longitude)

    return list(map(np.array, [distance, latitude, longitude, b]))
github burakbayramli / kod / nomadicterrain / map / route.py View on Github external
def goto_from_coord(start, distance, bearing):
    """
    distance: in kilometers
    bearing: 0 degree is north, 90 is east
    """
    s = geopy.Point(start[0],start[1])
    d = geopy.distance.VincentyDistance(kilometers = distance)
    reached = d.destination(point=s, bearing=bearing)
    return [reached.latitude, reached.longitude]
github vipyoung / kharita / anim_map / methods.py View on Github external
def partition_simple_edge(edge, distance_interval):
	"""
	given an edge (lon,lat) --> (lon, lat), creates holes every x meters (distance_interval)
	:param edge: a given edge
	:param distance_interval: in meters
	:return: list of holes
	"""

	# We always return the source node of the edge, hopefully the target will be added as the source of another edge.
	holes = [edge[0]]
	d = geopy.distance.VincentyDistance(meters=distance_interval)
	# make sure we are using lat,lon not lon,lat as a reference.
	startpoint = geopy.Point([edge[0][1], edge[0][0]])
	endpoint = geopy.Point([edge[1][1], edge[1][0]])
	initial_dist = geopy.distance.distance(startpoint, endpoint).meters
	if initial_dist < distance_interval:
		# return [], distance_interval - initial_dist
		return holes + [edge[1]]
	# compute the angle=bearing at which we need to be moving.
	bearing = calculate_bearing(startpoint[0], startpoint[1], endpoint[0], endpoint[1])
	last_point = startpoint

	for i in range(int(initial_dist) / distance_interval):
		new_point = geopy.Point(d.destination(point=last_point, bearing=bearing))
		holes.append(tuple([new_point.longitude, new_point.latitude]))
		last_point = new_point
	# return holes, initial_dist - (initial_dist / distance_interval) * distance_interval
	if holes[-1] != edge[1]:
		holes += [edge[1]]
github vipyoung / kharita / anim_map / kharita_anim_osm_merge.py View on Github external
# *****************
		# Cluster creation
		# *****************
		# TODO: be more conservative in creating clusters! Add something like a threshold, min number of cars, etc.
		if len(nearest_cluster_indices) == 0:
			# create a new cluster
			new_cluster = Cluster(cid=len(clusters), nb_points=1, last_seen=point.timestamp, lat=point.lat, lon=point.lon, angle=point.angle)
			clusters.append(new_cluster)
			lonlat_to_clusterid[new_cluster.get_lonlat()] = new_cluster.cid
			roadnet.add_node(new_cluster.cid)
			current_cluster = new_cluster.cid
			# recompute the cluster index
			update_kd_tree = True
		else:
			# add the point to the cluster
			pt = geopy.Point(point.get_coordinates())
			close_clusters_distances = [geopy.distance.distance(pt, geopy.Point(clusters[clu_index].get_coordinates())).meters
			                            for clu_index in nearest_cluster_indices]
			closest_cluster_indx = nearest_cluster_indices[close_clusters_distances.index(min(close_clusters_distances))]
			clusters[closest_cluster_indx].add(point)
			current_cluster = closest_cluster_indx

		# *****************
		# Edge creation
		# *****************
		# case of very first point in the trajectory (has no previous cluster.)
		if prev_cluster == -1:
			building_trajectories[traj_id] = current_cluster
			continue

		edge = [clusters[prev_cluster], clusters[current_cluster]]
		# TODO: I can add a condition on when to create fictional clusters. E.g., condition on angle diff (prev,curr)
github tum-ens / rivus / rivus / gridder / create_grid.py View on Github external
fuzz_radius_y = dy * noise_prop
    if noise_prop > MAX_NOISE:
        fuzz_radius_x = MAX_NOISE * dx
        fuzz_radius_y = MAX_NOISE * dy

    _check_input(origo_latlon, num_edge_x, num_edge_y, dx, dy, noise_prop)

    # Generate offset point coordinates
    if epsg is None:  # in  LatLon system
        # getting new points based on https://stackoverflow.com/a/24429798
        # Convert to geopy distance
        crsinit = {'init': 'epsg:4326'}
        dx = distance(meters=dx)
        dy = distance(meters=dy)
        points = []
        startp = gPoint([lat, lon])
        # create the grid coordinates
        for _ in range(num_vert_y):
            # In lon(x), lat(y) order to be passed to Shapeley.Point()
            # Bearing 90->East 0->North
            points.append([startp.longitude, startp.latitude])
            _startp = startp
            for _ in range(num_edge_x):
                _startp = dx.destination(point=_startp, bearing=90)
                points.append([_startp.longitude, _startp.latitude])
            startp = dy.destination(point=startp, bearing=0)
    else:  # in UTM XY coord system
        try:
            UTMXX = Proj(init='epsg:{}'.format(epsg))
            crsinit = {'init': 'epsg:{}'.format(epsg)}  # for GeoDataFrame
        except:
            raise ValueError('Not supported epsg number, \
github JoanMartin / trackanimation / trackanimation / utils.py View on Github external
time_proportion = (time_diff * point_idx) / end_point['TimeDifference'].item()

    distance_proportion = end_point['Distance'].item() * time_proportion
    time_diff_proportion = end_point['TimeDifference'].item() * time_proportion
    speed = distance_proportion / time_diff_proportion
    distance = time_diff * speed
    cum_time_diff = int(start_point['CumTimeDiff'].item() + time_diff_proportion)
    # date = datetime.strptime(start_point['Date'].item(), '%Y-%m-%d %H:%M:%S') + dt.timedelta(seconds=int(
    # time_diff_proportion))
    date = pd.to_datetime(start_point['Date'].astype(str), format='%Y-%m-%d %H:%M:%S') + dt.timedelta(
        seconds=int(time_diff_proportion))
    altitude = (end_point['Altitude'].item() + start_point['Altitude'].item()) / 2
    name = start_point['CodeRoute'].item()

    geo_start = geopy.Point(start_point['Latitude'].item(), start_point['Longitude'].item())
    geo_end = geopy.Point(end_point['Latitude'].item(), end_point['Longitude'].item())
    middle_point = get_coordinates(geo_start, geo_end, distance_proportion)

    df_middle_point = ([[name, middle_point.latitude, middle_point.longitude, altitude,
                         date, speed, int(time_diff), distance, None, cum_time_diff]])

    return df_middle_point
github geometalab / OSMDeepOD / src / base / node.py View on Github external
from geopy import Point
from geopy.distance import vincenty

from src.base.globalmaptiles import GlobalMercator


class Node(Point):
    def __init__(self, lat=0.0, lon=0.0, osm_id=0):
        super(Node, self).__new__(Point, latitude=lat, longitude=lon)
        self.osm_id = osm_id

    def __str__(self):
        return "Node " + str(self.osm_id) + ": Lat " + str(
                self.latitude) + ", Lon " + str(self.longitude)

    def copy(self):
        return Node(self.latitude, self.longitude, self.osm_id)

    def add_meter(self, vertical_distance, horizontal_distance):
        mercator = GlobalMercator()
        copy = self.copy()
        lat, lon = mercator.MetersToLatLon(horizontal_distance, vertical_distance)
        copy.latitude += lat