ARCGIS API for Python进行城市区域提取

ArcGIS API for Python主要用于Web端的扩展和开发,提供简单易用、功能强大的Python库,以及大数据分析能力,可轻松实现实时数据、栅格数据、空间数据等多源数据的接入和GIS分析、可视化,同时提供对平台的空间数据管理和组织管理功能。本篇博客将和大家分享,使用ArcGIS API for Python进行城市区域提取的方法和流程。

数据准备:

不同时期的landsat影像

一、关于栅格函数

在前面的博客"环境镶嵌数据集的渲染模板使用","环境镶嵌数据集栅格函数使用(一)"中我们已经介绍了在镶嵌数据集上配置栅格函数以及发布的方法,我们也可以直接通过ArcGIS API for Python在客户端来使用栅格函数,ArcGIS API for Python包含了很多栅格函数和分析工具,如下图所示:

二、城市区域提取的流程

城市区域提取的流程如下图所示:

三、脚本实现过程

  • 第一步:从portal中获取需要进行分析的数据

    #从Portal中检索landsat影像发布的影像服务
    from IPython.display import display
    landsatitems = gis.content.search('ndvisourceprj','Imagery Layer')
    landsat = landsatitems[0].layers[0]

    过滤得到不同年份的数据

    selected2000 = landsat.filter_by("Name='city2000prj'")
    selected2015 = landsat.filter_by("Name='city2015prj'")

  • 第二步:计算不同年份的NDVI并进行二值化处理

复制代码
  # 应用ndvi栅格函数生成不同年份ndvi
  ndvi2000 = ndvi(selected2000,'4 3')
  ndvi2015 = ndvi(selected2015,'4 3')

  # ndvi二值化处理,设定阈值0,小于阈值为1表示裸地和水体,其余为0
  ndvithreshold = 0
  ndvi2000binarization = less_than([ndvi2000,ndvithreshold])*1+greater_than([ndvi2000,ndvithreshold])*0
  ndvi2015binarization = less_than([ndvi2015,ndvithreshold])*1+greater_than([ndvi2015,ndvithreshold])*0
  • 第三步:计算不同年份的NDBI并进行二值化处理
复制代码
  # 应用extract_band函数提取短波红外、近红外波段数据
  swir = extract_band(selected2000,[5])
  nearir = extract_band(selected2000,[4])

  #计算不同年份的ndbi
  ndbi2000 = FLOAT([swir-nearir])/FLOAT([swir+nearir])
  ndbi2015 = FLOAT([extract_band(selected2015,[5])-extract_band(selected2015,[4])])/FLOAT([extract_band(selected2015,[5])+extract_band(selected2015,[4])])

  #ndbi二值化处理,设定阈值0,小于阈值为0,其余为1表示城市建设区域和低密度植被覆盖裸地,可以调整阈值
  ndbi2000binarization = less_than([ndbi2000,0])*0+greater_than([ndbi2000,0])*1
  ndbi2015binarization = less_than([ndbi2015,0.1])*0+greater_than([ndbi2015,0.1])*1
  • 第四步:城市建设用地提取

    #生成不同年份的城市建设用地数据
    citybuildinguse2000 = ndvi2000binarization * ndbi2000binarization
    citybuildinguse2015 = ndvi2015binarization * ndbi2015binarization

    #计算不同年份的城市建设用地变化
    buildinguse_diff = (citybuildinguse2015 - citybuildinguse2000)

    #变化结果重映射
    threshold_val = 0.1
    buildingusediff_remap = remap(buildinguse_diff,input_ranges=[threshold_val,1],output_values=[1],no_data_ranges=[-1,threshold_val],astype='u8')

    #变化结果颜色映射
    buildingusediff_colormap = colormap(buildingusediff_remap,colormap=[[1,124,252,0]],astype='u8')

    #变化结果输出图片
    from IPython.display import Image
    dataextent = '11541010.6342307,3538686.96622601,11614210.6342307,3628986.96622601'
    exportedimg = buildingusediff_colormap.export_image(bbox=dataextent,size=[1200,450],f='image')
    Image(exportedimg)

原文链接:https://bbs.csdn.net/forums/gisrs?spm=1001.2014.3001.6682

相关推荐
武子康12 小时前
大数据-236 离线数仓 - 会员指标验证、DataX 导出与广告业务 ODS/DWD/ADS 全流程
大数据·后端·apache hive
武子康2 天前
大数据-235 离线数仓 - 实战:Flume+HDFS+Hive 搭建 ODS/DWD/DWS/ADS 会员分析链路
大数据·后端·apache hive
DianSan_ERP2 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
够快云库2 天前
能源行业非结构化数据治理实战:从数据沼泽到智能资产
大数据·人工智能·机器学习·企业文件安全
AI周红伟2 天前
周红伟:智能体全栈构建实操:OpenClaw部署+Agent Skills+Seedance+RAG从入门到实战
大数据·人工智能·大模型·智能体
油墨香^_^2 天前
Node.js 安装指南(Mac 版本)
arcgis
B站计算机毕业设计超人2 天前
计算机毕业设计Django+Vue.js高考推荐系统 高考可视化 大数据毕业设计(源码+LW文档+PPT+详细讲解)
大数据·vue.js·hadoop·django·毕业设计·课程设计·推荐算法
计算机程序猿学长2 天前
大数据毕业设计-基于django的音乐网站数据分析管理系统的设计与实现(源码+LW+部署文档+全bao+远程调试+代码讲解等)
大数据·django·课程设计
B站计算机毕业设计超人2 天前
计算机毕业设计Django+Vue.js音乐推荐系统 音乐可视化 大数据毕业设计 (源码+文档+PPT+讲解)
大数据·vue.js·hadoop·python·spark·django·课程设计
十月南城2 天前
数据湖技术对比——Iceberg、Hudi、Delta的表格格式与维护策略
大数据·数据库·数据仓库·hive·hadoop·spark