Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nodoka4318/hokkaidle-discord-bot
https://github.com/nodoka4318/hokkaidle-discord-bot
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/nodoka4318/hokkaidle-discord-bot
- Owner: Nodoka4318
- Created: 2024-06-22T04:54:17.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-24T11:51:16.000Z (6 months ago)
- Last Synced: 2024-06-24T21:50:17.912Z (6 months ago)
- Language: TypeScript
- Size: 2.23 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hokkaidle Discord Bot
inspired by [Original Hokkaidle](https://hokkaidle.web.app) ([GitHub](https://github.com/takapiro99/hokkaidle))all resources are from [国土数値情報ダウンロード-国土地理院](https://nlftp.mlit.go.jp/ksj/index.html)
## Demo
https://github.com/Nodoka4318/hokkaidle-discord-bot/assets/78198198/a4381ab9-08ed-4e0d-85da-4fefebe2dae5
## Setup
1. Copy `config.json.default` to `config.json` and fill in `token`, `clientId`, and `guildId`.
2. Install dependencies and run the bot:
```
$ npm install --omit=dev
$ npm start
```## Note
Resources are generated by the following script:```python
import geopandas as gpd
import matplotlib.pyplot as plt
import json
import os# GeoJSONファイル
geojson_file = '/path/to/your.geojson'
gdf = gpd.read_file(geojson_file)municipality_name_field = 'N03_004'
district_name_field = 'N03_005'
subprefecture_name_field = 'N03_002'regions = []
names_set = set()# 出力フォルダ
output_dir = './images'
os.makedirs(output_dir, exist_ok=True)code = 1
for idx, row in gdf.iterrows():
name = row[municipality_name_field]
if district_name_field in row and row[district_name_field]:
name += row[district_name_field]subprefecture = row[subprefecture_name_field]
if name in names_set:
continue
names_set.add(name)
geometry = row['geometry']
centroid = geometry.centroid
latitude = centroid.y
longitude = centroid.x
region_info = {
"name": name,
"code": code,
"subprefecture": subprefecture,
"latitude": latitude,
"longitude": longitude
}
regions.append(region_info)
fig, ax = plt.subplots()gdf[(gdf[municipality_name_field] == row[municipality_name_field]) &
((gdf[district_name_field] == row[district_name_field]) if district_name_field in row and row[district_name_field] else True)].plot(ax=ax, color='black', edgecolor='black')
ax.axis('off')
plt.savefig(f'{output_dir}/{code}.png', bbox_inches='tight', pad_inches=0)
plt.close()
code += 1with open('./regions.json', 'w', encoding='utf-8') as f:
json.dump(regions, f, ensure_ascii=False, indent=2)print("処理が完了しました。")
```