当前位置:网站首页>1: Mosaic of 100W basic geographic information data
1: Mosaic of 100W basic geographic information data
2022-06-24 18:41:00 【Geographical space of ruiduobao】
background
It was officially released yesterday 1:100 Public version of basic geographic information data set , But this data is divided , We still need to do some merging .

Processing flow
Mainly used python Preprocess and merge data .

gdb turn shp vector
Use QGIS Of OSGeo4W Shell Software , Can be gdb The database is exported to shp vector .
ogr2ogr -f “ESRI Shapefile” F:\keshan\shp_get\I51 F:\keshan\shp100w\I51.gdb -lco ENCODING=UTF-8,
The format is :ogr2ogr -f + Format name + Save the path + Original file path + Encoding mode
import os
from tqdm import tqdm
Path = 'F:\keshan\shp100w/'
folder_names = os.listdir(Path)
# Script : Reference resources ogr2ogr -f "ESRI Shapefile" F:\keshan\shp_get\2 F:\keshan\shp100w\A49.gdb -lco ENCODING=UTF-8
bat_part1="ogr2ogr -f \"ESRI Shapefile\" F:\keshan\shp_get\\"
bat_part2=" F:\keshan\shp100w\\"
bat_part3=" -lco ENCODING=UTF-8"
# Loop Directory
for folder_name in tqdm(folder_names):
bat_text=bat_part1+folder_name.replace(".gdb","")+bat_part2+folder_name+bat_part3
print(bat_text)
Through the above script , Batch generate Export shp Of .bat Content . Package this content into .bat file , Input start+.bat route , Run the file

The operation results are as follows :

Open every file , Is the vector of the framing :

shp Vector merge
Use scripts , Traversal folder , Move all vector files with the same name into the same file :
import os
import shutil
from tqdm import tqdm
# Create local folder function
def mkdir(path):
# Introduce modules
# Remove the first space
path = path.strip()
# Remove the tail \ Symbol
path = path.rstrip("\\")
# Determine if the path exists
# There is True
# non-existent False
isExists = os.path.exists(path)
# Judge the result
if not isExists:
# Create a directory if it doesn't exist
# Create directory manipulation functions
os.makedirs(path)
print(path + ' Create success ')
return True
else:
# Do not create if directory exists , And prompt that the directory already exists
print(path + ' directory already exists ')
return False
Path = 'F:\keshan\shp_get/'
# Saved categories shp file location
Save_Fenlei= 'F:\keshan\shp_100w_fenlei/'
folder_names = os.listdir(Path)
# Loop Directory
for folder_name in tqdm(folder_names):
floder_PATH = os.path.join(Path, folder_name)
file_names = os.listdir(floder_PATH)
for file_names in file_names:
# Get file path and name
file_path =os.path.join(floder_PATH, file_names)
file_name=file_names.split(".")[0]
file_suffix = file_names.split(".")[1]
# Move the file to the specified directory Name as file Copy the file named file_dir In the folder of
dir_path = Save_Fenlei +file_name
# Create folder A folder where individual files are saved
mkdir(dir_path)
# Change file name
file_new_name = file_name.split(".")[0]+"_"+folder_name+"."+file_suffix
dst_name=os.path.join(dir_path, file_new_name)
# The specified file file Move to file_dir In the folder of
shutil.copy(file_path, dst_name)
Here we are , We have obtained... For each category shp vector , Load into gis In the software .

Now let's merge the vectors , First of all, I thought of arcgis and qgis Manual operation . But I'm lazy , Don't like repetitive operation , So I wrote a script to merge each category :
import os
import geopandas as gpd
import pandas as pd
from tqdm import tqdm
# Classified shp
Path = 'F:\keshan\shp_100w_fenlei/'
# Saved merge file location
Save_shp = r'F:\keshan\100Wmerge\shp/'
Save_geojson = r'F:\keshan\100Wmerge\geojson/'
folder_names = os.listdir(Path)
# Loop Directory
for folder_name in tqdm(folder_names):
try:
folder_name_path=os.path.join(Path, folder_name)
file = os.listdir(folder_name_path)
# Traverse shp File merge
path = [os.path.join(folder_name_path, i) for i in file if ".shp" in i]
gdf = gpd.GeoDataFrame(pd.concat([gpd.read_file(i) for i in path],
ignore_index=True), crs=gpd.read_file(path[0]).crs)
# export shp
gdf_path_name_shp =Save_shp+folder_name+".shp"
gdf.to_file(gdf_path_name_shp, driver="ESRI Shapefile", encoding="utf-8")
# export geojson
gdf_path_name_json =Save_geojson+folder_name+".gson"
gdf.to_file(gdf_path_name_json, driver='GeoJSON', encoding="utf-8")
except:
pass
Through this step ,ANNP This national vector is merge Okay , Put it in gis View... In the software :

thus , We got shp and geojson Two formats of 1:100w National Geographic basic information data :

Here is why we export another one separately geojson The file of , Because of my own prejudice :gson Than shp To use ,qgis Than arcgis Well done .
other
thus , The data has been converted , You can use it directly . The data types are as follows :


There's a lot of data , You can see :

I saw a post posted on the remote sensing forum , You can go download This consolidated version of the data :

Reference resources
National Geographic information system resource directory .https://www.webmap.cn/main.do?method=index
Geodata Geographic Data Institute .2021 National edition 1:100 10000 public version of basic geographic information data
边栏推荐
- next_ Permutation full permutation function
- Flex box flex attribute
- An analysis of the comments on the TV series Douban by procedural apes
- 面试算法 - 字符串问题总结
- 微服务系统设计——数据模型与系统架构设计
- Uniapp wechat applet calls mobile map to navigate to the target point
- Why should state-owned enterprises accelerate the digital transformation
- C self learning function
- Industry Cloud video editing software
- Location object
猜你喜欢

为什么 useEvent 不够好
[golang] leetcode intermediate - jumping game & different paths

Graph traversal (BFS and DFS) C language pure handwriting

Eight recommended microservice testing tools

Four security issues of low code and no code development

干货 | 新手经常忽略的嵌入式基础知识点,你都掌握了吗?

Window object

Value passing and reference passing of value types and reference types in CSharp

JS deep understanding of scope

微服务系统设计——子服务项目构建
随机推荐
BOM(Browser Object Model)
Paper sharing | self supervised learning paper jointly released by Yann Lecun and read by engineers
R中的指数回归
subject may not be empty [subject-empty]
Data driven decision making: Decision intelligence and design thinking
Application service access configuration parameters
In depth learning of movement methods
SAP license: what is ERP supply chain
JS picture switching case
JS picture display and hiding cases
Millions of dollars worth of NFT were stolen in the attack, and Google issued an emergency warning to 3.2 billion users worldwide | February 21 global network security hotspot
717.1-bit and 2-bit characters [sliding window]
What if the database table structure changes? Smartbi products support one click synchronization
130. surrounding area
Mcu-08 interrupt system and external interrupt application
Usage of typedef enum (enumeration)
时间溯源的系统设计思路
Rapidssl getting started SSL certificate
R language Quantitative Ecology redundancy analysis RDA analysis plant diversity species data visualization
About whether arm's large and small end mode is related to CPU or compiler