当前位置:首页>python>使用 Python 绘制历年中国省市区县地图(小地图版本+长版)

使用 Python 绘制历年中国省市区县地图(小地图版本+长版)

  • 2026-06-28 16:48:03
使用 Python 绘制历年中国省市区县地图(小地图版本+长版)
由于借助 AI 工具学习编程已经变得非常容易了,因此之后的课程就不再默认进行视频讲解了,如果特别需要视频讲解也可以联系李老师预约讲解~
讲义材料学习过程中遇到的问题也可以及时与李老师联系。

一、背景与原理

之前我们使用 R 语言的 sf + ggplot2 体系绘制历年中国省市区县地图(小地图版本 + 长版),本讲义将同样的功能用 Python 实现。Python 版本使用 geopandas + matplotlib 体系,提供了完整的模块化绘图函数。

附件中提供了 1949~2021 年每年的省市区县地图数据,包含 mini 和 long 两套:

mini 版本(小地图版本)
long 版本(长版)

R 与 Python 的包映射

R 包
Python 等价
功能
sf
geopandas
矢量数据读写与操作
ggplot2 + geom_sf
matplotlib
地图绘制
ggspatial(比例尺、指北针)
matplotlib(手动实现)
地图装饰
raster
rasterio
栅格数据读取
readxl
pandas(read_excel)
Excel 数据读取
dplyr
pandas
数据操作
scico
matplotlib colormaps
科学配色

二、使用 reticulate 创建与管理 Python 虚拟环境

2.1 安装 reticulate

