地理空间文件格式:shapefile(最常见)、GeoJSON、KML和GPKG
文件读取
# Read in the data
full_data = gpd.read_file("../input/geospatial-learn-course-data/DEC_lands/DEC_lands/DEC_lands.shp")
# View the first five rows of the data
full_data.head()
坐标参考系由欧洲石油勘探集团(EPSG)规范引用。
这个GeoDataFrame使用的是EPSG 32630,它通常被称为“墨卡托”投影。此投影保留角度(使其对航海有用)并稍微扭曲区域。
但是,当从CSV文件创建GeoDataFrame时,我们必须设置CRS。EPSG 4326对应于经纬度坐标。
# Create a DataFrame with health facilities in Ghana
facilities_df = pd.read_csv("../input/geospatial-learn-course-data/ghana/ghana/health_facilities.csv")
# Convert the DataFrame to a GeoDataFrame
facilities = gpd.GeoDataFrame(facilities_df, geometry=gpd.points_from_xy(facilities_df.Longitude, facilities_df.Latitude))
# Set the coordinate reference system (CRS) to EPSG 4326
facilities.crs = {
'init': 'epsg:4326'}
DataFrame常用参数
regions.geometry.length # 线长度
regions.geometry.area # 区域面积
画图
静态
# 1.简单的图层叠加
# Define a base map with county boundaries
ax = counties.plot(figsize=(10,10), color='none', edgecolor='gainsboro', zorder=3)
# Add wild lands, campsites, and foot trails to the base map
wild_lands.plot(color='lightgreen', ax=ax)
campsites.plot(color='maroon', markersize=2, ax=ax)
trails.plot(color='black', markersize=1, ax=ax)
# 2.考虑坐标参考的一致性
ax = regions.plot(figsize=(8,8), color='whitesmoke', linestyle=':', edgecolor='black')
facilities.to_crs(epsg=