中国行政区划矢量数据从数据获取到专业地理分析的完整解决方案【免费下载链接】ChinaAdminDivisonSHP中国行政区划矢量图ESRI Shapefile格式共四级国家、省/直辖市、市、区/县。关键字中国行政区划图中国地图中国行政区中国行政区地图行政区地图行政区行政区划地图矢量数据矢量地理数据省级直辖市市级区/县级行政区划图。项目地址: https://gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP还在为GIS开发中繁琐的中国行政区划数据获取而烦恼吗无论你是地理信息系统开发者、数据分析师还是城市规划专家ChinaAdminDivisonSHP项目提供了从国家到区县的四级中国行政区划矢量地图数据采用行业标准的ESRI Shapefile格式让你能够快速集成到现有技术栈中专注于业务逻辑而非数据预处理。 核心价值解决地理数据集成中的三大痛点在GIS项目开发中获取准确、完整且格式统一的中国行政区划数据常常面临以下挑战数据碎片化问题不同层级的行政区划数据分散在各个部门需要大量时间进行整合格式兼容性挑战数据格式各异转换工作繁琐且容易出错坐标系不一致不同来源的数据使用不同的坐标系统叠加分析时产生偏差ChinaAdminDivisonSHP通过提供四级行政区划的完整中国行政区划矢量数据直接解决了这些核心问题。数据来源于高德地图API采用GCJ-02坐标系基于WGS 84确保与主流中国地图服务兼容。️ 架构解析四级行政区划的技术实现Shapefile格式的技术优势项目采用ESRI Shapefile格式这是GIS领域最广泛支持的矢量数据格式。每个行政区划层级都包含完整的Shapefile文件集.shp文件存储几何形状数据包括点、线、多边形等空间要素.dbf文件存储属性数据包含行政编码、名称等关键信息.prj文件定义坐标参考系统确保空间数据正确显示.cpg文件指定字符编码支持中文字符的正确显示.shx文件空间索引文件提高数据访问效率四级行政区划的层级架构项目采用清晰的四级分层结构每级数据都保持一致的属性字段设计国家级数据完整的中国领土边界包含台湾省和南海诸岛省级数据34个省级行政区23省5自治区4直辖市2特别行政区市级数据约333个地级行政区包含地级市、自治州、地区等区县级数据约2875个县级行政区包含市辖区、县级市、县等![省级行政区划矢量地图](https://raw.gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP/raw/398535de74baa19be2013d6e00a4c01d4491157d/5. Demo/Province.png?utm_sourcegitcode_repo_files)省级行政区划矢量地图 - 展示34个省级行政区的空间分布和边界划分属性数据的标准化设计每个Shapefile都包含标准化的属性字段采用六位行政编码体系adcode字段六位数字编码前两位代表省份中间两位代表城市后两位代表区县name字段行政区划的完整中文名称层级关联字段通过编码体系建立四级行政区划的完整关联关系![省级行政区划属性数据表](https://raw.gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP/raw/398535de74baa19be2013d6e00a4c01d4491157d/5. Demo/ProvinceAttr.png?utm_sourcegitcode_repo_files)省级行政区划属性数据表 - 展示省级行政区的代码与名称对应关系 集成方案与主流GIS技术栈的无缝对接Python生态集成使用geopandas库可以轻松加载和处理这些Shapefile数据import geopandas as gpd # 加载省级行政区划数据 province_gdf gpd.read_file(2. Province/province.shp) # 查看数据结构 print(province_gdf.head()) print(f坐标系: {province_gdf.crs}) print(f几何类型: {province_gdf.geometry.type.unique()}) # 进行空间查询 beijing province_gdf[province_gdf[name] 北京市] print(f北京市面积: {beijing.geometry.area.values[0]:.2f} 平方度)WebGIS应用集成对于前端地图应用可以将数据转换为GeoJSON格式// 使用GDAL命令行工具转换格式 // ogr2ogr -f GeoJSON province.geojson province.shp // 在Leaflet中加载GeoJSON数据 fetch(province.geojson) .then(response response.json()) .then(data { L.geoJSON(data, { style: function(feature) { return { fillColor: #3388ff, weight: 2, opacity: 1, color: white, fillOpacity: 0.7 }; } }).addTo(map); });数据库存储方案对于大规模GIS应用建议将数据导入空间数据库-- PostgreSQL PostGIS导入示例 shp2pgsql -s 4326 -I province.shp public.province | psql -d gisdb -- 创建空间索引 CREATE INDEX idx_province_geom ON public.province USING gist(geom); -- 空间查询示例 SELECT name, ST_Area(geom) as area FROM public.province ORDER BY area DESC LIMIT 10;![市级行政区划矢量地图](https://raw.gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP/raw/398535de74baa19be2013d6e00a4c01d4491157d/5. Demo/City.png?utm_sourcegitcode_repo_files)市级行政区划矢量地图 - 展示333个地级行政区的空间分布东部地区城市密集度明显高于西部⚡ 性能优化大数据量下的处理策略数据分块处理对于包含2875个区县的district.shp文件建议采用分块处理策略import geopandas as gpd from shapely.geometry import box # 分块读取和处理大型Shapefile def process_shapefile_in_chunks(filepath, chunk_size100): gdf gpd.read_file(filepath) # 按地理范围分块 bounds gdf.total_bounds x_min, y_min, x_max, y_max bounds # 创建网格分块 x_step (x_max - x_min) / 10 y_step (y_max - y_min) / 10 results [] for i in range(10): for j in range(10): # 创建查询框 query_box box(x_min i*x_step, y_min j*y_step, x_min (i1)*x_step, y_min (j1)*y_step) # 空间查询获取区块数据 chunk gdf[gdf.intersects(query_box)] if not chunk.empty: # 处理区块数据 processed_chunk process_chunk(chunk) results.append(processed_chunk) return gpd.GeoDataFrame(pd.concat(results, ignore_indexTrue))空间索引优化使用R-tree空间索引显著提高查询性能from rtree import index # 构建空间索引 def build_spatial_index(gdf): idx index.Index() for i, geom in enumerate(gdf.geometry): idx.insert(i, geom.bounds) return idx # 使用空间索引进行快速查询 def spatial_query(gdf, idx, query_geom): # 获取可能相交的要素ID possible_matches list(idx.intersection(query_geom.bounds)) # 精确判断相交 matches [] for fid in possible_matches: if gdf.iloc[fid].geometry.intersects(query_geom): matches.append(fid) return gdf.iloc[matches]内存优化策略对于内存受限的环境可以使用Dask进行分布式处理import dask_geopandas as dgpd # 使用Dask加载大型Shapefile ddf dgpd.read_file(4. District/district.shp, npartitions10) # 分布式处理 result (ddf.groupby(pr_name) .agg({dt_name: count, geometry: lambda x: x.unary_union.area}) .compute()) 扩展生态构建完整的地理数据处理流水线数据质量验证工具创建自动化数据质量检查脚本import geopandas as gpd from shapely.geometry import Polygon, MultiPolygon from shapely.validation import explain_validity def validate_shapefile(filepath): 验证Shapefile数据的质量 gdf gpd.read_file(filepath) issues [] # 检查几何有效性 for idx, row in gdf.iterrows(): if not row.geometry.is_valid: issues.append({ index: idx, name: row.get(name, Unknown), issue: explain_validity(row.geometry) }) # 检查属性完整性 required_columns [adcode, name] missing_cols [col for col in required_columns if col not in gdf.columns] # 检查编码唯一性 duplicate_codes gdf[adcode].duplicated().sum() return { total_features: len(gdf), geometry_issues: len(issues), missing_columns: missing_cols, duplicate_codes: duplicate_codes, crs: str(gdf.crs) }数据更新自动化脚本基于高德API实现数据自动更新import requests import json import geopandas as gpd from shapely.geometry import shape class AMapDataUpdater: def __init__(self, api_key): self.api_key api_key self.base_url https://restapi.amap.com/v3/config/district def fetch_district_data(self, keywords, subdistrict0): 从高德API获取行政区划数据 params { keywords: keywords, subdistrict: subdistrict, key: self.api_key, extensions: all, output: JSON } response requests.get(self.base_url, paramsparams) return response.json() def parse_to_geojson(self, api_data): 将API数据解析为GeoJSON格式 features [] for district in api_data.get(districts, []): polyline district.get(polyline, ) if polyline: # 解析坐标字符串 coordinates [] for line in polyline.split(;): points line.split(|) for point in points: if point: lng, lat map(float, point.split(,)) coordinates.append([lng, lat]) if coordinates: geometry { type: Polygon, coordinates: [coordinates] } feature { type: Feature, geometry: geometry, properties: { adcode: district.get(adcode), name: district.get(name), level: district.get(level) } } features.append(feature) return { type: FeatureCollection, features: features }![区县级行政区划矢量地图](https://raw.gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP/raw/398535de74baa19be2013d6e00a4c01d4491157d/5. Demo/District.png?utm_sourcegitcode_repo_files)区县级行政区划矢量地图 - 展示2875个县级行政区的空间分布东部地区边界密度显著高于西部 最佳实践行业应用案例深度解析案例一城市规划与区域分析某城市规划研究院使用ChinaAdminDivisonSHP数据进行城市扩张分析import geopandas as gpd import matplotlib.pyplot as plt from datetime import datetime # 加载不同年份的行政区划数据 city_2020 gpd.read_file(historical_data/city_2020.shp) city_2023 gpd.read_file(3. City/city.shp) # 当前数据 # 计算城市扩张面积 def calculate_urban_expansion(old_gdf, new_gdf): expansion_results [] for idx, new_row in new_gdf.iterrows(): city_code new_row[adcode] new_geom new_row.geometry # 查找对应的历史数据 old_row old_gdf[old_gdf[adcode] city_code] if not old_row.empty: old_geom old_row.iloc[0].geometry # 计算扩张面积 expansion_area new_geom.area - old_geom.area expansion_results.append({ city_code: city_code, city_name: new_row[name], expansion_area: expansion_area, expansion_rate: (expansion_area / old_geom.area) * 100 }) return pd.DataFrame(expansion_results) # 生成扩张热力图 expansion_df calculate_urban_expansion(city_2020, city_2023) top_expanding expansion_df.nlargest(10, expansion_rate) plt.figure(figsize(12, 8)) plt.barh(top_expanding[city_name], top_expanding[expansion_rate]) plt.xlabel(城市扩张率 (%)) plt.title(2020-2023年城市扩张率TOP 10) plt.tight_layout() plt.savefig(city_expansion_top10.png, dpi300)案例二公共卫生数据分析疾控中心使用区县级数据进行疫情空间分析import geopandas as gpd import pandas as pd from libpysal.weights import Queen from esda.moran import Moran # 加载区县数据和疫情数据 district_gdf gpd.read_file(4. District/district.shp) covid_data pd.read_csv(covid_cases.csv) # 空间数据合并 merged_data district_gdf.merge(covid_data, left_onadcode, right_ondistrict_code) # 构建空间权重矩阵 w Queen.from_dataframe(merged_data) # 计算莫兰指数空间自相关 moran Moran(merged_data[cases_per_100k], w) print(f莫兰指数: {moran.I:.4f}) print(fP值: {moran.p_sim:.4f}) # 识别疫情热点区域 if moran.p_sim 0.05: print(存在显著的空间聚集模式) # 局部莫兰指数分析 from esda.moran import Moran_Local local_moran Moran_Local(merged_data[cases_per_100k], w) # 分类热点区域 merged_data[hotspot_type] 不显著 merged_data.loc[local_moran.q 1, hotspot_type] 高高聚集 merged_data.loc[local_moran.q 2, hotspot_type] 低低聚集 merged_data.loc[local_moran.q 3, hotspot_type] 高低异常 merged_data.loc[local_moran.q 4, hotspot_type] 低高异常 # 保存热点分析结果 merged_data.to_file(covid_hotspots.geojson, driverGeoJSON)![市级行政区划属性数据表](https://raw.gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP/raw/398535de74baa19be2013d6e00a4c01d4491157d/5. Demo/CityAttr.png?utm_sourcegitcode_repo_files)市级行政区划属性数据表 - 展示地级行政区与省级行政区的层级关联关系案例三商业选址优化零售企业使用多级行政区划数据进行门店选址分析import geopandas as gpd import networkx as nx from sklearn.cluster import DBSCAN import numpy as np class StoreLocationOptimizer: def __init__(self, province_data, city_data, district_data): self.province_gdf gpd.read_file(province_data) self.city_gdf gpd.read_file(city_data) self.district_gdf gpd.read_file(district_data) def analyze_market_coverage(self, store_locations, radius_km10): 分析门店市场覆盖范围 # 将门店位置转换为GeoDataFrame stores_gdf gpd.GeoDataFrame( store_locations, geometrygpd.points_from_xy( store_locations[longitude], store_locations[latitude] ), crsEPSG:4326 ) # 创建缓冲区转换为投影坐标系计算距离 stores_projected stores_gdf.to_crs(EPSG:3857) stores_projected[buffer] stores_projected.geometry.buffer(radius_km * 1000) # 转换回地理坐标系 stores_projected.set_geometry(buffer, inplaceTrue) stores_projected stores_projected.to_crs(EPSG:4326) # 计算覆盖的行政区划 coverage_results [] for idx, store in stores_projected.iterrows(): # 省级覆盖 province_covered self.province_gdf[ self.province_gdf.intersects(store.buffer) ][name].tolist() # 市级覆盖 city_covered self.city_gdf[ self.city_gdf.intersects(store.buffer) ][name].tolist() # 区县级覆盖 district_covered self.district_gdf[ self.district_gdf.intersects(store.buffer) ][name].tolist() coverage_results.append({ store_id: store[store_id], province_coverage: province_covered, city_coverage: city_covered, district_coverage: district_covered, total_population_coverage: self.calculate_population_coverage( store.buffer ) }) return pd.DataFrame(coverage_results) def calculate_population_coverage(self, buffer_geom): 计算缓冲区覆盖的人口简化示例 # 这里可以集成人口栅格数据或人口统计数据 # 返回估算的覆盖人口 return 0 下一步行动立即开始你的地理分析项目快速开始指南获取数据git clone https://gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP验证数据完整性# 检查Shapefile完整性 ogrinfo -so 1. Country/country.shp country ogrinfo -so 2. Province/province.shp province选择适合的集成方案小型项目直接使用Python geopandasWeb应用转换为GeoJSON Leaflet/Mapbox企业级应用导入PostGIS 空间索引优化性能基准测试建议在投入生产环境前建议进行以下基准测试数据加载性能测试测量不同层级数据的加载时间空间查询性能测试测试不同规模的空间查询响应时间内存使用测试监控处理大型数据集时的内存占用并发访问测试模拟多用户同时访问的场景持续集成与自动化建立自动化数据处理流水线# GitHub Actions示例 name: Data Processing Pipeline on: schedule: - cron: 0 0 * * 0 # 每周日运行 push: branches: [main] jobs: process-data: runs-on: ubuntu-latest steps: - uses: actions/checkoutv2 - name: Set up Python uses: actions/setup-pythonv2 with: python-version: 3.9 - name: Install dependencies run: | pip install geopandas pandas numpy pip install requests shapely - name: Run data validation run: python scripts/validate_data.py - name: Generate statistics report run: python scripts/generate_report.py - name: Upload artifacts uses: actions/upload-artifactv2 with: name: contenteditable="false">【免费下载链接】ChinaAdminDivisonSHP中国行政区划矢量图ESRI Shapefile格式共四级国家、省/直辖市、市、区/县。关键字中国行政区划图中国地图中国行政区中国行政区地图行政区地图行政区行政区划地图矢量数据矢量地理数据省级直辖市市级区/县级行政区划图。项目地址: https://gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考