options(repos = c(CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
install.packages("reticulate")

2.2 虚拟环境初始化原理

reticulate 会在 R 会话中绑定一个 Python 解释器,绑定后不可更改。因此我们必须在任何 {python} chunk 运行之前,通过 Sys.setenv(RETICULATE_PYTHON = ...) 环境变量锁定 Python 路径。setup chunk 中的代码已完成这一操作。

2.3 安装 Python 包

py_pkgs <- c("numpy""pandas""geopandas""matplotlib",
"rasterio""shapely""openpyxl""affine")
installed <- py_list_packages(".venv")$package
need_install <- setdiff(py_pkgs, installed)
if (length(need_install) > 0) {
  virtualenv_install(".venv", packages = need_install)
cat("已安装:"paste(need_install, collapse = ", "), "\n")
else {
cat("所有包已安装完毕。\n")
}

2.4 验证激活状态

py_config()

2.5 查看已安装的包

py_list_packages(".venv")

2.6 虚拟环境管理常用命令

# 删除虚拟环境(如需重建)
virtualenv_remove(".venv")
# 重建虚拟环境
virtualenv_create(".venv")
virtualenv_install(".venv", packages = c("numpy""pandas""geopandas", ...))

三、环境配置与数据准备

3.1 导入 Python 包

import os
import numpy as np
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import matplotlib.font_manager as fm
from matplotlib.patches import Rectangle
from shapely.geometry import box, Point
from shapely.ops import unary_union
import warnings
warnings.filterwarnings("ignore")

3.2 全局配置

# 中国地图常用的 Albers 等面积投影
MY_CRS = "+proj=aea +lat_0=0 +lon_0=105 +lat_1=25 +lat_2=47 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"
# 小地图坐标范围(MY_CRS 投影下的坐标)
SMALL_BBOX = {"xmin"120000"xmax"1766004.1,
"ymax"2557786.0"ymin"320000}
# 小地图缩放和平移参数
SMALL_SCALE = 0.5
SMALL_OFFSET_X = 2100000
SMALL_OFFSET_Y = 1665139
# ---- 字体配置:使用附件中的 LXGWWenKai 字体 ----
_font_path = os.path.join(os.getcwd(), "LXGWWenKai-Regular.ttf")
fm.fontManager.addfont(_font_path)
_font_prop = fm.FontProperties(fname=_font_path)
CN_FONT = _font_prop.get_name()
plt.rcParams["font.family"] = CN_FONT
plt.rcParams["axes.unicode_minus"] = False
plt.rcParams["font.size"] = 10
# 配色方案
LINE_COLORS = {
"九段线""#A29AC4",
"海岸线""#0055AA",
"小地图框格""black",
"省份""black",
}
LINE_WIDTHS = {
"九段线"0.6,
"海岸线"0.3,
"小地图框格"0.3,
"省份"0.3,
}

3.3 比例尺与装饰工具函数

defadd_scale_bar(ax, provmap, location="bl",
                   height_scale=0.016, width_scale=0.2):
"""在地图左下角添加比例尺。"""
    bounds = provmap.total_bounds
    map_width_m = bounds[2] - bounds[0]
    target_km = map_width_m * width_scale / 1000
    nice_values = [5001000200030005000100002000050000100000]
    bar_km = min(nice_values, key=lambda x: abs(x - target_km))
    bar_m = bar_km * 1000
    x0_frac = 0.08if location == "bl"else0.62
    xlim = ax.get_xlim()
    ylim = ax.get_ylim()
    ax_width = xlim[1] - xlim[0]
    x0_data = xlim[0] + x0_frac * ax_width
    y0_data = ylim[0] + 0.04 * (ylim[1] - ylim[0])
    bar_height_m = map_width_m * height_scale
    n_seg = 4
    seg_w = bar_m / n_seg
for i inrange(n_seg):
        color = "black"if i % 2 == 0else"white"
        rect = Rectangle(
            (x0_data + i * seg_w, y0_data), seg_w, bar_height_m,
            facecolor=color, edgecolor="black", linewidth=0.5,
            clip_on=False, zorder=10,
        )
        ax.add_patch(rect)
    ax.text(x0_data + bar_m / 2, y0_data - bar_height_m * 0.3,
f"{bar_km:,} km", fontsize=7, ha="center", va="top",
            color="black", zorder=10)
defadd_north_arrow(ax):
"""在地图右上角添加指北针。"""
    ax.annotate("N", xy=(0.980.95), xycoords="axes fraction",
                fontsize=10, fontweight="bold", ha="center", va="bottom")
    ax.annotate("", xy=(0.980.95), xycoords="axes fraction",
                xytext=(0.980.88), textcoords="axes fraction",
                arrowprops=dict(arrowstyle="->", color="black", lw=1.5))
defdraw_lines(ax, provlinemap):
"""绘制线条元素。"""
for _, row in provlinemap.iterrows():
        cls = row["class"]
        color = LINE_COLORS.get(cls, "gray")
        lw = LINE_WIDTHS.get(cls, 0.3)
        geom = row["geometry"]
if geom.geom_type == "MultiLineString":
for line in geom.geoms:
                xs, ys = line.xy
                ax.plot(xs, ys, color=color, linewidth=lw, zorder=3)
elif geom.geom_type == "LineString":
            xs, ys = geom.xy
            ax.plot(xs, ys, color=color, linewidth=lw, zorder=3)
defdraw_province_labels(ax, provmap, centroids):
"""绘制省名标注。"""
for i, row in provmap.iterrows():
        cx, cy = centroids.iloc[i].x, centroids.iloc[i].y
        ax.text(cx, cy, row["省"], fontsize=5, color="gray",
                ha="center", va="center", zorder=4)
defadd_vertical_colorbar(ax, fig, cmap, norm, label=None,
                           ticks=None, ticklabels=None,
                           n_segments=4):
"""在地图左下角、比例尺上方绘制竖向分段色条。"""
    xlim = ax.get_xlim()
    ylim = ax.get_ylim()
    ax_width = xlim[1] - xlim[0]
    ax_height = ylim[1] - ylim[0]
    cb_width_m = ax_width * 0.0075
    cb_height_m = ax_height * 0.15
    seg_height_m = cb_height_m / n_segments
    x0_frac = 0.08
    x0_data = xlim[0] + x0_frac * ax_width
    scale_y0 = ylim[0] + 0.04 * ax_height
    bar_height_m = ax_width * 0.016
    cb_bottom = scale_y0 + bar_height_m + ax_height * 0.025
    vmin, vmax = norm.vmin, norm.vmax
for i inrange(n_segments):
        frac_lo = i / n_segments
        frac_hi = (i + 1) / n_segments
        color = cmap((frac_lo + frac_hi) / 2)
        y_bottom = cb_bottom + i * seg_height_m
        rect = Rectangle(
            (x0_data, y_bottom), cb_width_m, seg_height_m,
            facecolor=color, edgecolor="black", linewidth=0.5,
            clip_on=False, zorder=10,
        )
        ax.add_patch(rect)
if ticks isnotNoneand ticklabels isnotNone:
for tick_val, tick_lbl inzip(ticks, ticklabels):
            frac = (tick_val - vmin) / (vmax - vmin) if vmax > vmin else0
            frac = max(0min(1, frac))
            y_pos = cb_bottom + frac * cb_height_m
            ax.plot(
                [x0_data + cb_width_m, x0_data + cb_width_m + cb_width_m * 0.3],
                [y_pos, y_pos],
                color="black", linewidth=0.5, clip_on=False, zorder=10,
            )
            ax.text(
                x0_data + cb_width_m + cb_width_m * 0.4, y_pos,
                tick_lbl, fontsize=6, ha="left", va="center",
                color="black", zorder=10,
            )
if label:
        ax.text(
            x0_data + cb_width_m / 2, cb_bottom + cb_height_m + ax_height * 0.01,
            label, fontsize=7, ha="center", va="bottom",
            color="black", zorder=10,
        )

四、小地图版本

4.1 数据读取

读取小地图版本的中国省级地图数据:

# 读取省级多边形
provmap = gpd.read_file(
"provmapdata/minishp/chinaprov2019mini/chinaprov2019mini.shp",
    encoding="utf-8"
)
provmap = provmap.dropna(subset=["省代码"]).reset_index(drop=True)
print(f"省级多边形: {len(provmap)} 个区域")
print(provmap.head())

读取线条数据(九段线、海岸线、小地图框格):

# 读取线条
provlinemap = gpd.read_file(
"provmapdata/minishp/chinaprov2019mini/chinaprov2019mini_line.shp",
    encoding="utf-8"
)
keep_classes = ["九段线""海岸线""小地图框格"]
provlinemap = provlinemap[
    provlinemap["class"].isin(keep_classes)
][["class""geometry"]].reset_index(drop=True)
print(f"线条: {len(provlinemap)} 条")
print(provlinemap["class"].value_counts())

4.2 在地图上添加散点图

读取经纬度数据并转换为 GeoDataFrame:

# 读取散点数据
pointdf = pd.read_excel("瞪羚、独角兽、创新型企业经纬度数据.xlsx")
pointdf = pointdf.dropna(subset=["经度"]).reset_index(drop=True)
print(f"散点数据: {len(pointdf)} 条")
print(pointdf.head())
# 转换为 GeoDataFrame(WGS84 → MY_CRS)
pointdfsf = gpd.GeoDataFrame(
    pointdf,
    geometry=gpd.points_from_xy(pointdf["经度"], pointdf["纬度"]),
    crs="EPSG:4326",
)
pointdfsf = pointdfsf.to_crs(MY_CRS)
print(pointdfsf.crs)

4.3 小地图的散点处理原理

小地图框格显示的是南海诸岛放大图。对于散点数据,需要将落在小地图范围内的点平移到框格位置。处理流程如下:

  1. 用 st_bbox 定义小地图在主图中的范围
  2. 用 st_intersection 提取落在该范围内的散点
  3. 对这些散点执行:先以范围左下角为原点缩小到 50%,再平移到小地图框格位置
  4. 将平移后的散点与原始散点合并
# 步骤 1:定义小地图范围
small_bbox = box(
    SMALL_BBOX["xmin"], SMALL_BBOX["ymin"],
    SMALL_BBOX["xmax"], SMALL_BBOX["ymax"]
)
# 步骤 2:提取小地图范围内的散点
pointdfsf_small = pointdfsf[
    pointdfsf.geometry.intersects(small_bbox)
].copy()
print(f"小地图范围内的散点: {len(pointdfsf_small)} 个")
# 步骤 3:平移到小地图位置
# 先将坐标原点移到 (xmin, ymin),再缩放 0.5,最后平移到目标位置
gdf_small = pointdfsf_small.copy()
gdf_small["geometry"] = gdf_small.geometry.translate(
    xoff=-SMALL_BBOX["xmin"],
    yoff=-SMALL_BBOX["ymin"],
)
gdf_small["geometry"] = gdf_small.geometry.scale(
    xfact=SMALL_SCALE, yfact=SMALL_SCALE, origin=(00),
)
gdf_small["geometry"] = gdf_small.geometry.translate(
    xoff=SMALL_OFFSET_X + SMALL_BBOX["xmin"] * SMALL_SCALE,
    yoff=SMALL_OFFSET_Y + SMALL_BBOX["ymin"] * SMALL_SCALE,
)
# 步骤 4:合并
pointdfsfall = pd.concat([pointdfsf, gdf_small], ignore_index=True)
print(f"合并后散点总数: {len(pointdfsfall)} 个")

4.4 绘制散点地图

# 获取省名标注坐标(质心)
centroids = provmap.geometry.representative_point()
# 为每个省分配颜色
all_colors = (
    plt.colormaps.get_cmap("tab20").colors +
    plt.colormaps.get_cmap("tab20b").colors +
    plt.colormaps.get_cmap("Set3").colors
)
unique_provs = list(dict.fromkeys(pointdfsfall["省"].values))
color_map = {prov: all_colors[i % len(all_colors)] for i, prov inenumerate(unique_provs)}
# 绘图
此处代码需下载讲义材料查看~

五、绘制填充地图

5.1 读取市级地图并统计

虽然绘制市级地图,但我们仍然使用省级线条(突出省份区域):

# 读取市级地图
citymap = gpd.read_file(
"citymapdata/minishp/chinacity2021mini/chinacity2021mini.shp",
    encoding="utf-8"
)
citymap = citymap.dropna(subset=["省代码"]).reset_index(drop=True)
print(f"市级多边形: {len(citymap)} 个区域")
# 省级线条(包含省份边界)
provlinemap2 = gpd.read_file(
"provmapdata/minishp/chinaprov2021mini/chinaprov2021mini_line.shp",
    encoding="utf-8"
)
keep_classes2 = ["九段线""海岸线""小地图框格""省份"]
provlinemap2 = provlinemap2[
    provlinemap2["class"].isin(keep_classes2)
][["class""geometry"]].reset_index(drop=True)
# 统计每个城市的公司数量
citydf = pointdf.groupby(["市""市代码"]).size().reset_index(name="n")
print(citydf.head(10))
# 合并到地图数据
citymap2 = citymap.merge(citydf, on="市代码", how="left")
citymap2["n"] = citymap2["n"].fillna(0)
citymap2["plot_val"] = citymap2["n"] + 1# log(0) 无定义
print(f"有数据的城市: {(citymap2['n'] > 0).sum()} 个")

5.2 连续变量填色地图

fig, ax = plt.subplots(11, figsize=(108.5), dpi=400)
cmap = plt.colormaps.get_cmap("YlOrBr")
norm = mcolors.LogNorm(vmin=citymap2["plot_val"].min(),
                       vmax=citymap2["plot_val"].max())
# 填充地图
citymap2.plot(ax=ax, column="plot_val", cmap=cmap, norm=norm,
              edgecolor="gray", linewidth=0.01, zorder=1)
# 设置等比例,避免地图变形
ax.set_aspect("equal")
_xl = ax.get_xlim(); _yl = ax.get_ylim()
_dw = _xl[1] - _xl[0]; _dh = _yl[1] - _yl[0]
fig.set_size_inches(1010 * _dh / _dw)
ax.set_xlim(_xl); ax.set_ylim(_yl)
# 线条
draw_lines(ax, provlinemap2)
# 散点(叠加)
for prov, color in color_map.items():
    mask = pointdfsfall["省"] == prov
    pointdfsfall[mask].plot(ax=ax, color=color, markersize=0.5, zorder=2)
# 省名
draw_province_labels(ax, provmap, centroids)
# 装饰
此处代码需下载讲义材料查看~

5.3 连续变量填色地图(竖直图例)

也可以使用竖直图例展示连续变量:

fig, ax = plt.subplots(11, figsize=(108.5), dpi=400)
# 使用与 pic2 相同的 YlOrBr + LogNorm 配色
cmap3 = plt.colormaps.get_cmap("YlOrBr")
norm3 = mcolors.LogNorm(vmin=citymap2["plot_val"].min(),
                        vmax=citymap2["plot_val"].max())
citymap2.plot(ax=ax, column="plot_val", cmap=cmap3, norm=norm3,
              edgecolor="gray", linewidth=0.01, legend=False, zorder=1)
# 设置等比例
ax.set_aspect("equal")
_xl3 = ax.get_xlim(); _yl3 = ax.get_ylim()
_dw3 = _xl3[1] - _xl3[0]; _dh3 = _yl3[1] - _yl3[0]
fig.set_size_inches(1010 * _dh3 / _dw3)
ax.set_xlim(_xl3); ax.set_ylim(_yl3)
# 线条
draw_lines(ax, provlinemap2)
# 散点
for prov, color in color_map.items():
    mask = pointdfsfall["省"] == prov
    pointdfsfall[mask].plot(ax=ax, color=color, markersize=0.5, zorder=2)
# 省名
draw_province_labels(ax, provmap, centroids)
# 装饰
此处代码需下载讲义材料查看~

六、使用栅格数据绘制地图

6.1 高分辨率栅格 → 散点

高分辨率的栅格数据可以先聚合(降采样),再转换成密集的散点数据绘制。相当于 R 中 raster::aggregate() + rasterToPoints() 的组合:

import rasterio
from rasterio.warp import Resampling
from shapely.geometry import Point as ShpPoint
# 读取并聚合栅格(每隔 10 个像素取均值)
tif_path = "cn2022.tif"
aggregate_factor = 10
with rasterio.open(tif_path) as src:
    new_width = src.width // aggregate_factor
    new_height = src.height // aggregate_factor
    data = src.read(
        out_shape=(src.count, new_height, new_width),
        resampling=Resampling.average,
    )[0]
from affine import Affine
    transform = Affine(
        src.transform.a * aggregate_factor,
        src.transform.b,
        src.transform.c,
        src.transform.d,
        src.transform.e * aggregate_factor,
        src.transform.f,
    )
    src_crs = src.crs
    nodata = src.nodata
print(f"原始尺寸: {src.width} x {src.height}")
print(f"聚合后: {new_width} x {new_height}")
# 转为 GeoDataFrame
data_float = data.astype(np.float64)
if nodata isnotNone:
    data_float[data == nodata] = np.nan
rows, cols = np.where(~np.isnan(data_float) & (data_float > 0))
xs = [transform * (c + 0.5, r + 0.5for r, c inzip(rows, cols)]
values = data_float[rows, cols]
cn2022points = gpd.GeoDataFrame(
    {"cn2022": values},
    geometry=[ShpPoint(x[0], x[1]) for x in xs],
    crs=src_crs,
)
cn2022points = cn2022points[cn2022points["cn2022"] > 0].reset_index(drop=True)
cn2022points = cn2022points.to_crs(MY_CRS)
print(f"有效散点: {len(cn2022points)} 个")
print(cn2022points.describe())
# 拆分小地图部分
defsplit_for_small_map(gdf):
    small_bbox = box(
        SMALL_BBOX["xmin"], SMALL_BBOX["ymin"],
        SMALL_BBOX["xmax"], SMALL_BBOX["ymax"]
    )
    gdf_small = gdf[gdf.geometry.intersects(small_bbox)].copy()
iflen(gdf_small) > 0:
        gdf_small["geometry"] = gdf_small.geometry.translate(
            xoff=-SMALL_BBOX["xmin"], yoff=-SMALL_BBOX["ymin"])
        gdf_small["geometry"] = gdf_small.geometry.scale(
            xfact=SMALL_SCALE, yfact=SMALL_SCALE, origin=(00))
        gdf_small["geometry"] = gdf_small.geometry.translate(
            xoff=SMALL_OFFSET_X + SMALL_BBOX["xmin"] * SMALL_SCALE,
            yoff=SMALL_OFFSET_Y + SMALL_BBOX["ymin"] * SMALL_SCALE)
return pd.concat([gdf, gdf_small], ignore_index=True)
return gdf
cn2022points_all = split_for_small_map(cn2022points)
print(f"合并后: {len(cn2022points_all)} 个散点")
# 绘图
fig, ax = plt.subplots(11, figsize=(108.5), dpi=400)
cmap = plt.colormaps.get_cmap("RdYlBu_r")
norm = mcolors.LogNorm(vmin=cn2022points_all["cn2022"].min(),
                       vmax=cn2022points_all["cn2022"].max())
# 散点
cn2022points_all.plot(ax=ax, column="cn2022", cmap=cmap, norm=norm,
                      markersize=0.1, zorder=1)
# 省级边界
provmap.plot(ax=ax, facecolor="none", edgecolor="gray",
             linewidth=0.01, zorder=2)
# 设置等比例
ax.set_aspect("equal")
_xl4 = ax.get_xlim(); _yl4 = ax.get_ylim()
_dw4 = _xl4[1] - _xl4[0]; _dh4 = _yl4[1] - _yl4[0]
fig.set_size_inches(1010 * _dh4 / _dw4)
ax.set_xlim(_xl4); ax.set_ylim(_yl4)
# 线条
draw_lines(ax, provlinemap)
# 省名
for i, row in provmap.iterrows():
    cx, cy = centroids.iloc[i].x, centroids.iloc[i].y
    ax.text(cx, cy, row["省"], fontsize=5, color="gray",
            ha="center", va="center", zorder=4)
ax.set_axis_off()
ax.set_title("2022 年中国夜间灯光地图", fontsize=14,
             fontweight="bold", pad=30)
ax.text(0.51.03"绘图:微信公众号 RStata",
        transform=ax.transAxes, fontsize=9, ha="center", va="bottom",
        color="gray")
add_scale_bar(ax, provmap)
add_north_arrow(ax)
# 水平色条(左下角比例尺上方)
此处代码需下载讲义材料查看~

6.2 低分辨率栅格 → 多边形

低分辨率的栅格数据适合转换成 polygon 绘制:

from rasterio.features import shapes as rasterio_shapes
from shapely.geometry import shape as shapely_shape
tif_path2 = "NH3_em_anthro_2015_sector_ENE.tif"
with rasterio.open(tif_path2) as src:
    data = src.read(1)
    transform = src.transform
    src_crs = src.crs
    nodata = src.nodata
data_float = data.astype(np.float64)
if nodata isnotNone:
    data_float[data == nodata] = np.nan
# 栅格转多边形
mask = ~np.isnan(data_float) & (data_float > 0)
results = [
    {"properties": {"NH3": v}, "geometry": shapely_shape(s)}
for s, v in rasterio_shapes(data_float, transform=transform, mask=mask)
if v > 0
]
cn2022polygons = gpd.GeoDataFrame.from_features(results, crs=src_crs)
cn2022polygons = cn2022polygons.to_crs(MY_CRS)
print(f"多边形: {len(cn2022polygons)} 个")
print(cn2022polygons["NH3"].describe())
# 拆分小地图
cn2022polygons_all = split_for_small_map(cn2022polygons)
# 裁剪到中国范围
china_union = unary_union(provmap.geometry)
cn2022polygons_all = cn2022polygons_all[
    cn2022polygons_all.geometry.intersects(china_union)
].copy()
cn2022polygons_all["geometry"] = cn2022polygons_all.geometry.intersection(china_union)
# 计算色标范围
values= cn2022polygons_all["NH3"].dropna().values
values=values[values>0]
log_vals = np.log10(values)
rmin, rmax = log_vals.min(), log_vals.max()
vmin =10** (rmin +0.02* (rmax - rmin))
vmax =10** (rmax -0.02* (rmax - rmin))
vmedian =10** np.mean([rmin, rmax])
print(f"色标范围: {vmin:.4f} ~ {vmax:.4f}, 中位数: {vmedian:.4f}")
fig, ax = plt.subplots(11, figsize=(108.5), dpi=400)
cmap = plt.colormaps.get_cmap("YlOrRd_r")
norm = mcolors.LogNorm(vmin=vmin, vmax=vmax)
# 填充地图
cn2022polygons_all.plot(ax=ax, column="NH3", cmap=cmap, norm=norm,
                        edgecolor="none", linewidth=0, zorder=1)
# 设置等比例
ax.set_aspect("equal")
_xl5 = ax.get_xlim(); _yl5 = ax.get_ylim()
_dw5 = _xl5[1] - _xl5[0]; _dh5 = _yl5[1] - _yl5[0]
fig.set_size_inches(1010 * _dh5 / _dw5)
ax.set_xlim(_xl5); ax.set_ylim(_yl5)
# 省级边界
provmap.plot(ax=ax, facecolor="none", edgecolor="gray",
             linewidth=0.01, zorder=2)
# 线条
draw_lines(ax, provlinemap)
# 省名
for i, row in provmap.iterrows():
    cx, cy = centroids.iloc[i].x, centroids.iloc[i].y
    ax.text(cx, cy, row["省"], fontsize=5, color="gray",
            ha="center", va="center", zorder=4)
ax.set_axis_off()
ax.set_title("各地区 NH₃ 排放分布(单位:kg/m²/yr)", fontsize=14,
             fontweight="bold", pad=30)
ax.text(0.51.03"绘图:微信公众号 RStata",
        transform=ax.transAxes, fontsize=9, ha="center", va="bottom",
        color="gray")
add_scale_bar(ax, provmap)
add_north_arrow(ax)
# 水平色条(左下角比例尺上方,宽度为原来的 1/3)
此处代码需下载讲义材料查看~

七、长版地图

长版地图数据的使用更简单,这里仅演示散点图。长版不包含小地图框格,没有南海小地图:

# 读取长版省级地图
provmap_long = gpd.read_file(
"provmapdata/longshp/chinaprov2019long/chinaprov2019long.shp",
    encoding="utf-8"
)
provmap_long = provmap_long.dropna(subset=["省代码"]).reset_index(drop=True)
print(f"长版省级多边形: {len(provmap_long)} 个")
# 长版线条(不含小地图框格)
provlinemap_long = gpd.read_file(
"provmapdata/longshp/chinaprov2019long/chinaprov2019long_line.shp",
    encoding="utf-8"
)
keep_long = ["九段线""海岸线"]
provlinemap_long = provlinemap_long[
    provlinemap_long["class"].isin(keep_long)
][["class""geometry"]].reset_index(drop=True)
# 查看范围
bounds = provmap_long.total_bounds
print(f"X 范围: {bounds[0]:.0f} ~ {bounds[2]:.0f}")
print(f"Y 范围: {bounds[1]:.0f} ~ {bounds[3]:.0f}")
# 绘图
fig, ax = plt.subplots(11, figsize=(89), dpi=400)
# 底图
provmap_long.plot(ax=ax, facecolor="white", edgecolor="gray",
                  linewidth=0.01, zorder=1)
# 设置等比例
ax.set_aspect("equal")
_xl6 = ax.get_xlim(); _yl6 = ax.get_ylim()
_dw6 = _xl6[1] - _xl6[0]; _dh6 = _yl6[1] - _yl6[0]
fig.set_size_inches(88 * _dh6 / _dw6)
ax.set_xlim(_xl6); ax.set_ylim(_yl6)
# 散点
for prov, color in color_map.items():
    mask = pointdfsf["省"] == prov
    pointdfsf[mask].plot(ax=ax, color=color, markersize=2, zorder=2)
# 线条
draw_lines(ax, provlinemap_long)
# 省名
centroids_long = provmap_long.geometry.representative_point()
for i, row in provmap_long.iterrows():
    cx, cy = centroids_long.iloc[i].x, centroids_long.iloc[i].y
    ax.text(cx, cy, row["省"], fontsize=5, color="gray",
            ha="center", va="center", zorder=4)
# 装饰
ax.set_axis_off()
ax.set_title("瞪羚、独角兽、创新型企业的地理分布",
             fontsize=14, fontweight="bold", pad=30)
ax.text(0.51.03"绘图:微信公众号 RStata",
        transform=ax.transAxes, fontsize=9, ha="center", va="bottom",
        color="gray")
add_scale_bar(ax, provmap_long, height_scale=0.016, width_scale=0.3)
add_north_arrow(ax)
fig.text(0.50.01"数据来源:瞪羚云网站", ha="center",
         fontsize=7, color="gray")
fig.savefig("pic6.png", bbox_inches="tight", dpi=400)
plt.close(fig)
print("图片已保存: pic6.png")

八、模块化绘图函数

上面的代码逐步演示了完整的绘图流程。为了方便复用,所有绘图逻辑已被封装到 draw_china_map.py 模块中,可以直接调用:

from draw_china_map import (
    read_provmap, read_provline, read_citymap, read_point_data,
    plot_mini_scatter_map, plot_mini_choropleth,
    plot_mini_choropleth_discrete, plot_mini_raster_points,
    plot_mini_raster_polygons, plot_long_scatter_map,
)
# 示例:一键绘制所有 6 张地图
provmap = read_provmap(2019, version="mini")
provline = read_provline(2019, version="mini")
pointdfsf = read_point_data("瞪羚、独角兽、创新型企业经纬度数据.xlsx")
plot_mini_scatter_map(provmap, pointdfsf, provline, save_path="pic1.png")

更多关于地图绘制的内容可以学习平台上的系列课程「使用 R 语言进行地理计算」。

如何参加课程?

是不是感觉很硬核!欢迎报名 RStata 培训班获取全部课程和以会员价获取数据资料(10元/份)详情可阅读这篇推文:数据处理、图表绘制、效率分析与计量经济学如何学习~

详情可点击阅读原文进入 RStata 学院了解(从首页的会员卡专区即可查看和购买会员卡)。

更多关于 RStata 培训班的信息可添加微信号 r_stata2 咨询:

附件下载(点击文末的阅读原文即可跳转):

https://rstata.duanshu.com/#/brief/course/72c36d788f9d4497a7e33f23f9437598

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 08:13:14 HTTP/2.0 GET : https://f.mffb.com.cn/a/489051.html
  2. 运行时间 : 0.084730s [ 吞吐率:11.80req/s ] 内存消耗:4,810.88kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=71281e66606ed69f5d0ed2884a5434a3
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000546s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001010s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000385s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000225s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000466s ]
  6. SELECT * FROM `set` [ RunTime:0.000189s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000586s ]
  8. SELECT * FROM `article` WHERE `id` = 489051 LIMIT 1 [ RunTime:0.000814s ]
  9. UPDATE `article` SET `lasttime` = 1783123994 WHERE `id` = 489051 [ RunTime:0.000999s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000243s ]
  11. SELECT * FROM `article` WHERE `id` < 489051 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000391s ]
  12. SELECT * FROM `article` WHERE `id` > 489051 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.003576s ]
  13. SELECT * FROM `article` WHERE `id` < 489051 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001221s ]
  14. SELECT * FROM `article` WHERE `id` < 489051 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.004072s ]
  15. SELECT * FROM `article` WHERE `id` < 489051 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002400s ]
0.086341s