• 公図のCRSは以下の通り2種類あり、これをフォルダ分けする。
  • 地籍調査済みの箇所 → 緯度経度
  • 上記以外 → 平面直角座標系のようなもの
#geojsonを公共座標と任意座標でフォルダ分けする

import shutil
import re
import glob
import os

# パターンファイルの作成
pattern1 = '公共座標'
pattern2 = '任意座標'

# ファイルパス
path_locate = r"Z:\ikain\Documents\gis\公図\test"

# ファイルの取得
file_list = glob.glob(os.path.join(path_locate,"*.geojson"))
print(file_list)

# 保存フォルダを作成する
dir_pattern1 = os.path.join(path_locate,pattern1)

if not os.path.isdir(dir_pattern1):
  os.makedirs(dir_pattern1)
  print(pattern1,"フォルダを作成しました。")

dir_pattern2 = os.path.join(path_locate,pattern2)

if not os.path.isdir(dir_pattern2):
  os.makedirs(dir_pattern2)
  print(pattern2,"フォルダを作成しました。")

dir_pattern3 = os.path.join(path_locate,"未分類")

if not os.path.isdir(dir_pattern3):
  os.makedirs(dir_pattern3)
  print("未分類フォルダを作成しました。")

for textfile in file_list:

  f = open(textfile, encoding="utf-8")
  lines = f.readlines()
  f.close

  if re.search(pattern1,"".join(lines)):
    print(textfile,"-> 公共座標")
    shutil.copy(textfile,dir_pattern1)
  elif re.search(pattern2,"".join(lines)):
    print(textfile,"-> 任意座標")
    shutil.copy(textfile,dir_pattern2)
  else:
    print(textfile,"-> 未分類")
    shutil.copy(textfile,dir_pattern3)