Esempio n. 1
0
    pass
  
  return ret



lon_lst = []
lat_lst = []

for index, row in df.iterrows():
  # a. 使用js api进行经纬度转换
  # params['latlng'] = str(row['Y']) + ',' + str(row['X'])
  # lon, lat = getLonLatFromGpssgp(t_url)
  
  # b. 使用计算公式进行经纬度转换
  lon, lat = gcj02towgs84(row['X'], row['Y'])
  lon_lst.append(lon)
  lat_lst.append(lon)  
  
  if index % 10000 == 0:
    print '-' * 8 + str(index) + '-' * 8

# 4. 数据转储为Excel
import shelve
import xlsxwriter
df['lon'] = lon_lst
df['lat'] = lat_lst

file_writer = pd.ExcelWriter('data/fdf.xlsx', engine='xlsxwriter')
df.to_excel(file_writer)
file_writer.save()
Esempio n. 2
0
# conding:utf-8

from coordTransform_utils import gcj02towgs84, bd09togcj02

lat, lng = 39.99062,116.306206
result4 = gcj02towgs84(lng, lat)

blat, blng = 12941606.14,4826039.41
result5 = bd09togcj02(blng, blat)

print result5


def getConnEngine(jdbc_file_path = 'data/jdbc.properties'):
  import csv
  from sqlalchemy import create_engine

  prop = {}
  with open(jdbc_file_path, 'r') as csvfile:
    prop_reader = csv.reader(csvfile, delimiter="=")
    prop = {row[0]:row[1] for row in prop_reader}

  conn_str = 'postgresql+pg8000://{0}:{1}@{2}:{3}/{4}'.format(
    prop['jdbc.user'], prop['jdbc.password'],
    prop['jdbc.host'], prop['jdbc.port'],
    prop['jdbc.dbname']
  )
  
  engine = create_engine(conn_str)
  return engine