![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python日常记录
python琐碎
LP点绛唇
古代剑客们在与对手狭路相逢时,不论对手有多么强大,就算对方是天下第一剑客,明知不敌,也要亮出自己的宝剑,即使倒在对手剑下也不丢人。这就是亮剑精神。
展开
-
Python-读取Excel
Python原创 2022-07-27 10:22:01 · 294 阅读 · 1 评论 -
Arcpy-波段合成
import fnmatchimport osimport arcpyFCIout_path = '**********************'FCIout_path02 = '*****************************'for i in range(1, 86): print(i) _B12 = fnmatch.filter(os.listdir(FCIout_path), str(i) + '_B12_*.tif') _B11 = fnmatch.原创 2022-05-13 22:48:54 · 623 阅读 · 0 评论 -
Arcpy-统计shp表数量
import arcpyimport osimport fnmatch# import Tile# tile = Tile.tilestile = 'T55GDN'shpunionf = 'E:/Atest/' + tile + '/Iboundary/Export_Output03.shp'rows = arcpy.SearchCursor(shpunionf, ["FId"])count = 0for row in rows: count = count + 1pr..原创 2022-05-10 20:43:54 · 445 阅读 · 0 评论 -
python-日常记录
outdirftf = 'E:/Atest/T33NVG/HHproduct20/BA20clip/'allshpftp = fnmatch.filter(os.listdir(outdirftf), '*.tif')原创 2022-05-09 22:48:07 · 163 阅读 · 0 评论 -
Python-查找文件
outdirftf = 'E:/'allshpftp = fnmatch.filter(os.listdir(outdirftf), '*.tif')原创 2022-05-09 22:46:35 · 329 阅读 · 0 评论 -
python-数组画条形图
import matplotlibimport matplotlib.pyplot as pltimport gdalimport numpy as npimport osimport fnmatchplt.figure("lena")# arr 就是需要计算的直方图的一维数组 # bins 就是直方图的柱数 # facecolor: 直方图颜色 # alpha: 透明度# 返回值 : # n: 直方图向量,是否归一化由参数设定 # bins: 返回各个bin的区间范围 # pat.原创 2021-12-02 13:49:00 · 1652 阅读 · 0 评论 -
python-查找目录下所有指定后缀名的文件
import osimport shutildef findAllFilesWithSpecifiedSuffix(target_dir, target_suffix="jp2"): find_res = [] target_suffix_dot = "." + target_suffix walk_generator = os.walk(target_dir) for root_path, dirs, files in walk_generator: .原创 2021-11-02 09:53:17 · 549 阅读 · 0 评论 -
python-数组计算
1、二维数组求和a = [[1,2],[3,4],[5,6]]print(sum(sum(i) for i in a))2、剔除numpy数组中的0值import numpy as nparray = [1, 1, 0, 3, 4, 5, 0]a = np.array(array)b = a[a != 0]print(b) # [1 1 3 4 5]3、numpy一维数组,求和、均值、方差、标准差import numpy as nparray = [1, 1, 0, 3原创 2021-10-12 15:40:00 · 2120 阅读 · 0 评论 -
python-opencv-画外接矩形框
画外接矩形框,可以画成一个最大的,也可以分别画。# -*- coding: utf-8 -*-import cv2image = cv2.imread('G:/110w2/mask_tif4/00.png')print(image.shape)print(image.shape[0]) # hprint(image.shape[1]) # w# 图像转灰度图img = cv2.cvtColor(image, cv2.COLOR_BGR...原创 2021-09-02 22:15:47 · 5333 阅读 · 0 评论 -
python-opencv-图像上画矩形框
就是根据坐标,在图片上画一个矩形框。import cv2image = cv2.imread('G:/110w2/mask_tif4/0.png')a = (204, 136, 259, 164)cv2.rectangle(image, (a[0], a[1]), (a[2], a[3]), (0, 0, 255), 2)# 图片显示cv2.imshow("image",image)# 图片保存cv2.imwrite('G:/110w2/mask_tif4/1_.png', image原创 2021-09-02 21:55:59 · 5063 阅读 · 0 评论 -
python-opencv-图像旋转
这种旋转方式,旋转后的图像,是原图的外接矩形框,四个角的部分,填充了黑色。import cv2import numpy as np# 旋转angle角度,缺失背景白色(255, 255, 255)填充def rotate_bound_white_bg(image, angle): # grab the dimensions of the image and then determine the # center (h, w) = image.shape[:2]原创 2021-09-02 21:51:15 · 764 阅读 · 0 评论