前言
数据来源于王法辉教授的GIS和数量方法,以后有空,我会利用python来实现里面的案例,这里向王法辉教授致敬。
绘制普查人口密度格局
使用属性查询提取区边界
import numpy as np import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt import arcpy from arcpy import env plt.style.use('ggplot')#使用ggplot样式 %matplotlib inline#输出在线图片
plt.rcParams['font.family'] = ['sans-serif'] plt.rcParams['font.sans-serif'] = ['SimHei']# 替换sans-serif字体为黑体 plt.rcParams['axes.unicode_minus'] = False # 解决坐标轴负数的负号显示问题
regions = gpd.GeoDataFrame.from_file('../Census.gdb',layer='County') regions
BRTrt = regions[regions.NAMELSAD10=='East Baton Rouge Parish']
投影
BRTrt = BRTrt.to_crs('EPSG:26915') BRTrt.crs
BRTrt.to_file('BRTrt.shp')
裁剪数据
Tract = gpd.GeoDataFrame.from_file('../Census.gdb',layer='Tract') Tract = Tract.to_crs('EPSG:26915')
TractUtm = gpd.GeoDataFrame.from_file('TractUtm.shp') BRTrtUtm = gpd.GeoDataFrame.from_file('BRTrt.shp')
# Set workspace env.workspace = r"MyProject" # Set local variables in_features = "TractUtm.shp" clip_features = "BRTrt.shp" out_feature