【Earth Engine】基于GEE合成Landsat4/5/7/8/9影像并进行NDVI、NDWI和MNDWI等指数计算_landsat4—5tm影像波段组合-程序员宅基地

技术标签: Earth Engine  GEE  Landsat  遥感  NDVI  

1 简介与摘要

最近在做一个课题,需要逐月还有逐年的NDVI还有一系列衍生数据。
但是逐月的使用Sentinel影像会出现有云,并且掩膜掉容易出现空洞,所以我就想着可以拿Landsat来补充。
同样的思想,在逐年数据上也可以应用于不同的Landsat影像,这样可以丰富影像数量,提升计算质量。比如前一段时间刚上去的Landsat9,就号称可以和Landsat8协同,降低重访周期。
考虑到使用同一系列卫星的场景比较多,所以这篇博文就使用Landsat系列卫星的影像合成。

因此,结合实际应用场景,在这里需要做的工作是:

  1. 输入某一个时间(或时间段),得到ImageCollection,并且(以地图和数字的形式)显示兴趣区里的影像数量;
  2. 通过ImageCollection数据合成,并且计算一些基础的指数。

2 思路

首先,要获取一个包含我需要的时间段/影像质量/区域范围的Landsat系列影像,也就是一个Landsat的ImageCollection。
在得到ImageCollection之前,需要考虑一个问题——这些影像的相同的波段名可能对应不同的频率,比如说Landsat4/5/7的第四波段是近红外(NIR),而Landsat8/9的第四波段是红光(red),所以需要在这些波段重命名一下,这样合成才不会合错。
然后,就可以通过一个mean()(当然也可以其他的函数),将一个ImageCollection合成一个Image,以方便计算各种指数。
最后,通过预设的指数计算公式,计算指数即可。

总的来说,比较麻烦的是前半部分。后半部分的工作直接套用一些常规的做法就行了。

3 效果预览

惯例,在代码前面先放效果预览。
我在控制台展示了各个卫星匹配到的影像数量,还有合成后总的ImageCollection的影像数量。
在地图中显示合成后的真彩色和假彩色影像,还有计算后的NDVI、NDWI、MNDWI,最后还有各个区域影像数量的可视化。

在接下来的示例里,我时间段选取20200101——20210101,云量低于20%,兴趣区随手勾了一个大概希腊+土耳其(老精罗了)。

我的兴趣区(roi):
在这里插入图片描述

控制台:
在这里插入图片描述
上图的意思是Landsat8得到1484幅影像,Landsat7得到1411幅影像,合成后的ImageCollection有2895幅(1484+1411)影像。

合成后的真彩色影像:
在这里插入图片描述

合成后的假彩色影像:
在这里插入图片描述

NDVI(绿色是高值,红色是低值):
在这里插入图片描述

NDWI(蓝色是高值,白色是低值):
在这里插入图片描述

MNDWI(蓝色是高值,白色是低值):
在这里插入图片描述

影像数量(以像元为基本计算单位,红色是低值,绿色是中值,蓝色是高值):
在这里插入图片描述

4 代码思路

考虑到要调用Landsat4/5/7/8/9,所以先写上这些卫星的预处理函数,包括大气校正和云掩膜;其中4/5/7的函数通用,8/9的函数通用。如下:

function applyScaleFactorsL89(image) {
    
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBands, null, true);
}

function applyScaleFactorsL457(image) {
    
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBand = image.select('ST_B6').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBand, null, true);
}

function cloudmaskL89(image) {
    
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = (1 << 4);
  var cloudsBitMask = (1 << 3);
  // Get the pixel QA band.
  var qa = image.select('QA_PIXEL');
  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
                 .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return image.updateMask(mask);
}

