当前位置: 首页 > news >正文

随州网站制作价格江门网站定制多少钱

随州网站制作价格,江门网站定制多少钱,客服在线系统,政务网站建设模块目录 1 简介与摘要2 思路3 效果预览4 代码思路5 完整代码6 后记 1 简介与摘要 最近在做一些课题,需要使用Sentinel-1/2进行机器学习制图。 然后想着总结一下相关数据和方法,就花半小时写了个代码。 然后再花半小时写下这篇博客记录一下。 因为基于多次拍…

目录

  • 1 简介与摘要
  • 2 思路
  • 3 效果预览
  • 4 代码思路
  • 5 完整代码
  • 6 后记

1 简介与摘要

最近在做一些课题,需要使用Sentinel-1/2进行机器学习制图。
然后想着总结一下相关数据和方法,就花半小时写了个代码。
然后再花半小时写下这篇博客记录一下。
因为基于多次拍脑袋而且花的时间很少,所以千万不要把这篇博客的实验流程当作完整的实验,
具体的科研实验还需要反复设计和多次试错!!!

这篇博客主要参考数据(相对贫困指数,RWI)来自这个GEE社区网站,有缺数据的可以直接在这上面找,要用的时候调用一下就行了。这是这个数据的一个交互地图预览。
工作完全是在GEE平台上写的,如上面所说,这个工作跟我的课题内容关系不大,纯粹是拍脑袋的需求然后拍脑袋写的代码。

2 思路

思路就是用Sentinel-1/2的一些波段作为自变量,对自变量在2400m进行采样(因为这个RWI数据的分辨率就是2400),
然后相对贫困指数RWI作为因变量,
最后在10m尺度使用随机森林回归进行相对贫困制图。

因为我没相关需求,求快,所以这里就简单随便弄弄。
因为是随便弄弄,我也不计算什么乱七八糟的指数了,就用VV和VH还有一些光学波段作为自变量。
因变量就直接用原数据的RWI。

研究区选的是坦桑尼亚的原首都达雷斯萨拉姆及其周边,选这个地方没啥特殊的原因,纯粹是点开那个交互地图映入眼帘的就是这个地方(好耳熟的名字,依稀记得当时所里好像有好多非洲老哥来自这个地方)。

所以总的来说,就是基于Sentinel-1/2做一个高分辨率的(10m)相对贫困地图。

这个博客主要还是展示如何用开源数据在GEE上快速实现机器学习制图,这个博客提供的思路太简单了,如果正经是搞科研论文或者做实验还涉及很多数据预处理步骤。
首先这个RWI数据就要咔咔一顿处理,在这个思路里直接在2400m采样肯定是行不通的。
所以这个博客主要还是提供一个参考,具体的一些流程还需要精心设计和反复试错。

3 效果预览

惯例,在代码前面先放效果预览。

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

控制台:
在这里插入图片描述
上图的意思是区域内有2578个样本点,我拿80%(2078个)的去训练,20%(500个)去验证。
散点图是观测值和预测值的散点图。
RMSE就是均方根误差了。看着效果还可以哈。

绘制结果:
在这里插入图片描述

红色的是RWI高值(有钱),蓝色绿色的是RWI低值(贫困)。

绘制结果的细节:
在这里插入图片描述
在这里插入图片描述

为什么看起来这么稀碎呢,因为我拿World Settlement Footprint, WSF掩膜了一下,常规操作,具体可看代码。

4 代码思路

首先我把我要用的数据拉进来。其中RWI数据我按我的ROI筛选一下,不然太多了。代码如下:

// Importing Built-up map
var wsf2019 = ee.ImageCollection('projects/sat-io/open-datasets/WSF/WSF_2019');var wsf_01 = wsf2019.mosaic().eq(255);
var buildingup = wsf_01;// Importing RWI
var rwi = ee.FeatureCollection("projects/sat-io/open-datasets/facebook/relative_wealth_index").filterBounds(roi.geometry());print("sample size", rwi.size())

考虑到要调用Sentinel-1和2,所以也把这些数据写进来,然后也要写上一些预处理。代码如下:

