logo

ジュリアでSHPファイルを読む方法 📂ジュリア

ジュリアでSHPファイルを読む方法

コード

screen

XsDB_주거인구_100M_TM.shpというshpファイルを読み込むコードは以下の通りだ。

using Shapefile

cd(@__DIR__)
path = "XsDB_주거인구_100M_TM.shp"
table = Shapefile.Table(path)

using DataFrames
df = DataFrame(table)

もちろん、ファイルを読み込むだけではできることが限られており、データを調べるためにはデータフレームに変換する必要がある。

実行結果

959660×16 DataFrame
    Row │ geometry                     MEGA_NM                            MEGA_CD  CTY_NM                    CTY_CD  X_AXIS  Y_AXIS  HOUS     POP      POP_10   POP_20   POP_30   POP_40   POP_50   POP_60_O  \xb9\xe8\xc6\xf7ó 
        │ Point…?                      String                             String   String                    String  Int64   Int64   Float64  Float64  Float64  Float64  Float64  Float64  Float64  Float64   String
────────┼─────────────────────────────────────────────────────────────────────────────────────────────────
      1 │ Point(254298.0, 4.26549e5)   \xb0\xe6\xb1\u2d75                 41       \xbf\xa9\xc1ֱ\xba          41730   365950  526450    10.08    24.56     4.64     1.92     1.84     4.72     4.32      7.12  biz-gis.com
      2 │ Point(2.59622e5, 4.24405e5)  \xb0\xe6\xb1\u2d75                 41       \xbf\xa9\xc1ֱ\xba          41730   371250  524250     1.42     3.47     0.81     0.29     0.52     0.52     0.59      0.74  biz-gis.com
      3 │ Point(2.61134e5, 423221.0)   \xb0\xe6\xb1\u2d75                 41       \xbf\xa9\xc1ֱ\xba          41730   372750  523050     1.26     3.08     0.68     0.28     0.35     0.49     0.45      0.83  biz-gis.com
      4 │ Point(2.50311e5, 4.15806e5)  \xb0\xe6\xb1\u2d75                 41       \xbf\xa9\xc1ֱ\xba          41730   361850  515750    10.08    25.2      3.68     2.96     1.68     4.4      6.0       6.48  biz-gis.com
   ⋮    │              ⋮                               ⋮                     ⋮                ⋮                ⋮       ⋮       ⋮        ⋮        ⋮        ⋮        ⋮        ⋮        ⋮        ⋮        ⋮              ⋮
 959658 │ Point(2.09955e5, 2.46768e5)  \xc0\xfc\xb6\xf3\xbaϵ\xb5          45       \xbf\xcf\xc1ֱ\xba          45710   319750  347150     1.83     4.53     1.92     0.24     0.45     0.72     0.69      0.51  biz-gis.com
 959659 │ Point(215588.0, 4.55344e5)   \xb0\xe6\xb1\u2d75                 41       \xb3\xb2\xbe\xe7\xc1ֽ\xc3  41360   327550  555650     2.38     5.31     0.91     0.74     0.57     0.97     1.05      1.07  biz-gis.com
 959660 │ Point(2.54717e5, 4.24754e5)  \xb0\xe6\xb1\u2d75                 41       \xbf\xa9\xc1ֱ\xba          41730   366350  524650     1.26     3.07     0.58     0.24     0.23     0.59     0.54      0.89  biz-gis.com
                                                                                                                                                                                                             959653 rows omitted

環境

  • OS: Windows
  • julia: v1.5.0