การพล็อตด้วย GeoJSON

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

Mary van Valkenburg

Data Science Program Manager, Nashville Software School

GeoJSON ของย่านที่อยู่อาศัย

{ "type": "FeatureCollection",
  "features": [
    { "type":"Feature",
      "properties":{
    "name":"Historic Buena Vista"
    },"geometry":{
        "type":"MultiPolygon","coordinates":[[[[-86.79511056795417,36.17575....
neighborhoods = gpd.read_file('./data/neighborhood_boundaries.geojson')
neighborhoods.head(1)
        name             geometry
Historic Buena Vista    (POLYGON ((-86.79511056795417 36.17575964963348...)))
การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

dependency ของ Geopandas

ภาพแสดงแบบ raster และ vector

  • Fiona
    • ให้ Python API สำหรับ OGR
  • GDAL/OGR
    • GDAL สำหรับแปลงข้อมูล raster
    • OGR สำหรับแปลงข้อมูล vector
การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

เปรียบเทียบกราฟิก raster และ vector

ภาพ raster ของ Corfu ภาพ raster ของ Corfu

ภาพ vector ของ Corfu ภาพ vector ของ Corfu

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

Colormap

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

การพล็อตด้วยสี

school_districts.head(3)
first_name     last_name    position    district      geometry
Sharon         Gentry       Member       1    (POLYGON ((-86.771 36.383)...))
Jill           Speering     Vice-Chair   3    (POLYGON ((-86.753 36.404)...))
Jo Ann         Brannon      Member       2    (POLYGON ((-86.766 36.083)...))

เปรียบเทียบ color map

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python
council_dists.plot(
                   column='district', 
                   cmap='Set3', 
                   legend=True)
plt.title('Council Districts')
plt.show();

กราฟ council district พร้อม legend ยาว

leg_kwds={'title':'District Number', 
          'loc': 'upper left', 
          'bbox_to_anchor':(1, 1.03), 
          'ncol':3}
council_dists.plot(column='district', 
                   cmap='Set3',
                   legend=True, 
             legend_kwds=leg_kwds)
plt.title('Council Districts')
plt.show();

กราฟ council district พร้อม legend หลายคอลัมน์

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

มาฝึกกันเถอะ!

การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python

Preparing Video For Download...