
Python
白杰(高光谱激光雷达遥感)
“长期致力于高光谱激光雷达定量遥感与应用研究”。中国科学院院长奖获得者,全国激光雷达优秀博士学位论文奖获得者
展开
-
python2 arcpy.CreateFeatureclass_management()输入参数设置
【代码】python2 arcpy.CreateFeatureclass_management()输入参数设置。原创 2023-03-21 19:48:57 · 971 阅读 · 0 评论 -
arcpy程序最好不要依赖于arcmap运行程序MakeFeatureLayer_management,而要用CopyFeatures_management
可以选择使用CopyFeatures_management函数先将生成的文件保存到本地,然后在执行其他函数时,函数输入参数不要写为arcmap里现有的图层,而是指定为已经在本地的文件的绝对路径,这样就不会在gis中执行函数,大大提高了运行速率。arcpy程序最好不要MakeFeatureLayer_management,这样会在arcmap中产生图层layer,再去调用类似相交分析的功能时,就会在gis中执行,减慢运行速率。原创 2023-03-21 11:18:43 · 926 阅读 · 0 评论 -
arcpy取特定像元值应该用经纬度字符串,而不是行列号
【代码】arcpy取特定像元值应该用经纬度字符串,而不是行列号。原创 2023-03-19 09:56:02 · 157 阅读 · 0 评论 -
python3 字符串转为路径
os.path.dirname()原创 2022-12-04 23:24:31 · 2202 阅读 · 0 评论 -
【转载】进程、线程、多线程概念详解
进程、线程、多线程概念详解转载 2022-11-06 21:19:36 · 241 阅读 · 0 评论 -
plt.scatter报错ValueError: s must be a scalar, or float array-like with the same size as x and y
报错:ValueError: s must be a scalar, or float array-like with the same size as x and y原因,scatter函数没有严格参数输入格式改正解决!原创 2022-10-28 22:12:20 · 4457 阅读 · 0 评论 -
UnboundLocalError: local variable ‘Band780‘ referenced before assignment
这是因为 rowList中没有找到 == ‘784’,查看rowList知道是数据类型的问题。原创 2022-09-03 13:41:56 · 233 阅读 · 0 评论 -
Python 读取csv后在所有列中找到特定想要的几列,并将其单独存为一个新的csv
【代码】Python 读取csv后在所有列中找到特定想要的几列,并将其单独存为一个新的csv。原创 2022-09-02 15:28:41 · 2073 阅读 · 0 评论 -
python os.system一个脚本中顺序执行多个脚本报错怎么办?
# -*- coding: utf-8 -*-"""Created on Thu May 5 16:35:46 2022@author: Lenovo"""import osrootDir = u'E:\\AIRCAS\\B科研论文专利\\4投稿\\数据处理'os.system(os.path.join(rootDir,'1smoothingdata.py'))os.system(os.path.join(rootDir,'2normalization.py'))os.system(o原创 2022-05-05 21:00:10 · 1675 阅读 · 0 评论 -
python re.search模糊匹配字符串/找出含有指定某几个/多个字符串的文件
paths = ['bbb','bbb123ccc']result = []for fname in paths: match1 = re.search('bbb', fname) match2 = re.search('ccc', fname) #re.search()方法扫描整个字符串,并返回第一个成功的匹配。如果匹配失败,则返回None。 if match1: if match2: result.append(fname)原创 2022-05-05 15:38:29 · 3547 阅读 · 0 评论 -
python float型(小数型)等差数列相等间隔列表生成
def PolynomialFunc(R): a8 = 9.536789998906224e-14 a7 = -1.6140913734735798e-11 a6 = 1.23390327559906e-09 a5 = -5.6346849959531704e-08 a4 = 1.7132562642642067e-06 a3 = -3.660798456800642e-05 a2 = 0.0005657675405418512 a1 = -0原创 2022-05-03 17:26:55 · 2143 阅读 · 0 评论 -
Python 按行读取txt中数据并转为float型
file = open(file_path,'r') file_data = file.readlines() target_data = re.split('\s+',file_data[1].strip()) for index,item in enumerate(target_data): target_data[index] = float(item)原创 2022-04-28 18:17:29 · 3190 阅读 · 0 评论 -
Python3 创建txt时FileNotFoundError: [Errno 2] No such file or directory:
finalfile1 = open(final_piecewiseParameters)创建txt时FileNotFoundError: [Errno 2] No such file or directory:解决open参数中加一个‘a’就可以。finalfile1 = open(final_piecewiseParameters,'a')原创 2022-04-28 17:16:53 · 1118 阅读 · 0 评论 -
Python3 LinAlgError: SVD did not converge in Linear Least Squares
有用的话记得回过头请给本文点个赞,感谢您的支持!LinAlgError: SVD did not converge in Linear Least Squares说明在拟合时,y值里存在nan值,ps:虽然你的原始文件中可能没有nan值,但是可能存在数值类型不是float型或完全的整型的数据,导致读出来的数据中有nan值,我就遇到一个,如图,读出来有一个是nan值,原始文件中是一个float型数字。解决方法,去掉该数据。y = lsit(y)nan_index = []for i in r原创 2022-04-28 14:35:26 · 11106 阅读 · 3 评论 -
Python3 TypeError: cannot do slice indexing on Index with these indexers [1] of type int
读取excel时,不加header=None,则报错TypeError: cannot do slice indexing on Index with these indexers [1] of type int temp_df = pd.read_excel(current_file) row_list = list(temp_df.loc[0,1:]) column_list = list(temp_df.loc[1:,0]) TypeError: cannot do原创 2022-04-27 20:01:24 · 13677 阅读 · 0 评论 -
Python3 pd.dataframe写入csv和xlsx
Python3 pd.dataframe写入csv和xlsx。代码如下:df = pd.DataFrame( columns={'dist','distance','409','425', '442', '458', '474', '491', '507', '523', '540', '556','572', '589', '605', '621', '637', '653', '670', '686', '703', '719', '735', '751', '768', '784','80原创 2022-01-18 17:33:39 · 3752 阅读 · 0 评论 -
Python ValueError: invalid literal for int() with base 10: os.listdir()检索文件后排序
1 ValueError: invalid literal for int() with base 10:fPath = 'F:\\RAPID MODELING v3_mixed_Cab_changing_random\\'folder_name = os.listdir(fPath) folder_name.sort(key=lambda x: int(x[8:])) File "F:\create_R2_RMSE_RAPID_leaf_Cab_vegetation_index.py",.原创 2021-09-13 17:32:02 · 238 阅读 · 0 评论 -
Python plt.legend绘图图例显示不全只显示一个字符
上原码: ax.legend(labels = 'band',loc='upper center') ax.legend(labels = 'band',loc='best') 结果图:原因是因为将图例放到legend里了,应该放到plt.plot里,改后代码:plt.plot(timeData,intensityData,c = 'blue',linewidth = 1,label='band')ax.legend(loc='best')plt.plot(timeD原创 2021-08-29 10:27:42 · 14279 阅读 · 6 评论 -
Python IndexError: list assignment index out of range
import osimport numpy as npimport pandas as pdimport reimport mathimport matplotlib.pyplot as pltfrom scipy import interpolatedef main(): fPath = 'F:\\RAPID MODELING v3_0824\\' folder_num = os.listdir(fPath) file_name = 'waveform_sgl.原创 2021-08-28 20:54:39 · 921 阅读 · 0 评论 -
Python 正则表达式解决Value error:could not convert string to float问题
正则表达式参见链接,用于解决读取二进制文件dat或txt文件中的数据,去除空白字符和首尾字符等,上代码。 fPath = 'F:\\RAPID MODELING v3_0824\\' folder_num = os.listdir(fPath) file_name = 'waveform_sgl_1000_1000.dat' columns = ['time(ns)','400','435','470','505','540','575','610','645','68原创 2021-08-27 10:50:36 · 2098 阅读 · 0 评论 -
Python3 每行将多个元素/数字写入txt 按行写入txt
file = open(outputfile,'a') #f.writelines()每行写入多个变量 #f.write()每行写入单个变量 for b in range(index_540,index_840+1): for i in range(1,8): I_lambda_0 = [] I_lambda_alpha = [] alpha = [] for f ...原创 2020-12-08 20:35:13 · 3073 阅读 · 0 评论 -
Python3 df.loc和df.iloc函数用法及提取指定行列位置处数值
关于pandas.dataframe.loc与pandas.dataframe.iloc用法官方说明,见官网。df.loc和df.iloc函数用法的df由pandas.read_csv()函数读取而来。1. DataFrame.locAccess a group of rows and columns by label(s) or a boolean array..loc[] is primarily label based, but may also be used with a boolean原创 2020-11-29 12:44:32 · 23934 阅读 · 3 评论 -
Python3 多线程threading处理xlsx/csv数据
Python如果单线程执行代码去处理数万个xlsx,包括读出和写入的操作,整个过程耗时会很长。本文以处理一批15000个csv文件为例,对比Python3单线程和多线程处理效率。任务:每一个csv包括三个波段的内容,将其分解成三个波段,总共产生45000个文件。import osfrom pandas import Seriesimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport reimport原创 2020-11-19 22:16:54 · 2286 阅读 · 2 评论 -
python3 将RTK中点导出后整理为单位为度,存为csv
python3 将RTK中的点导出后整理为unit为degree的点# -*- coding: utf-8 -*-"""Created on Fri Sep 18 23:22:15 2020@author: Yiting_BAI"""import numpy as npimport pandas as pdimport os# set the path of the xlsinput_path = 'E:\\AIR_CAS\\怀来遥感综合试验站实验\\'output_fn = os原创 2020-09-19 00:25:03 · 506 阅读 · 0 评论 -
Python2.7.3 ArcGIS10.2下的Python2.7.3安装pip之SyntaxError: invalid syntax解决方法
SyntaxError: invalid syntax1.实现cmd中调gis下python2除了拖动gis下的python.exe进命令行,就是:在用户变量和环境变量的path中将python2.7.3的安装路径==C:\Python27\ArcGIS10.2==置顶,然后重新启动计算机。然后在cmd中输入python,此时就是gis下的python2。如此,可以方便调用,arcpy实验任务结束后请将其置末,让python优先。2.安装setuptoolsArcgis10.2下自带的python原创 2020-08-17 22:36:10 · 1688 阅读 · 2 评论 -
python3.6版本的tensorflow2.0.0离线安装
Microsoft Windows [版本 10.0.18363.900]© 2019 Microsoft Corporation。保留所有权利。C:\Users\Administrator>activate deeplearning(deeplearning) C:\Users\Administrator>pip install C:\tensorflow-2.0.0-cp36-cp36m-win_amd64.whlProcessing c:\tensorflow-2.0.0-cp36原创 2020-06-28 00:50:02 · 2291 阅读 · 2 评论 -
python2 使用arcpy自定义GIS工具箱,实现excel读取、空间插值
一、实验目的1.掌握Arcpy基本语法、功能函数2.学会使用Arcpy自定义GIS工具箱3.使用arcpy进行空间插值4.自定义创建的Arcmap制图模板,使用arcpy调节图例、注记、比例尺等位置二、实验内容1.arcpy包自定义工具箱,选择文件,生成新的文件名,按照第4列经、第5列纬度,生成点矢量图形.2.按照第6列地面高程数据进行spline空间插值,生成空间插值后的图层,在第...原创 2020-01-20 13:18:47 · 4695 阅读 · 4 评论 -
python3 ogr AttributeError: 'NoneType' object has no attribute 'GetLayer'
在使用osgeo.ogr的时候,发现ds.GetLayer(0)报错:AttributeError: ‘NoneType’ object has no attribute ‘GetLayer’原因是fn路径有问题.原代码:from osgeo import ogrfn = 'E:\meichuan_prec_station.shp'ds = ogr.Open(fn,False)lay...原创 2019-11-24 11:42:58 · 6063 阅读 · 2 评论 -
python3 批量读取指定目录下指定后缀的所有文件
# 读取TRMM影像data = []g = os.walk("C:/Users/KAI/Desktop/PYTHON作业/卫星降雨数据TRMM3B43_分辨率0.25度")for path,d,filelist in g: for filename in filelist: if filename.endswith('TIF'): st...原创 2019-11-16 15:24:48 · 1679 阅读 · 0 评论 -
python3 用地面站点实测降雨数据校正TRMM/3B43遥感降雨数据
目的:学习用地面站点实测降雨数据校正卫星遥感降雨数据。学习将多景遥感图像绘制成在一张图上,且使用同一个colorbar原始数据:2007-2010年的TRMM卫星3B43产品(2013年12个月的月降雨数据,覆盖范围精度-180180、纬度-5050,0.25x0.25度分辨率,像素值单位:mm/hour);江西梅川江地区63个气象站的2007-2010年的月降雨数据,以及站点位置SHAP...原创 2019-11-16 14:27:35 · 4466 阅读 · 9 评论 -
python3 用地面雨量计数据校正TRMM/3B43数据之模型建立
本文数据为处理后的TRMM累计年降水量数据和雨量计累计年降水量数据# -*- coding: utf-8 -*-"""Created on Tue Nov 12 19:31:07 2019@author: BAI Depei"""from osgeo import ogrfrom osgeo import gdalimport numpy as npimport sympy ...原创 2019-11-16 09:49:14 · 2164 阅读 · 6 评论 -
python3 matplotlib多个子图对应同一个colorbar
python3 matplotlib多个子图对应同一个colorbar# -*- coding: utf-8 -*-"""Created on Tue Nov 12 19:31:07 2019@author: BAI Depei"""from osgeo import gdalimport numpy as npimport sympy as spimport matplotl...原创 2019-11-15 23:50:14 · 14090 阅读 · 0 评论 -
python3 怎么把公式和图片合并起来?
一、利用python生成图片二、打开Word,添加文本框到左上角,输入公式三、将其另存为pdf文件四、将PDF拖入Photoshop五、裁剪六、另存储为图片jpg,选择质量为最佳点击okay七、查看公式和图片合体后的图片局部放大,分辨率居高不下~八、如果有用的话,请你给我点个赞R2 = a*asquare = (np.array(data_TRMM_stat...原创 2019-11-15 00:27:26 · 653 阅读 · 0 评论 -
python3 装包http失败 An HTTP error occurred when trying to retrieve this URL.
通常装包的时候响应半天最后告诉你失败了,http延时了什么的,多半是包的地址在国外。先用学校的校园网,CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-64/sympy-1.4-py36_0.condaElapsed: -An HTTP error occu...原创 2019-11-12 23:42:09 · 1108 阅读 · 0 评论 -
python3 根据表格给出的信息批量修改文件名
数据:杂乱无章的数据文件名&留学生中心给的选课签字表代码:# -*- coding: utf-8 -*-"""Created on Sat Nov 2 17:00:20 2019@author: BAI Depei"""import openpyxl as oximport os#依据老师给的最终的成绩打分表,依据学号修改收到的作业的名称(按照表中的顺序...原创 2019-11-02 22:21:11 · 1843 阅读 · 0 评论 -
python3 判断.xlsl表的两列是否一致
数据代码# -*- coding: utf-8 -*-"""Created on Fri Nov 1 15:29:41 2019@author: Bai Depei"""import openpyxl as ox#判断两个签字表中的两列数据是否一致,相等#-----------------------------读取两个表-----------------------...原创 2019-11-01 17:37:31 · 1614 阅读 · 0 评论 -
python3 计算各类地物NDVI均值及将NDVI异常值栅格像元写为点矢量图形
作业一请利用下列数据统计各类土地利用类型的NDVI均值。NDVI值通常位于-1至1之间,请将该地区NDVI异常值发生的像元位置和具体数值,生成一个点shape文件。数据:(1) Landsat8地面反射率文件LC08_L1TP_121041_121042_20190312_T1_sr_scale_mosaic_clip.tifLandsat8的NDVI公式:NDVI = (Band5-B...原创 2019-10-26 21:58:42 · 4567 阅读 · 8 评论 -
Python学习(一)Windows下如何对Anaconda和Python进行环境配置及安装和定位包
摘要:简单介绍了python语言和其他语言的区别、anaconda的结构、以及如何在Windows系统下对二者进行环境配置、和如何安装包到指定环境位置或者查看某包所在位置。说白了要介绍的内容就是,python和其他语言有什么不一样,anaconda是什么,它长什么样,什么是环境,为什么要配置环境,怎么配置环境,怎么在python和anaconda下安装想要的包,怎么指定包的安装位置,怎么知道以前...原创 2019-09-08 12:30:45 · 3078 阅读 · 0 评论