0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

geopandasとpandasのデータフレームを結合してシェープファイルにする

Last updated at Posted at 2022-02-14

モジュールimport

import geopandas as gpd
import pandas as pd
from os import path
import os

適当に用意した四次メッシュshapeファイル読み込み

path_shp = "../MESH4.shp"
gdf = gpd.read_file(path_shp)
print(gdf.head())

結合対象のデータ読み込み

path_m = "../cleansed.csv"
df = pd.read_csv(path_m, index_col=0)
print(df.head())
df["mesh4code"] = df["mesh4code"].astype(str)

出発地のメッシュコードをキーにinner join

merged_data = pd.merge(df, gdf, left_on='mesh4code', right_on='MESH4_ID')

gdf_out = gpd.GeoDataFrame(merged_data)
print(gdf_out.head())
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?