Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
オープンデータとDjangoの連携で作る地図アプリ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mopinfish
February 16, 2025
52
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
オープンデータとDjangoの連携で作る地図アプリ
2025/02/15に札幌で行われたFOSS4G Hokkaidoの懇親会でのLT資料です。
Djangoのogrinspectで地理空間データを取り込む手順について発表しました。
mopinfish
February 16, 2025
More Decks by mopinfish
See All by mopinfish
Detecting Quarry Pond Remnants on a Japanese Island Heritage Site Using Sentinel-2 Imagery and Open-Source Remote Sensing Tools
mopinfish
0
47
A Systematic Comparison of RAG Architectures for Geographic POI Question Answering
mopinfish
0
12
北木島丁場跡探索のための衛星画像による水域可視化
mopinfish
0
67
静岡県3都市の道路ネットワーク比較分析
mopinfish
0
35
OSMnx Galleryの紹介
mopinfish
0
330
HelloCyclingステーションの需要をQGISで可視化する
mopinfish
0
130
OSMnxによる街路構造の分析と可視化
mopinfish
0
990
RailsプロジェクトにVuex-ORMを導入した話
mopinfish
0
410
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
108
250k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.7k
How to build a perfect <img>
jonoalderson
1
6k
We Have a Design System, Now What?
morganepeng
55
8.3k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
930
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
670
We Are The Robots
honzajavorek
0
370
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
New Earth Scene 8
popppiees
3
2.6k
Transcript
オープンデータと Djangoの 連携で作る地図アプリ Georepublic Japan 大塚 昇 1 2025/02/15 FOSS4G Hokkaido
LT
自己紹介 • 名前 ◦ 大塚昇 • 経歴 ◦ 2010- 不動産関連サービスのWebエンジニア
◦ 2020- 現職にて行政向けアプリのPM ◦ 2020- 社会人博士課程在籍 • 趣味 ◦ 登山、旅行 2
会社紹介 • 合同会社Georepublic Japan • 位置情報系テクノロジー • タスク管理ツールLOBSTA 3
本日の内容 1. 都知事杯オープンデータハッカソンで地図アプリを作成 2. Djangoのogrinspectを使ってオープンデータをPostgresqlに 取り込み 3. Djangorestframeworkで地図アプリ化 4
都知事杯オープンデータ・ハッカソンとは • 東京都が主催する行政課 題解決のためのイベント • 東京都オープンデータカタ ログサイトに掲載されてい るオープンデータを活用し て、行政課題の解決に向 けた提案を行う
5
作成したアプリ「 OPEN3Dマップ」 • 江東区の文化財をマッピ ング • 文化財に対してAIによって 生成された3Dオブジェクト を登録・閲覧することがで きる
6
利用データ:江東区文化財一覧 7
QGISでシェープファイルに変換 8
Djangoのogrinspectとは • GeoDjangoに含まれる管 理コマンド • ShapefileやGeoJSONな どの地理空間データソー スを解析し、Djangoモデ ルとマッピング辞書を自動 生成する
9 python manage.py ogrinspect <データソース > <モデル 名> [オプション ]
ogrinspectの実行 10 # This is an auto-generated Django model module
created by ogrinspect. from django.contrib.gis.db import models class cultural_properties(models.Model): id = models.FloatField() ...(中略) geom = models.PointField(srid=6668) # Auto-generated `LayerMapping` dictionary for cultural_properties model cultural_properties_mapping = { 'id': 'id', ...(中略) 'geom': 'POINT', } python manage.py ogrinspect \ open3d_map/data/cultural_properties.shp \ cultural_properties --srid=6668 --mapping
Model classとして保存 11 class CulturalProperty(models.Model): name = models.CharField(max_length=254) name_kana =
models.CharField(max_length=254, null=True) name_gener = models.CharField(max_length=254, null=True, blank=True) name_en = models.CharField(max_length=254, null=True) category = models.CharField(max_length=254) type = models.CharField(max_length=254) place_name = models.CharField(max_length=254, null=True, blank=True) address = models.CharField(max_length=254) latitude = models.FloatField(null=True) longitude = models.FloatField(null=True) url = models.CharField(max_length=254, null=True) note = models.CharField(max_length=4094, null=True) geom = models.PointField(srid=6668)
loaderの作成 12 import os from django.contrib.gis.utils import LayerMapping, LayerMapError from
.models import CulturalProperty class CulturalPropertiesLoader: # 1. mapping定義 mapping = { 'name': 'name', ...(中略) 'geom': 'POINT', } # 2. 読み込むファイルを指定し、レイヤーマッピングに変換 path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data', 'cultural_properties.shp')) lm = LayerMapping(CulturalProperty, cls.path, cls.mapping, transform=False, encoding='utf-8') # 3. ロード処理を実行 lm.save(strict=False, verbose=True)
loaderの実行 13 python manage.py shell >>> from open3d_map.loaders import CulturalPropertiesLoader
>>> CulturalPropertiesLoader.run() ...(中略) Saved: CulturalProperty object (2016) Saved: CulturalProperty object (2017) Saved: CulturalProperty object (2018) Saved: CulturalProperty object (2019) Saved: CulturalProperty object (2020) Saved: CulturalProperty object (2021) Saved: CulturalProperty object (2022)
読み込んだデータの確認 14
APIコンソールで確認 15
地図画面でのマッピング 16
まとめ • Djangoのogrinspectコマンドを使うことで、地理空間データを 簡単に取り込める • 取り込んだデータを返却するAPIをDjangoRestFrameworkで 作成し、地図アプリケーションを効率的に開発できる 17
ご清聴ありがとうございました 18
19