function cloudMaskL457(image) {
    
  var qa = image.select('QA_PIXEL');
  // If the cloud bit (5) is set and the cloud confidence (7) is high
  // or the cloud shadow bit is set (3), then it's a bad pixel.
  var cloud = qa.bitwiseAnd(1 << 3)
                  .and(qa.bitwiseAnd(1 << 9))
                  .or(qa.bitwiseAnd(1 << 4));
  // Remove edge pixels that don't occur in all bands
  var mask2 = image.mask().reduce(ee.Reducer.min());
  return image.updateMask(cloud.not()).updateMask(mask2);
}

写完预处理的函数,就需要改波段名称,以便放在同一个ImageCollection里能自动合成。因此,需要写将波段重命名的函数,如下:

function bandRenameL89(image) {
    
  var blue = image.select(['SR_B2']).rename('blue');
  var green = image.select(['SR_B3']).rename('green');
  var red = image.select(['SR_B4']).rename('red');
  var nir = image.select(['SR_B5']).rename('nir');
  var swir1 = image.select(['SR_B6']).rename('swir1');
  var swir2 = image.select(['SR_B7']).rename('swir2');
  var new_image = blue.addBands([green, red, nir, swir1, swir2]);
  return new_image;
}

function bandRenameL457(image) {
    
  var blue = image.select(['SR_B1']).rename('blue');
  var green = image.select(['SR_B2']).rename('green');
  var red = image.select(['SR_B3']).rename('red');
  var nir = image.select(['SR_B4']).rename('nir');
  var swir1 = image.select(['SR_B5']).rename('swir1');
  var swir2 = image.select(['SR_B7']).rename('swir2');
  var new_image = blue.addBands([green, red, nir, swir1, swir2]);
  return new_image;
}

在这里,选取常用的光学波段,将波段重命名为blue、green、red、nir、swir1、swir2。
最后,根据波段名称,写指数计算的函数。和其他人的文章不同,这里的输入的波段名称是我们重命名后的(见上面的代码)。这里以NDVI、NDWI和MNDWI为例,如下:

function NDVI(img) {
    
 var nir = img.select("nir");
 var red = img.select("red");
 var ndvi = img.expression(
   "(nir - red)/(nir + red)",
   {
    
     "nir": nir,
     "red": red
   }
 );
 return ndvi;
}

function NDWI(img) {
    
 var green = img.select("green");
 var nir = img.select("nir");
 var ndwi = img.expression(
   "(green - nir)/(green + nir)",
   {
    
     "green": green,
     "nir": nir
   }
 );
 return ndwi;
}

function MNDWI(img) {
    
 var green = img.select("green");
 var swir1 = img.select("swir1");
 var mndwi = img.expression(
   "(green - swir1)/(green + swir1)",
   {
    
     "green": green,
     "swir1": swir1
   }
 );
 return mndwi;
}

好了,到这里,所有预置的函数都写完了。
接下来就是对各个卫星的影像预处理,然后放进同一个ImageCollection里。下面是利用上述的函数进行预处理,可以根据需要自行调整。如下:

// landsat 9
var l9_col = ee.ImageCollection('LANDSAT/LC09/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL89)
                  .map(cloudmaskL89)
                  .map(bandRenameL89)
                  ;
print('landsat9', l9_col.size())
// landsat 8
var l8_col = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL89)
                  .map(cloudmaskL89)
                  .map(bandRenameL89)
                  ;
