
Python
~
小松鼠想吃大闸蟹
这个作者很懒,什么都没留下…
展开
-
基于梯度下降法的线性回归拟合以及绘制图形(Python代码)
Tips:采用梯度下降法实现线性回归,同时可批量绘制散点图和拟合曲线以及损失图。样例数据:拟合曲线图:损失曲线:Python代码:#!/usr/bin/env python# -*- coding: utf-8 -*-"""Created on Fri Jan 22 15:05:16 2021E-mail: 1321378489@qq.com@author: xiao_gf"""import mathimport numpy as npimport pandas a原创 2021-02-04 17:33:01 · 1441 阅读 · 0 评论 -
栅格数据批量裁剪(Python)
Tips:基于GDAL库的gdal.Warp工具实现栅格数据的批量裁剪功能。#!/usr/bin/env python# -*- coding: utf-8 -*-"""Created on Fri Jan 8 16:31:59 2021E-mail: 1321378489@qq.com@author: xiao_gf"""import time,osfrom osgeo import gdalimport numba @numba.jit # 程序加速def clip原创 2021-01-08 16:35:42 · 1669 阅读 · 2 评论 -
矢量文件按照属性值批量提取(Python代码)
Tips: 通过ArcGIS可实现提取,本代码主要是批量处理。仅供参考~代码适应样例说明:数据:2000-2018年逐年的全国县级人口数据,例如:2000_population.shp、2001_population.shp等要求:分布提取每年每个省份的县级人口数据数据属性表:字段包括:FID、population、cityName等最后结果:输出19个文件夹,每个文件夹中包括各省份的人口数据#!/usr/bin/env python# -*- coding: utf-8 -*-"""C原创 2020-12-30 10:42:00 · 1515 阅读 · 4 评论 -
区域统计批处理功能(Python代码)
Tips :本代码实现ArcGIS中的区域统计功能(Zonal),将统计的属性值直接赋予矢量文件属性表,可实现批量统计。import ogr, osfrom rasterstats import zonal_statsdef zonal(input_vector,in_raster,Stats_type,raster_name): shp = ogr.Open(input_vector,1) lyr = shp.GetLayer()原创 2020-12-18 10:27:03 · 1493 阅读 · 2 评论 -
多波段影像数据区域统计(Python代码)
Tips :本代码实现ArcGIS中的区域统计功能(Zonal),有两点特色:1)能够将统计得到的属性值直接赋予矢量文件中;2)可实现多波段影像区域统计(方法比较笨,先拆分波段,然后进行统计)。区域统计的类型参考ArcGIS:MEAN— Calculates the average of all cells in the value raster that belong to the same zone as the output cell.MAJORITY — Determines the va原创 2020-12-18 10:17:03 · 1737 阅读 · 4 评论 -
nc数据批量转为tiff数据详细代码(Python代码)
#nc数据批量转为tiff数据详细代码(Python代码)# -*- coding: utf-8 -*-"""Created on Wed Dec 2 11:12:50 2020@author: xiao_gf"""import osimport numpy as npimport netCDF4 as ncfrom osgeo import gdal,osrdef strstr(str1, str2): #查找某一字符是否存在于另一字符串中,str2为需要查找的字符,str1原创 2020-12-14 17:28:07 · 4342 阅读 · 18 评论 -
中国气象数据网的.nc数据批量下载(Python代码)
中国气象数据网的.nc数据批量下载(Python代码)# -*- coding: utf-8 -*-"""Created on Thu Dec 10 13:55:39 2020@author: xiao下载链接列表格式样例:http://101.201.177.119/dlorder/orderData/xxx/Z_NAFP_C_BABJ_20191029012028_P_CLDAS_RT_CHN_0P0625_HOR-RSM000010-2019102900.nc?Expires=xxx&原创 2020-12-10 18:03:02 · 4315 阅读 · 2 评论