Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

Google Maps API soruları


Goering

Öne çıkan mesajlar

alttaki linktekinin yaptığını yapmaya çalışıyorum:
- A ve B noktası belirlicem; Google Distance Matrix veya Directions API walk/drive distance vericek.
- A ve B noktası *.csv'den alınacak, gelen cevap *.csv'de yan kolona kaydedilecek.

http://www.analyticsvidhya.com/blog/2015/03/hacking-google-maps-create-distance-features-model-applications/

python 3.* + PyCharm'da çalışıyorum ama yeni öğreniyorum dili. başka bir dilde mi query yollıyim? java falan da bilmiyorum.

sorular:
- googlemaps module kalktı mı? (Client olarak mı yazmam gerekiyor)
- for i in range(0, 8): excel'de nereyi gosteriyor? o range neresi A8'e kadar olan range mi mesela?
- daha kolay nasil yaparim bunu?

... yardim edene bira ve biralar.
Link to comment
Sosyal ağlarda paylaş

https://github.com/googlemaps/google-maps-services-python/



for i in range(0,8) dediginde asagidaki tablonun idleri.bastaki 0..8.



yukaridaki github a bak.cok kisa oz anlatmis. onunla halledicen olayi zaten.

sunlarda python videolari: https://www.youtube.com/user/sentdex/playlists

https://www.youtube.com/user/derekbanas/search?query=python

bunlarada goz attin mi problem kalmaz.

Link to comment
Sosyal ağlarda paylaş

pulkas said:



ben yanlış anlamışım.

o range *.csv'den alacağı yeri gösteriyor zannediyordum.

peki şimdi csv dosyası boş diye error alıyorum?
pandas.io.common.EmptyDataError: No columns to parse from file

origin, destinationları nerden alıyor yani?

edit: tamam indexing muhabbetini okudum şimdi, yani 0 1 2 3 4 diye kendim indexli csv oluşturmam lazım / for i derken for index'miş - baya noob'um da :D
Link to comment
Sosyal ağlarda paylaş

yine error ve yine yetemiyorum.
okuyorum ama niye hata verdigini anlamadim tabi ki...

line 37:
cities['distance'][i] = finddist(source,destination)

benim kod

import googlemaps
from datetime import datetime


def finddist(source, destination):
gmaps = googlemaps.Client(key='benim key')
now = datetime.now()
directions_result = gmaps.directions(source,destination,mode="driving",departure_time=now)
for map1 in directions_result:
overall_stats = map1['legs']
for dimensions in overall_stats:
distance = dimensions['distance']
return [distance['text']]

def findtime(source, destination):
gmaps = googlemaps.Client(key='benim key')
now = datetime.now()
directions_result = gmaps.directions(source,destination,mode="driving",departure_time=now)
for map1 in directions_result:
overall_stats = map1['legs']
for dimensions in overall_stats:
duration = dimensions['duration']
return [duration['text']]

import numpy as np
import pandas as pd
import pylab as pl
import os
os.chdir("/users/goering/documents")
cities = pd.read_csv("cities.csv")

cities[distance] = 0
cities[time] = 0
for i in range(0, 8):
source = cities['Source'][i]
destination = cities['Destination'][i]
cities['distance'][i] = finddist(source,destination)
cities['time'][i] = findtime(source,destination)



error

/Users/goering/PycharmProjects/untitled/maps/__init__.py:37: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
cities['distance'][i] = finddist(source,destination)
/Users/goering/.virtualenvs/lxmltest/lib/python2.7/site-packages/pandas/core/indexing.py:132: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
self._setitem_with_indexer(indexer, value)
/Users/goering/PycharmProjects/untitled/maps/__init__.py:38: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

Link to comment
Sosyal ağlarda paylaş

tamam bunu da cozdum

benim hiyarligim python 2.*'den run ettigim icinmis

3.* dan baslattim...

googlemaps module yok diyor simdi de :(

pip install googlemaps
diyince de requirement already satisfied :(:(:(

error

ImportError: No module named 'googlemaps'



ben mi kuramamisim, .virtualize falan da var? yoksa googlemaps mi kalkmis?
Link to comment
Sosyal ağlarda paylaş

Goering said:

pycharm'dan project interpreter secmemisim, yine benim hiyarligimmis.

tesekkur ederim yardimlarin icin, istanbuldaysan bira ismarlarim...


bu arada pycharm in icinde paket yoneticisi var.Professional olani ogrenciye beles.Communitysinde de var olabilir ote yandan.

https://www.jetbrains.com/help/pycharm/2016.1/installing-uninstalling-and-upgrading-packages.html
Link to comment
Sosyal ağlarda paylaş

module'leri yine pycharm icinde yukledim.
3.5 icin...

ayni hata geri geldi:

error

/Users/goering/PycharmProjects/untitled/maps/__init__.py:37: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
cities['distance'][i] = finddist(source,destination)
/Users/goering/.virtualenvs/lxmltest/lib/python2.7/site-packages/pandas/core/indexing.py:132: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
self._setitem_with_indexer(indexer, value)
/Users/goering/PycharmProjects/untitled/maps/__init__.py:38: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame



-ayni mesaj ama bu sefer 3.5 ve virtualenv degil- ustteki mesajdan aldim yenisini paste etmedim, ayni cunku...
Link to comment
Sosyal ağlarda paylaş

Traceback error

error

Traceback (most recent call last):
File "/Users/goering/PycharmProjects/untitled/maps/__init__.py", line 38, in
cities['distance'][i] = finddist(origin, destination)
File "/Users/goering/PycharmProjects/untitled/maps/__init__.py", line 8, in finddist
directions_result = gmaps.directions(origin, destination, mode="driving", departure_time=now)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/googlemaps/directions.py", line 99, in directions
"origin": convert.latlng(origin),
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/googlemaps/convert.py", line 79, in latlng
normalized = normalize_lat_lng(arg)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/googlemaps/convert.py", line 107, in normalize_lat_lng
"but got %s" % type(arg).__name__)
TypeError: Expected a lat/lng dict or tuple, but got float

Link to comment
Sosyal ağlarda paylaş

VIM'de calistirdigim icin yukaridaki hatayi aliyormusum,
yani cevap alamadigi icin onu anlayabildim :)


simdi...

hata kodum bu: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
A value is trying to be set on a copy of a slice from a DataFrame

line 37:
cities['distance'] = finddist(source, destination)

bunu [i]chained indexing
olmadan yazmam lazim...

buna gore:

http://s000.tinyupload.com/index.php?file_id=15796154154408368457

Link to comment
Sosyal ağlarda paylaş

×
×
  • Yeni Oluştur...