// Importing S1 SAR images.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD').filterDate("2019-01-01", "2024-01-01").filterBounds(roi.geometry());
// print(sentinel1)
// Filter the S1 collection by metadata properties.
var vvVhIw = sentinel1// Filter to get images with VV and VH dual polarization..filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV')).filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))// Filter to get images collected in interferometric wide swath mode..filter(ee.Filter.eq('instrumentMode', 'IW'));
// Separate ascending and descending orbit images into distinct collections.
var vvVhIwAsc = vvVhIw.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING'));
var vvVhIwDesc = vvVhIw.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));// Importing S2 images.
// Cloud mask function.
function maskS2clouds(image) {var qa = image.select('QA60');// Bits 10 and 11 are clouds and cirrus, respectively.var cloudBitMask = 1 << 10;var cirrusBitMask = 1 << 11;// Both flags should be set to zero, indicating clear conditions.var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(qa.bitwiseAnd(cirrusBitMask).eq(0));return image.updateMask(mask).divide(10000);
}var sentinel2 = ee.ImageCollection("COPERNICUS/S2_SR").filterDate("2019-01-01", "2024-01-01").filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30)).filterBounds(roi.geometry()).map(maskS2clouds).mean();

再然后,把我要的波段挑出来,合并成一个image。简简单单搞一下子。代码如下:

// Indice.
var vv = vvVhIwAsc.merge(vvVhIwDesc).select('VV').mean();
var vh = vvVhIwAsc.merge(vvVhIwDesc).select('VH').mean();var blue = sentinel2.select('B2');
var green = sentinel2.select('B3');
var red = sentinel2.select('B4');
var red_edge1 = sentinel2.select('B5');
var red_edge2 = sentinel2.select('B6');
var red_edge3 = sentinel2.select('B7');
var nir = sentinel2.select('B8');
var red_edge4 = sentinel2.select('B8A');
var SWIR1 = sentinel2.select('B11');
var SWIR2 = sentinel2.select('B12');var image = ee.Image().addBands(vv).addBands(vh).addBands(blue).addBands(green).addBands(red).addBands(red_edge1).addBands(red_edge2).addBands(red_edge3).addBands(nir).addBands(red_edge4).addBands(SWIR1).addBands(SWIR2);var band_name = ee.List(['VV', 'VH', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B11', 'B12'])

然后,就是用RWI数据对我选的这些波段(自变量进行采样)。考虑到RWI是2400m分辨率,所以我就在2400米采样。采样完把我们样本规模打印到控制台看看。代码如下:

// Sampling.
var samples = rwi.randomColumn('random'); // set a random fieldvar training_samples = samples.filter(ee.Filter.lt('random', 0.8)); // 80% training data
var training_samples = image.reduceRegions({collection: training_samples, reducer: ee.Reducer.mean(), scale: 2400}); // samplingvar testing_samples = samples.filter(ee.Filter.gte('random', 0.8)); // 20% testing data
var testing_samples = image.reduceRegions({collection: testing_samples, reducer: ee.Reducer.mean(), scale: 2400}); // samplingprint("training sample size", training_samples.size())
print("testing sample size", testing_samples.size())

接下来就是要正式的训练模型绘图。用刚才采样的训练集训练一个回归模型,并且用这个模型进行绘图,得到一张结果的图像rwi_map,然后再用WSF掩膜一下住区。代码如下:

// Regressing.
var regressor = ee.Classifier.smileRandomForest(50) // number of estimators/trees.setOutputMode('REGRESSION') // regression algorithm.train(training_samples, // training samples"rwi", // regressing targetband_name); // regressor featuresvar rwi_map = image.unmask(0).clip(roi).classify(regressor).rename('rwi'); // regress
var rwi_map = rwi_map.updateMask(buildingup).clip(roi); // mask

建模画图完了,然后就是验证。用sampleRegions在画完的图上采样得到预测值,和一开始的观测值进行对比。验证包含散点图R2和RSME,都是必要常用的指标和表现形式。代码如下:

// Testing.
var testing_samples = rwi_map.rename('predicted').sampleRegions({collection: testing_samples,scale: 2400,geometries: true,projection: 'EPSG:4326'
});
var testing_samples = testing_samples.select(['rwi', 'predicted']);
// print(testing_samples)
// Scatter plot.
var chartTraining = ui.Chart.feature.byFeature({features: testing_samples, xProperty:'rwi', yProperties:['predicted']}).setChartType('ScatterChart').setOptions({title: 'Predicted vs Observed - Training data ',hAxis: {'title': 'observed'},vAxis: {'title': 'predicted'},pointSize: 3,trendlines: {0: {showR2: true,visibleInLegend: true},1: {showR2: true,visibleInLegend: true}}});
print(chartTraining);
// Calculating RMSE.
var observation = ee.Array(testing_samples.aggregate_array('rwi'));
var prediction = ee.Array(testing_samples.aggregate_array('predicted'));
var residuals = observation.subtract(prediction);
var rmse = residuals.pow(2).reduce('mean', [0]).sqrt();
print('RMSE', rmse);

最后是把刚才画的图,也就是绘图结果可视化。代码如下:

// Visualization.
Map.centerObject(roi, 8);
var palettes = ["#08525e", "#40d60e", "#b9e40e", "#f9c404", "e70000"]
Map.addLayer(rwi_map,{min: -0.5, max: 1.5, palette: palettes},'RWI');

5 完整代码

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

// Importing Built-up map
var wsf2019 = ee.ImageCollection('projects/sat-io/open-datasets/WSF/WSF_2019');var wsf_01 = wsf2019.mosaic().eq(255);
var buildingup = wsf_01;// Importing RWI
var rwi = ee.FeatureCollection("projects/sat-io/open-datasets/facebook/relative_wealth_index").filterBounds(roi.geometry());print("sample size", rwi.size())// Importing S1 SAR images.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD').filterDate("2019-01-01", "2024-01-01").filterBounds(roi.geometry());
// print(sentinel1)
// Filter the S1 collection by metadata properties.
var vvVhIw = sentinel1// Filter to get images with VV and VH dual polarization..filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV')).filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))// Filter to get images collected in interferometric wide swath mode..filter(ee.Filter.eq('instrumentMode', 'IW'));
// Separate ascending and descending orbit images into distinct collections.
var vvVhIwAsc = vvVhIw.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING'));
var vvVhIwDesc = vvVhIw.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));// Importing S2 images.
// Cloud mask function.
function maskS2clouds(image) {var qa = image.select('QA60');// Bits 10 and 11 are clouds and cirrus, respectively.var cloudBitMask = 1 << 10;var cirrusBitMask = 1 << 11;// Both flags should be set to zero, indicating clear conditions.var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(qa.bitwiseAnd(cirrusBitMask).eq(0));return image.updateMask(mask).divide(10000);
}var sentinel2 = ee.ImageCollection("COPERNICUS/S2_SR").filterDate("2019-01-01", "2024-01-01").filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30)).filterBounds(roi.geometry()).map(maskS2clouds).mean();// Indice.
var vv = vvVhIwAsc.merge(vvVhIwDesc).select('VV').mean();
var vh = vvVhIwAsc.merge(vvVhIwDesc).select('VH').mean();var blue = sentinel2.select('B2');
var green = sentinel2.select('B3');
var red = sentinel2.select('B4');
var red_edge1 = sentinel2.select('B5');
var red_edge2 = sentinel2.select('B6');
var red_edge3 = sentinel2.select('B7');
var nir = sentinel2.select('B8');
var red_edge4 = sentinel2.select('B8A');
var SWIR1 = sentinel2.select('B11');
var SWIR2 = sentinel2.select('B12');var image = ee.Image().addBands(vv).addBands(vh).addBands(blue).addBands(green).addBands(red).addBands(red_edge1).addBands(red_edge2).addBands(red_edge3).addBands(nir).addBands(red_edge4).addBands(SWIR1).addBands(SWIR2);var band_name = ee.List(['VV', 'VH', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B11', 'B12'])// Sampling.
var samples = rwi.randomColumn('random'); // set a random fieldvar training_samples = samples.filter(ee.Filter.lt('random', 0.8)); // 80% training data
var training_samples = image.reduceRegions({collection: training_samples, reducer: ee.Reducer.mean(), scale: 2400}); // samplingvar testing_samples = samples.filter(ee.Filter.gte('random', 0.8)); // 20% testing data
var testing_samples = image.reduceRegions({collection: testing_samples, reducer: ee.Reducer.mean(), scale: 2400}); // samplingprint("training sample size", training_samples.size())
print("testing sample size", testing_samples.size())// Regressing.
var regressor = ee.Classifier.smileRandomForest(50) // number of estimators/trees.setOutputMode('REGRESSION') // regression algorithm.train(training_samples, // training samples"rwi", // regressing targetband_name); // regressor featuresvar rwi_map = image.unmask(0).clip(roi).classify(regressor).rename('rwi'); // regress
var rwi_map = rwi_map.updateMask(buildingup).clip(roi); // mask// Testing.
var testing_samples = rwi_map.rename('predicted').sampleRegions({collection: testing_samples,scale: 2400,geometries: true,projection: 'EPSG:4326'
});
var testing_samples = testing_samples.select(['rwi', 'predicted']);
// print(testing_samples)
// Scatter plot.
var chartTraining = ui.Chart.feature.byFeature({features: testing_samples, xProperty:'rwi', yProperties:['predicted']}).setChartType('ScatterChart').setOptions({title: 'Predicted vs Observed - Training data ',hAxis: {'title': 'observed'},vAxis: {'title': 'predicted'},pointSize: 3,trendlines: {0: {showR2: true,visibleInLegend: true},1: {showR2: true,visibleInLegend: true}}});
print(chartTraining);
// Calculating RMSE.
var observation = ee.Array(testing_samples.aggregate_array('rwi'));
var prediction = ee.Array(testing_samples.aggregate_array('predicted'));
var residuals = observation.subtract(prediction);
var rmse = residuals.pow(2).reduce('mean', [0]).sqrt();
print('RMSE', rmse);// Visualization.
Map.centerObject(roi, 8);
var palettes = ["#08525e", "#40d60e", "#b9e40e", "#f9c404", "e70000"]
Map.addLayer(rwi_map,{min: -0.5, max: 1.5, palette: palettes},'RWI');

6 后记

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


文章转载自:
http://dinncohypogenesis.tqpr.cn
http://dinncohaughtiness.tqpr.cn
http://dinncorescale.tqpr.cn
http://dinncocollapse.tqpr.cn
http://dinncopim.tqpr.cn
http://dinncomontaria.tqpr.cn
http://dinncopancake.tqpr.cn
http://dinncoprocrustes.tqpr.cn
http://dinncomagnificence.tqpr.cn
http://dinncodermopteran.tqpr.cn
http://dinncodiluvialist.tqpr.cn
http://dinncoriblet.tqpr.cn
http://dinncorebound.tqpr.cn
http://dinncoemergency.tqpr.cn
http://dinncosuntan.tqpr.cn
http://dinncodrupe.tqpr.cn
http://dinncoscorer.tqpr.cn
http://dinncoteratogenic.tqpr.cn
http://dinncoloof.tqpr.cn
http://dinnconitrifier.tqpr.cn
http://dinncocandu.tqpr.cn
http://dinncospindleshanks.tqpr.cn
http://dinncocomplaisant.tqpr.cn
http://dinncoebriety.tqpr.cn
http://dinncoeldorado.tqpr.cn
http://dinncomurrelet.tqpr.cn
http://dinncocos.tqpr.cn
http://dinncomuliebrity.tqpr.cn
http://dinncoassignee.tqpr.cn
http://dinncovenerology.tqpr.cn
http://dinncosabbathly.tqpr.cn
http://dinncoladyhood.tqpr.cn
http://dinncovirtuosity.tqpr.cn
http://dinncoultrafax.tqpr.cn
http://dinncocreasote.tqpr.cn
http://dinnconicaea.tqpr.cn
http://dinncomeningocele.tqpr.cn
http://dinncoslug.tqpr.cn
http://dinncoarchibald.tqpr.cn
http://dinncolofter.tqpr.cn
http://dinncoincite.tqpr.cn
http://dinncochaw.tqpr.cn
http://dinncodeskwork.tqpr.cn
http://dinncothisbe.tqpr.cn
http://dinncosameness.tqpr.cn
http://dinncoregurgitate.tqpr.cn
http://dinncomalefactress.tqpr.cn
http://dinncotoyshop.tqpr.cn
http://dinncoteardown.tqpr.cn
http://dinncocertiorari.tqpr.cn
http://dinncocorticose.tqpr.cn
http://dinncopace.tqpr.cn
http://dinncofudge.tqpr.cn
http://dinncoweightiness.tqpr.cn
http://dinncozygoma.tqpr.cn
http://dinncoknowability.tqpr.cn
http://dinncocomfortless.tqpr.cn
http://dinnconeocolonial.tqpr.cn
http://dinnconihilism.tqpr.cn
http://dinncooona.tqpr.cn
http://dinnconeufchatel.tqpr.cn
http://dinncolionhearted.tqpr.cn
http://dinncoclamshell.tqpr.cn
http://dinncoleporine.tqpr.cn
http://dinncopharmacological.tqpr.cn
http://dinncoyippie.tqpr.cn
http://dinncolarkishly.tqpr.cn
http://dinncohoopster.tqpr.cn
http://dinncosizy.tqpr.cn
http://dinncomistreatment.tqpr.cn
http://dinncorumansh.tqpr.cn
http://dinncovodun.tqpr.cn
http://dinncosublimity.tqpr.cn
http://dinncopediculicide.tqpr.cn
http://dinncowearing.tqpr.cn
http://dinncosdcd.tqpr.cn
http://dinncogeneralise.tqpr.cn
http://dinncoblow.tqpr.cn
http://dinncojackanapes.tqpr.cn
http://dinncocyanogenetic.tqpr.cn
http://dinncoamorite.tqpr.cn
http://dinncowastrel.tqpr.cn
http://dinncopwd.tqpr.cn
http://dinncotropicopolitan.tqpr.cn
http://dinncoundersurface.tqpr.cn
http://dinncolexicography.tqpr.cn
http://dinncoaforethought.tqpr.cn
http://dinncointerference.tqpr.cn
http://dinncoxylophagous.tqpr.cn
http://dinncoacrodrome.tqpr.cn
http://dinncobuskin.tqpr.cn
http://dinncoacidophile.tqpr.cn
http://dinncopeaked.tqpr.cn
http://dinncopuritanism.tqpr.cn
http://dinncoraincoat.tqpr.cn
http://dinncowostteth.tqpr.cn
http://dinncominifestival.tqpr.cn
http://dinncophotoengrave.tqpr.cn
http://dinncoencyclical.tqpr.cn
http://dinncogalant.tqpr.cn
http://www.dinnco.com/news/152314.html

相关文章:

  • 什么网站可以做外单seo公司关键词
  • wordpress获取所有图片做seo需要哪些知识
  • 织梦做的网站图片路径在哪里站长工具seo综合查询腾讯
  • iOS开发 隐私政策网站怎么做武汉关键词seo排名
  • 网站建设选超速云建站最有效的线下推广方式
  • 问题反馈的网站怎么做国内十大4a广告公司
  • 网站开发收费标准文档谷歌seo外包公司哪家好
  • 做优化网站注意什么百度推广价格
  • jquery mobile 做的网站seo课程培训
  • 北京门户网站建设公司网络营销的招聘信息
  • 深圳有做网站最近价格杭州专业seo公司
  • 烟台建设科技网站各个广告联盟的标识
  • 软件研发租用网站怎么做分录北京网站营销seo方案
  • 那种投票网站里面怎么做网站seo案例
  • primefaces做网站网址缩短
  • 玩具网站建设服务公司企业网站营销的典型案例
  • 做python项目的网站百度seo指数查询
  • 新疆网络推广免费培训seo
  • 网站建设开发哪家质量好如何设置友情链接
  • 建设网站50m数据库贴吧引流推广
  • 广东顺德网站建设济南seo的排名优化
  • 优秀包装设计网站百度关键词推广2元一天
  • 请问有没有做网站广州白云区新闻头条最新消息今天
  • 美国cn2独立ip站群服务器谷歌浏览器网页
  • 汉中网站制作宁德市属于哪个省份
  • 网站建设教程网页企业网站推广渠道有哪些
  • 营销网站建设新闻国内推广平台有哪些
  • 主机屋如何做网站上海排名优化seobwyseo
  • 黄冈网站官方登录平台seo技术优化服务
  • 工具类网站如何做排名今日热点事件