def fenzhixiang_points(r,f_dir): coor_dic = r.fenzhiiang() directory = f_dir if not os.path.isdir(directory): os.mkdir(directory) fname = directory+'\\fenzhixiang' point=[] if coor_dic: for i in coor_dic: point.append((coor_dic[i][0],coor_dic[i][1],coor_dic[i][2],'','','','')) # print point wp.point_to_shp(point,fname+'.shp')
def dianxiangan_dian_shp(r,f_dir): if r.dianxiangan(): dianxiangan_lon, dianxiangan_lat, dianxiangan_name, dianxiangan_qianduan,line_type_list, distance_str_list, ganta_type_list = r.dianxiangan() directory = f_dir dianxiangan_coor_dic = {} for i in range(len(dianxiangan_lon)): dianxiangan_coor_dic[i] = [dianxiangan_lon[i],dianxiangan_lat[i],dianxiangan_qianduan[i],dianxiangan_name[i],ganta_type_list[i]] if not os.path.isdir(directory): os.mkdir(directory) fname = directory+'\\dianxiangan' point=[] for i in dianxiangan_coor_dic: point.append([dianxiangan_coor_dic[i][0],dianxiangan_coor_dic[i][1],dianxiangan_coor_dic[i][3],dianxiangan_coor_dic[i][2],dianxiangan_coor_dic[i][4],'','']) wp.point_to_shp(point,fname+'.shp')
def bianyaqi_shp(r,f_dir): bianyaqi_lon, bianyaqi_lat, bianyaqi_label = r.didianyapeidianxiang() # print(bianyaqi_lon, bianyaqi_lat, bianyaqi_label) bianyaqi_label = bianyaqi_label # print(f_dir) # exit() directory = f_dir if not os.path.isdir(directory): os.mkdir(directory) fname = directory+'bianyaqi.shp' # fname = fname.encode('gbk') # print(directory) # exit() # print(bianyaqi_lon, bianyaqi_lat, bianyaqi_label) wp.point_to_shp([[bianyaqi_lon,bianyaqi_lat,str(bianyaqi_lon),str(bianyaqi_lat),bianyaqi_label,'','']],fname)
def select_vertical_horizontal(r,f_dir): # transparent = transparent_jiliangxiang(r) transparent, red, black = r.full_and_spare_and_transparent_jiliangxiang() dianbiao_dic = r.jiliangxiang() lon=[] lat=[] if r.dianxiangan(): lon_list,lat_list,name_list,qianduan_list,_,_,_ = r.dianxiangan() for i in range(len(lon_list)): lon.append(lon_list[i]) lat.append(lat_list[i]) bianyaqi_lon,bianyaqi_lat,_ = r.didianyapeidianxiang() directory = f_dir if not os.path.isdir(directory): os.mkdir(directory) fname = directory+'\\extent_lyr.shp' for i in dianbiao_dic: lon.append(dianbiao_dic[i][0]) lat.append(dianbiao_dic[i][1]) for i in transparent: lon.append(transparent[i][0]) lat.append(transparent[i][1]) lon.append(bianyaqi_lon) lat.append(bianyaqi_lat) # print max(lon),min(lon) # print max(lat),min(lat) # print (max(lon)-min(lon))/(max(lat)-min(lat)) fw = open(directory+'\\select.txt','w') if (max(lon)-min(lon))/(max(lat)-min(lat)) >1: fw.write('heng') else: fw.write('shu') fw.close() lon_offset=(max(lon)-min(lon))*.1 lat_offset=(max(lat)-min(lat))*.1 lon_list=[max(lon)+lon_offset,min(lon)-lon_offset] lat_list=[max(lat)+lat_offset,min(lat)-lon_offset] points=[] for i in range(2): points.append([lon_list[i],lat_list[i],'','','','','']) wp.point_to_shp(points,fname)
def qiangzhijia_shp(r,f_dir): if r.diyaqiangzhijia(): # lon_list, lat_list, qianduan_list, name_list, types_list lon_list,lat_list,qianduan,name,types,_ = r.diyaqiangzhijia() directory = f_dir if not os.path.isdir(directory): os.mkdir(directory) qiangzhijia_coor_dic={} for i in range(len(lon_list)): qiangzhijia_coor_dic[i] = [lon_list[i],lat_list[i],qianduan[i],name[i],types[i]] fname = directory+'\\qiangzhijia' point=[] for i in qiangzhijia_coor_dic: point.append([qiangzhijia_coor_dic[i][0],qiangzhijia_coor_dic[i][1],qiangzhijia_coor_dic[i][2],qiangzhijia_coor_dic[i][3],qiangzhijia_coor_dic[i][4],'','']) wp.point_to_shp(point,fname+'.shp')
def jiliangxiang_shp(r,f_dir): transparent, red, black = r.full_and_spare_and_transparent_jiliangxiang() directory = f_dir if not os.path.isdir(directory): os.mkdir(directory) fname_trans = directory+'\\transparent' fname_red = directory+'\\red' fname_black = directory+'\\black' point_trans = [] point_red = [] point_black = [] for i in transparent: # 姓名换行 new_name = '' # print '***'.join(transparent[i][2]) break_point = int(len(transparent[i][2]) / 2) if break_point == 0: break_point = 1 for ii,name in enumerate(transparent[i][2]): new_name += name + ' ' if (ii + 1) % break_point == 0 and not ii == 0: new_name += '\n' # point_trans.append([transparent[56i][0],transparent[i][1],' '.join(transparent[i][2]),i,'','','','']) point_trans.append([transparent[i][0],transparent[i][1],new_name,i,'','','','']) # exit() for i in range(len(red)): point_red.append([red[i][1],red[i][2],'',red[i][0],red[i][3],'','']) for i in range(len(black)): point_black.append([black[i][1],black[i][2],'',black[i][0],black[i][3],'','']) # print len(point_trans) # print len(red) # print len(black) wp.point_to_shp(point_trans,fname_trans+'.shp') wp.point_to_shp(point_red,fname_red+'.shp') wp.point_to_shp(point_black,fname_black+'.shp')