print('landsat8', l8_col.size())
// landsat 7
var l7_col = ee.ImageCollection('LANDSAT/LE07/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL457)
                  .map(cloudMaskL457)
                  .map(bandRenameL457)
                  ;
print('landsat7', l7_col.size())
// landsat 5
var l5_col = ee.ImageCollection('LANDSAT/LT05/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL457)
                  .map(cloudMaskL457)
                  .map(bandRenameL457)
                  ;
print('landsat5', l5_col.size())
// landsat 4
var l4_col = ee.ImageCollection('LANDSAT/LT04/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL457)
                  .map(cloudMaskL457)
                  .map(bandRenameL457)
                  ;
print('landsat4', l4_col.size())

需要注意的是,roi是我们划定的研究区,sart_date和end_date是我们需要的影像时间范围,cloudCover是我们预设的最大云量,为了方便修改参数,一些影像要求(日期和云量)在这里我使用变量代替。另外,在每个卫星预处理函数后面,用size()函数print出了匹配到的影像数量。效果图见前一章。
接下来的工作就是把这些影像,合成一个ImageCollection。这里需要用到的函数是merge(),具体如下:

var image = l9_col
            .merge(l8_col)
            .merge(l7_col)
            .merge(l5_col)
            .merge(l4_col)
            ;
print("final image count", image.size(), image)

最后,调用指数计算的函数对最终合成的ImageCollection进行计算,不过在此之前需要先mean合成一下,如下:

print("final image count", image.size(), image)
var final_image = image.mean().clip(roi);
var image_ndvi = NDVI(final_image)
var image_ndwi= NDWI(final_image)
var image_mndwi = MNDWI(final_image)

最后简单写个可视化,包括NDVI、NDWI、MNDWI:

Map.addLayer(final_image, {
    bands: ["red", "green", "blue"], min:0.0, max:0.25}, "image")
Map.addLayer(final_image, {
    bands: ["nir", "red", "green"], min:0.0, max:0.25}, "image2")
var ndvi_palettes = ["#e700d5", "#e60000", "#e69f00", "#dfe200", "#7ebe00", "#00a10c", "#008110"];
Map.addLayer(image_ndvi.clip(roi), {
    min:-0.5, max:0.7, palette:ndvi_palettes}, "ndvi");
var ndwi_palettes = ["ffffff","#f9f9f9","#d8fdf4","#7dd5e9","3d7ede","243ad4","#1c00b8", "#250081"];
Map.addLayer(image_ndwi.clip(roi), {
    min:-0.5, max:0.7, palette:ndwi_palettes}, "ndwi");
Map.addLayer(image_mndwi.clip(roi), {
    min:-0.5, max:0.9, palette:ndwi_palettes}, "mndwi");

然后,顺手把影像数量的可视化写了,这里用到count(),如下:

var images_count = image.select('red').count();
Map.addLayer(images_count.rename('count').clip(roi), {
    min:10, max:80, palette:["#ff0000", "#fbff00", "#1dff02", "#02adff"]}, "images count");

好了,完成了。最后导出就行。

// export to drive
Export.image.toDrive(
  {
    
    image: image_ndvi.clip(roi),
    folder: "ndvi",
    description: "ndvi" + year_name,
    scale: 30,
    region: roi,
    maxPixels: 1e13
  })
Export.image.toDrive(
  {
    
    image: image_ndwi.clip(roi),
    folder: "ndwi",
    description: "ndwi" + year_name,
    scale: 30,
    region: roi,
    maxPixels: 1e13
  })
Export.image.toDrive(
  {
    
    image: image_mndwi.clip(roi),
    folder: "mndwi",
    description: "mndwi" + year_name,
    scale: 30,
    region: roi,
    maxPixels: 1e13
  })

对了,要记得在最前面补上需要更改的参数。

var year_name = 2020;
var start_date = (year_name) + '-01-01';
var end_date   = (year_name + 1) + '-01-01';
var cloudCover = 20

5 完整代码

我的代码链接在这,可以直接使用。
完整代码如下(和链接中相同):

var year_name = 2020;
var start_date = (year_name) + '-01-01';
var end_date   = (year_name + 1) + '-01-01';
var cloudCover = 20

Map.addLayer(roi)

// indices
function NDVI(img) {
    
 var nir = img.select("nir");
 var red = img.select("red");
 var ndvi = img.expression(
   "(nir - red)/(nir + red)",
   {
    
     "nir": nir,
     "red": red
   }
 );
 return ndvi;
}

function NDWI(img) {
    
 var green = img.select("green");
 var nir = img.select("nir");
 var ndwi = img.expression(
   "(green - nir)/(green + nir)",
   {
    
     "green": green,
     "nir": nir
   }
 );
 return ndwi;
}

function MNDWI(img) {
    
 var green = img.select("green");
 var swir1 = img.select("swir1");
 var mndwi = img.expression(
   "(green - swir1)/(green + swir1)",
   {
    
     "green": green,
     "swir1": swir1
   }
 );
 return mndwi;
}


function bandRenameL89(image) {
    
  var blue = image.select(['SR_B2']).rename('blue');
  var green = image.select(['SR_B3']).rename('green');
  var red = image.select(['SR_B4']).rename('red');
  var nir = image.select(['SR_B5']).rename('nir');
  var swir1 = image.select(['SR_B6']).rename('swir1');
  var swir2 = image.select(['SR_B7']).rename('swir2');
  var new_image = blue.addBands([green, red, nir, swir1, swir2]);
  return new_image;
}

function bandRenameL457(image) {
    
  var blue = image.select(['SR_B1']).rename('blue');
  var green = image.select(['SR_B2']).rename('green');
  var red = image.select(['SR_B3']).rename('red');
  var nir = image.select(['SR_B4']).rename('nir');
  var swir1 = image.select(['SR_B5']).rename('swir1');
  var swir2 = image.select(['SR_B7']).rename('swir2');
  var new_image = blue.addBands([green, red, nir, swir1, swir2]);
  return new_image;
}

function applyScaleFactorsL89(image) {
    
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBands, null, true);
}

function applyScaleFactorsL457(image) {
    
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBand = image.select('ST_B6').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBand, null, true);
}

function cloudmaskL89(image) {
    
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = (1 << 4);
  var cloudsBitMask = (1 << 3);
  // Get the pixel QA band.
  var qa = image.select('QA_PIXEL');
  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
                 .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return image.updateMask(mask);
}

function cloudMaskL457(image) {
    
  var qa = image.select('QA_PIXEL');
  // If the cloud bit (5) is set and the cloud confidence (7) is high
  // or the cloud shadow bit is set (3), then it's a bad pixel.
  var cloud = qa.bitwiseAnd(1 << 3)
                  .and(qa.bitwiseAnd(1 << 9))
                  .or(qa.bitwiseAnd(1 << 4));
  // Remove edge pixels that don't occur in all bands
  var mask2 = image.mask().reduce(ee.Reducer.min());
  return image.updateMask(cloud.not()).updateMask(mask2);
}



// get image collection
// landsat 9
var l9_col = ee.ImageCollection('LANDSAT/LC09/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL89)
                  .map(cloudmaskL89)
                  .map(bandRenameL89)
                  ;
print('landsat9', l9_col.size())
// landsat 8
var l8_col = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL89)
                  .map(cloudmaskL89)
                  .map(bandRenameL89)
                  ;
print('landsat8', l8_col.size())
// landsat 7
var l7_col = ee.ImageCollection('LANDSAT/LE07/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL457)
                  .map(cloudMaskL457)
                  .map(bandRenameL457)
                  ;
print('landsat7', l7_col.size())
// landsat 5
var l5_col = ee.ImageCollection('LANDSAT/LT05/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL457)
                  .map(cloudMaskL457)
                  .map(bandRenameL457)
                  ;
print('landsat5', l5_col.size())
// landsat 4
var l4_col = ee.ImageCollection('LANDSAT/LT04/C02/T1_L2')
                  .filterBounds(roi)
                  .filterDate(start_date, end_date)
                  .filter(ee.Filter.lt('CLOUD_COVER', cloudCover))
                  .map(applyScaleFactorsL457)
                  .map(cloudMaskL457)
                  .map(bandRenameL457)
                  ;
print('landsat4', l4_col.size())

// combine, mean and calculate
var image = l9_col
            .merge(l8_col)
            .merge(l7_col)
            .merge(l5_col)
            .merge(l4_col)
            ;
print("final image count", image.size(), image)
var final_image = image.mean().clip(roi);
var image_ndvi = NDVI(final_image)
var image_ndwi= NDWI(final_image)
var image_mndwi = MNDWI(final_image)

Map.addLayer(final_image, {
    bands: ["red", "green", "blue"], min:0.0, max:0.25}, "image")
Map.addLayer(final_image, {
    bands: ["nir", "red", "green"], min:0.0, max:0.25}, "image2")
var ndvi_palettes = ["#e700d5", "#e60000", "#e69f00", "#dfe200", "#7ebe00", "#00a10c", "#008110"];
Map.addLayer(image_ndvi.clip(roi), {
    min:-0.5, max:0.7, palette:ndvi_palettes}, "ndvi");
var ndwi_palettes = ["ffffff","#f9f9f9","#d8fdf4","#7dd5e9","3d7ede","243ad4","#1c00b8", "#250081"];
Map.addLayer(image_ndwi.clip(roi), {
    min:-0.5, max:0.7, palette:ndwi_palettes}, "ndwi");
Map.addLayer(image_mndwi.clip(roi), {
    min:-0.5, max:0.9, palette:ndwi_palettes}, "mndwi");


var images_count = image.select('red').count();
Map.addLayer(images_count.rename('count').clip(roi), {
    min:10, max:80, palette:["#ff0000", "#fbff00", "#1dff02", "#02adff"]}, "images count");



// export to drive
// export to drive
Export.image.toDrive(
  {
    
    image: image_ndvi.clip(roi),
    folder: "ndvi",
    description: "ndvi" + year_name,
    scale: 30,
    region: roi,
    maxPixels: 1e13
  })
Export.image.toDrive(
  {
    
    image: image_ndwi.clip(roi),
    folder: "ndwi",
    description: "ndwi" + year_name,
    scale: 30,
    region: roi,
    maxPixels: 1e13
  })
Export.image.toDrive(
  {
    
    image: image_mndwi.clip(roi),
    folder: "mndwi",
    description: "mndwi" + year_name,
    scale: 30,
    region: roi,
    maxPixels: 1e13
  })

6 后记

刚开始学习GEE,可能有些地方不太专业不太科学,希望诸位同行前辈不吝赐教或者有什么奇妙的想法可以和我共同探讨一下。可以在csdn私信我或者联系我邮箱([email protected]),不过还是希望大家邮箱联系我,csdn私信很糟糕而且我上csdn也很随缘。
如果对你有帮助,还望支持一下~点击此处施舍或扫下图的码。
-----------------------分割线(以下是乞讨内容)-----------------------
在这里插入图片描述

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Leaze932822995/article/details/125263489

智能推荐

c# 调用c++ lib静态库_c#调用lib-程序员宅基地

文章浏览阅读2w次,点赞7次,收藏51次。四个步骤1.创建C++ Win32项目动态库dll 2.在Win32项目动态库中添加 外部依赖项 lib头文件和lib库3.导出C接口4.c#调用c++动态库开始你的表演...①创建一个空白的解决方案,在解决方案中添加 Visual C++ , Win32 项目空白解决方案的创建:添加Visual C++ , Win32 项目这......_c#调用lib

deepin/ubuntu安装苹方字体-程序员宅基地

文章浏览阅读4.6k次。苹方字体是苹果系统上的黑体,挺好看的。注重颜值的网站都会使用,例如知乎:font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, W..._ubuntu pingfang

html表单常见操作汇总_html表单的处理程序有那些-程序员宅基地

文章浏览阅读159次。表单表单概述表单标签表单域按钮控件demo表单标签表单标签基本语法结构<form action="处理数据程序的url地址“ method=”get|post“ name="表单名称”></form><!--action,当提交表单时,向何处发送表单中的数据,地址可以是相对地址也可以是绝对地址--><!--method将表单中的数据传送给服务器处理,get方式直接显示在url地址中,数据可以被缓存,且长度有限制;而post方式数据隐藏传输,_html表单的处理程序有那些

PHP设置谷歌验证器(Google Authenticator)实现操作二步验证_php otp 验证器-程序员宅基地

文章浏览阅读1.2k次。使用说明:开启Google的登陆二步验证(即Google Authenticator服务)后用户登陆时需要输入额外由手机客户端生成的一次性密码。实现Google Authenticator功能需要服务器端和客户端的支持。服务器端负责密钥的生成、验证一次性密码是否正确。客户端记录密钥后生成一次性密码。下载谷歌验证类库文件放到项目合适位置(我这边放在项目Vender下面)https://github.com/PHPGangsta/GoogleAuthenticatorPHP代码示例://引入谷_php otp 验证器

【Python】matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距-程序员宅基地

文章浏览阅读4.3k次,点赞5次,收藏11次。matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距

docker — 容器存储_docker 保存容器-程序员宅基地

文章浏览阅读2.2k次。①Storage driver 处理各镜像层及容器层的处理细节,实现了多层数据的堆叠,为用户 提供了多层数据合并后的统一视图②所有 Storage driver 都使用可堆叠图像层和写时复制(CoW)策略③docker info 命令可查看当系统上的 storage driver主要用于测试目的,不建议用于生成环境。_docker 保存容器

随便推点

网络拓扑结构_网络拓扑csdn-程序员宅基地

文章浏览阅读834次,点赞27次,收藏13次。网络拓扑结构是指计算机网络中各组件(如计算机、服务器、打印机、路由器、交换机等设备)及其连接线路在物理布局或逻辑构型上的排列形式。这种布局不仅描述了设备间的实际物理连接方式,也决定了数据在网络中流动的路径和方式。不同的网络拓扑结构影响着网络的性能、可靠性、可扩展性及管理维护的难易程度。_网络拓扑csdn

JS重写Date函数,兼容IOS系统_date.prototype 将所有 ios-程序员宅基地

文章浏览阅读1.8k次,点赞5次,收藏8次。IOS系统Date的坑要创建一个指定时间的new Date对象时,通常的做法是:new Date("2020-09-21 11:11:00")这行代码在 PC 端和安卓端都是正常的,而在 iOS 端则会提示 Invalid Date 无效日期。在IOS年月日中间的横岗许换成斜杠,也就是new Date("2020/09/21 11:11:00")通常为了兼容IOS的这个坑,需要做一些额外的特殊处理,笔者在开发的时候经常会忘了兼容IOS系统。所以就想试着重写Date函数,一劳永逸,避免每次ne_date.prototype 将所有 ios

如何将EXCEL表导入plsql数据库中-程序员宅基地

文章浏览阅读5.3k次。方法一:用PLSQL Developer工具。 1 在PLSQL Developer的sql window里输入select * from test for update; 2 按F8执行 3 打开锁, 再按一下加号. 鼠标点到第一列的列头,使全列成选中状态,然后粘贴,最后commit提交即可。(前提..._excel导入pl/sql

Git常用命令速查手册-程序员宅基地

文章浏览阅读83次。Git常用命令速查手册1、初始化仓库git init2、将文件添加到仓库git add 文件名 # 将工作区的某个文件添加到暂存区 git add -u # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,不处理untracked的文件git add -A # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,包括untracked的文件...

分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120-程序员宅基地

文章浏览阅读202次。分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120

【C++缺省函数】 空类默认产生的6个类成员函数_空类默认产生哪些类成员函数-程序员宅基地

文章浏览阅读1.8k次。版权声明:转载请注明出处 http://blog.csdn.net/irean_lau。目录(?)[+]1、缺省构造函数。2、缺省拷贝构造函数。3、 缺省析构函数。4、缺省赋值运算符。5、缺省取址运算符。6、 缺省取址运算符 const。[cpp] view plain copy_空类默认产生哪些类成员函数

推荐文章

热门文章

相关标签