最新数据处理 之 1:100万与1:25万全国基础地理数据库批量合并
生活随笔
收集整理的這篇文章主要介紹了
最新数据处理 之 1:100万与1:25万全国基础地理数据库批量合并
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
背景
數據來源:全國地理信息資源目錄服務系統
鏈接:全國地理信息資源目錄服務系統
這個網站是由自然資源部主管, 國家基礎地理信息中心進行運行維護的,因此數據是比較權威的。目前,網站上提供了以下三類數據:
-
30米全球地表覆蓋數據,數據整體現勢性達到2010年
-
1:100萬全國基礎地理數據庫,數據整體現勢性達到2015年
-
1:25萬全國基礎地理數據庫,數據整體現勢性達到2015年
個人可以進行注冊,然后查詢和下載,下載的時候,需要提供單位和下載的目的。提交后,很快就可以進行下載了。
但是,數據是基于塊的,下載后,還需要進行逐一拼接,雖然用ArcGIS的工具可以實現,但手動點擊操作比較繁瑣。因此,本文主要介紹如何進行批量拼接,用到的是ArcPy工具。
數據組織形式如上圖。由于1:100萬的數據是采用gbd數據庫的形式存儲的,1:25萬的數據是采用shape文件進行保存的,因此兩個數據的拼接還需要注意。廢話不多說,直接上代碼。
1:100萬全國基礎地理數據庫
import os import arcpy gdb_list = [] file_dir = "gdb" # put the unzipped gdb file (such as A49.gdb) in this folder dir_list = os.listdir(file_dir) for dir in dir_list:if ".gdb" in dir:gdb_list.append(file_dir + "\\" + dir) print(gdb_list) # check the gdb out_path = "dataset_100w" out_gdb_name = "merge_100w" merge_gdb = out_path + "\\" + out_gdb_name + ".gdb" if arcpy.Exists(merge_gdb):pass else:arcpy.CreateFileGDB_management(out_path, out_gdb_name) for gdb in gdb_list:print(gdb)arcpy.env.workspace = gdbfcs = arcpy.ListFeatureClasses()for fc in fcs:print(" " + fc)if arcpy.Exists(merge_gdb + "\\" + fc):arcpy.Append_management(gdb + "\\" + fc,merge_gdb + "\\" + fc,"NO_TEST")else:arcpy.FeatureClassToFeatureClass_conversion(fc, merge_gdb, fc)1:25萬全國基礎地理數據庫
import os import arcpy path = 'data' # put the unzipped file in this folder fileList = os.listdir(path) a = [] b = [] c = [] d = [] e = [] f = [] g = [] h = [] k = [] for i in fileList:path_name = path + '\\' + iarcpy.env.workspace = path_namefsc = arcpy.ListFeatureClasses()for j in fsc:if j == "agnp.shp":a.append(path_name + "\\" + j)elif j == 'aanp.shp':b.append(path_name + "\\" + j)elif j == 'hyda.shp':c.append(path_name + "\\" + j)elif j == 'hydl.shp':d.append(path_name + "\\" + j)elif j == 'hydp.shp':e.append(path_name + "\\" + j)elif j == 'lrdl.shp':f.append(path_name + "\\" + j)elif j == 'lrrl.shp':g.append(path_name + "\\" + j)elif j == 'resa.shp':h.append(path_name + "\\" + j)elif j == 'resp.shp':k.append(path_name + "\\" + j) arcpy.env.workspace = 'dataset_25w\\' arcpy.env.overwriteoutput = True arcpy.Merge_management(a,"agnp_25w.shp") arcpy.Merge_management(b,"aanp_25w.shp") arcpy.Merge_management(c,"hyda_25w.shp") arcpy.Merge_management(d,"hydl_25w.shp") arcpy.Merge_management(e,"hydp_25wn.shp") arcpy.Merge_management(f,"lrdl_25w.shp") arcpy.Merge_management(g,"lrrl_25w.shp") arcpy.Merge_management(h,"resa_25w.shp") arcpy.Merge_management(k,"resp_25w.shp")最后
這兩段代碼經過了最新測試,沒有出現問題,可以放心使用!其中,1:100萬的結果合并成了gdb數據庫格式,1:25萬的結果合并成了shape格式,都可以用ArcGIS打開。下圖是1:100萬居民地地名在ArcGIS中的展示結果。
?
?
總結
以上是生活随笔為你收集整理的最新数据处理 之 1:100万与1:25万全国基础地理数据库批量合并的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为交换机测试吞吐量软件,【精选】ixc
- 下一篇: java编译成功,但运行失败,即错误: