Skip to content

jinx2plus/MapmatchingTrajectorytoLinks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A Study on the Effectiveness of Rest Areas Using Continuous Driving Time

λŒ€μš©λŸ‰ λͺ¨λΉŒλ¦¬ν‹° λ°μ΄ν„°μš© λ§΅λ§€μΉ­ μ—”μ§„: 연속 μš΄μ „μ‹œκ°„ 기반 μ‘ΈμŒμ‰Όν„° νš¨κ³Όμ„± 뢄석

이 μ €μž₯μ†ŒλŠ” ν•œκ΅­******곡단 의뒰 ν•˜μ— ν™”λ¬Όμ°¨ 연속 μš΄μ „ 데이터λ₯Ό μ΄μš©ν•΄ μ‘ΈμŒμ‰Όν„° 배치의 효과λ₯Ό μ •λŸ‰μ μœΌλ‘œ λΆ„μ„ν•œ 연ꡬ κ΄€λ ¨ λ§΅λ§€μΉ­ μ½”λ“œμž…λ‹ˆλ‹€. λ³Έ λ ˆν¬μ§€ν† λ¦¬λŠ” λŒ€κ·œλͺ¨ GPS ꢀ적 데이터λ₯Ό ν‘œμ€€ λ…Έλ“œ-링크 체계에 μ •ν•©ν•˜λŠ” 싀무 μ§€ν–₯적 λ§΅λ§€μΉ­(Map-Matching) νŒŒμ΄ν”„λΌμΈμ„ κ΅¬ν˜„ν•œ ν”„λ‘œμ νŠΈμž…λ‹ˆλ‹€. 곡곡 MaaS, DRT(μˆ˜μš”μ‘λ‹΅ν˜• ꡐ톡), ꡐ톡 뢄석 ν”Œλž«νΌμ— 적용 κ°€λŠ₯ν•œ ν™•μž₯ν˜• 곡간 데이터 처리 ꡬ쑰λ₯Ό λͺ©ν‘œλ‘œ μ„€κ³„λ˜μ—ˆμŠ΅λ‹ˆλ‹€. This repository contains a data-processing and map-matching pipeline for evaluating rest-area effectiveness using truck continuous-driving records.

πŸš€ 60초 μ•ˆμ— 확인할 수 μžˆλŠ” 핡심 μ—­λŸ‰

  • λŒ€κ·œλͺ¨ ꢀ적 데이터 처리 νŒŒμ΄ν”„λΌμΈ 섀계
  • 곡간 인덱싱 기반 μ„±λŠ₯ μ΅œμ ν™” ꡬ쑰
  • ꡐ톡곡학 μ œμ•½ 쑰건을 λ°˜μ˜ν•œ λ§€μΉ­ μ•Œκ³ λ¦¬μ¦˜
  • PostGIS 적용 κ°€λŠ₯ μ•„ν‚€ν…μ²˜

πŸ“Œ ν”„λ‘œμ νŠΈ λͺ©μ 

  • λͺ¨λΉŒλ¦¬ν‹° μ„œλΉ„μŠ€ 운영 μ΅œμ ν™” 지원
  • DRT λ°°μ°¨ 및 λ…Έμ„  뢄석 기반 ꡬ좕
  • 톡행 νŒ¨ν„΄(O/D) 뢄석을 ν†΅ν•œ μˆ˜μš” λ°€μ§‘ μ§€μ—­ λ„μΆœ
  • ꡐ톡 μ•ˆμ „ 및 μœ„ν—˜ ꡬ간 뢄석 기반 데이터 μ •ν•©

βš™οΈ μ£Όμš” κΈ°λŠ₯

1. GPS 데이터 μ „μ²˜λ¦¬

  • μ΄μƒμΉ˜ 제거
  • 속도/λ°©ν–₯ 기반 필터링
  • ꢀ적 μ •μ œ

2. 곡간 인덱싱 기반 λ§€μΉ­

  • R-tree λ˜λŠ” μœ μ‚¬ ꡬ쑰 ν™œμš©
  • 후보 링크 탐색 μ΅œμ ν™”

3. 링크 λ‹¨μœ„ λ§€μΉ­ 둜직

  • 거리 기반 후보 μ„ μ •
  • λ°©ν–₯μ„± 검증
  • 연속성 기반 보정

4. κ²°κ³Ό 검증 및 μ‹œκ°ν™”

  • O/D νŒ¨ν„΄ μΆ”μΆœ
  • QGIS 연계 좜λ ₯
  • 링크별 ν†΅ν–‰λŸ‰ 집계

πŸ— μ‹œμŠ€ν…œ 흐름

  1. μ›μ‹œ GPS 데이터 μž…λ ₯
  2. 데이터 μ •μ œ 및 μ „μ²˜λ¦¬
  3. 곡간 인덱슀 ꡬ좕
  4. 링크 λ§€μΉ­ μˆ˜ν–‰
  5. 검증 및 κ²°κ³Ό 좜λ ₯

πŸ“Š 싀무 ν™œμš© κ°€λŠ₯μ„±

λ³Έ ν”„λ‘œμ νŠΈλŠ” λ‹€μŒ μ—­λŸ‰μ„ 증λͺ…ν•©λ‹ˆλ‹€:

  • λŒ€κ·œλͺ¨ λͺ¨λΉŒλ¦¬ν‹° 데이터 처리 λŠ₯λ ₯
  • μž¬ν˜„ κ°€λŠ₯ν•œ 곡간 데이터 νŒŒμ΄ν”„λΌμΈ 섀계
  • ꡐ톡곡학 기반 μ•Œκ³ λ¦¬μ¦˜ 섀계 λŠ₯λ ₯
  • MaaS 및 DRT 운영 μ˜μ‚¬κ²°μ • 지원 κ°€λŠ₯μ„±

🎯 ν”„λ‘œμ νŠΈ κ°œμš” / Project Overview

연ꡬ λ°°κ²½ / Research Background

μ‘ΈμŒμ‰Όν„°μ˜ λ°°μΉ˜μ™€ μ΄μš©μ„±μ΄ 연속 μš΄μ „μ‹œκ°„ 초과λ₯Ό μ€„μ΄λŠ” 데 λ―ΈμΉ˜λŠ” 효과λ₯Ό DTG(기둝계) 데이터λ₯Ό 기반으둜 ν‰κ°€ν•©λ‹ˆλ‹€. This project evaluates whether rest-area infrastructure and placement can reduce long continuous driving time using truck DTG (digital tachograph) data.

뢄석 λ²”μœ„ / Study Scope

  • λŒ€μƒ λ„λ‘œλ§: 전라뢁도 μΌλ°˜κ΅­λ„ ν‘œμ€€λ§ν¬
  • Analysis area: Road links of national highways in Jeollabuk-do.
  • κΈ°κ°„: 2025-03-01 ~ 2025-08-31 (6κ°œμ›”)
  • Period: 2025-03 to 2025-08 (6 months).
  • 데이터: μ°¨λŸ‰ID, GPS(X/Y), λ‚ μ§œΒ·μ‹œκ°„, μ°¨λŸ‰μ†μ„±(V_TYPE) λ“± DTG ν•„λ“œ
  • Data source: Truck DTG records containing vehicle id, GPS coordinates, date/time, and vehicle metadata.

πŸ”¬ 뢄석 절차 / Methodology

1) 데이터 μˆ˜μ§‘ 및 μ •μ œ / Data Ingestion and Cleaning

  • date, time, carid, V_TYPE, lon, lat(λ˜λŠ” GPSX, GPSY)λ₯Ό μ •κ·œν™”ν•©λ‹ˆλ‹€.
  • Standardize raw fields into normalized columns: date, time, carid, V_TYPE, lon, lat (or GPSX, GPSY).

2) 연속 μš΄μ „ ꡬ간 μΆ”μΆœ / Continuous-Driving Extraction

  • μ°¨λŸ‰λ³„λ‘œ 연속 μš΄μ „ μ‹œκ°„ ꡬ간을 μΆ”μΆœν•˜κ³ , μ—¬ν–‰(trip) λ‹¨μœ„λ‘œ λΆ„ν• ν•©λ‹ˆλ‹€.
  • Extract continuous-driving segments per vehicle and segment them into trips.
  • 동일 μ°¨λŸ‰(carid) κΈ°μ€€μœΌλ‘œ μ‹œκ°„Β·κ±°λ¦¬ κΈ°μ€€ EDA 및 trip 정합성을 μ κ²€ν•©λ‹ˆλ‹€.
  • Validate trip consistency by temporal sequence and distance consistency per vehicle.

3) λ„λ‘œ 링크 λ§€μΉ­ / Link Matching

  • 각 trip의 μƒ˜ν”Œμ λ“€μ—μ„œ λ„λ‘œ 링크 맀칭을 μˆ˜ν–‰ν•˜κ³ , 2.5μ‹œκ°„ μž„κ³„κ°’ κΈ°μ€€ ꡬ간을 λΆ„λ₯˜ν•©λ‹ˆλ‹€.
  • Match trip points to road network links and classify segments by continuous-driving duration thresholds.
  • 속도 쑰건(μ°¨λŸ‰ κΈ°μ€€ 20~250 km/h 필터링 λ“±)으둜 였차λ₯Ό μ •μ œν•©λ‹ˆλ‹€.
  • Filter outliers with speed rules (e.g., valid speed range for trucks).
  • !!To make it fast!!Refactored to a Class-based structure to encapsulate the Spatial Index (STRtree), reducing redundant index-building time and improving memory scope management.

4) 집계 및 μ‹œκ°ν™” / Aggregation and Visualization

  • κΈ΄ 연속 μš΄μ „(2h+, 2.5h+) λΉˆλ„, 링크 λ‹¨μœ„ κ΅ν†΅λŸ‰, VLM, λΉ„μœ¨ 등을 μ‚°μΆœν•©λ‹ˆλ‹€.
  • Compute long-duration metrics (>, 2h and >2.5h), link-level traffic, VLM, and ratio metrics.
  • μ „μ²˜λ¦¬ 결과와 μž„κ³„μΉ˜ κ²°κ³Όλ₯Ό 지도 기반 plot으둜 μ €μž₯ν•©λ‹ˆλ‹€.
  • Save map/line visualizations as image outputs for inspection.

핡심 톡계 / Key Statistics

  • 전체 μ΅œλŒ€ μ°¨λŸ‰ν†΅ν–‰λŸ‰: 413,661λŒ€/링크 (평균 24,513λŒ€)
  • Max vehicle count per link: 413,661 (average 24,513).
  • 2μ‹œκ°„ 초과 ꡬ간: μ΅œλŒ€ 29,586λŒ€(링크 ν†΅ν–‰λŸ‰μ˜ 59.7%), 평균 2,233λŒ€(11.5%)
  • Continuous driving >2h: max 29,586 trucks (59.7% of link traffic), avg 2,233 trucks (11.5%).
  • 2.5μ‹œκ°„ 초과 ꡬ간: μ΅œλŒ€ 11,691λŒ€(링크 ν†΅ν–‰λŸ‰μ˜ 53.5%), 평균 1,100λŒ€(7.16%)
  • Continuous driving >2.5h: max 11,691 trucks (53.5%), avg 1,100 trucks (7.16%).

πŸ—ΊοΈ 뢄석 κ²°κ³Ό μ˜ˆμ‹œ / Result Snapshots

μ•„λž˜ μ΄λ―Έμ§€λŠ” 데이터 ꡬ성, μƒ˜ν”Œλ§ ꡬ간, λ§€μΉ­Β·μ‹œκ°ν™” 결과의 쀑간 점검 μ‚°μΆœλ¬Όμž…λ‹ˆλ‹€. The figures below show intermediate data validation, sampled trajectory windows, and map matching outputs.

Step 1: DTG Data Snapshot Step 2: Link Matching with Candidate Points Step 3: Sample Trajectory Plot Step 4: Filtered Link-level Heatmap

πŸ“ 디렉터리 ꡬ쑰 / Directory Structure

MapmatchingTrajectorytoLinks/
β”œβ”€β”€ processingDTGJB.py
β”œβ”€β”€ processingDTGJB2.py
β”œβ”€β”€ untitled1.py
β”œβ”€β”€ untitled2.py
β”œβ”€β”€ q3.py
β”œβ”€β”€ q4.py
β”œβ”€β”€ plot5.py
β”œβ”€β”€ plot6.py
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ cli.py
β”‚   β”œβ”€β”€ run_dtg_pipeline.py
β”‚   β”œβ”€β”€ run_dtg_pipeline_alt.py
β”‚   β”œβ”€β”€ run_q3.py
β”‚   β”œβ”€β”€ run_q4.py
β”‚   β”œβ”€β”€ plot_dtg_links.py
β”‚   β”œβ”€β”€ plot_dtg_links_alt.py
β”œβ”€β”€ JBROI.*
β”œβ”€β”€ JBROI2.*
β”œβ”€β”€ roi_box.gpkg
β”œβ”€β”€ bfg-1.15.0.jar
β”œβ”€β”€ data/
└── tools/

🧩 νŒŒμΌλ³„ μ—­ν•  / File Roles

처리 λͺ¨λ“ˆ / Processing Modules

  • processingDTGJB.py β€” 핡심 μ „μ²˜λ¦¬ μœ ν‹Έλ¦¬ν‹° / Core processing utilities.
  • processingDTGJB2.py β€” processingDTGJB.py의 보완/λŒ€μ²΄ λͺ¨λ“ˆ / Companion/alternative variant.
  • untitled2.py β€” DTG νŒŒμ΄ν”„λΌμΈ κΈ°λ³Έ μ‹€ν–‰κΈ° / Primary DTG pipeline entry.
  • untitled1.py β€” DTG νŒŒμ΄ν”„λΌμΈ 보쑰/λ³€ν˜• μ‹€ν–‰κΈ° / Secondary/alternate DTG pipeline entry.
  • q3.py β€” 집계/μ •μ±… μ§€ν‘œ μ‚°μΆœκΈ° / Aggregation and post-processing script.
  • q4.py β€” 집계 ν™•μž₯ μ‹€ν—˜ 슀크립트 / Extended aggregation/analysis script.
  • plot5.py β€” 지도 기반 μ‹œκ°ν™”(1) / Map visualization routine #1.
  • plot6.py β€” 지도 기반 μ‹œκ°ν™”(2) / Map visualization routine #2.
  • JBROI*, JBROI2*, roi_box.gpkg β€” 뢄석 μ˜μ—­(ROI) μ •μ˜ 파일 / ROI geometry inputs.
  • bfg-1.15.0.jar β€” Git νžˆμŠ€ν† λ¦¬ 정리/이λ ₯ 정리 보쑰 도ꡬ / Git history maintenance helper.

scripts/ μ§„μž…μ  / Script Entry Points

  • scripts/cli.py β€” 톡합 μ‹€ν–‰ μΈν„°νŽ˜μ΄μŠ€ / Unified CLI dispatcher.
  • run_dtg_pipeline.py β€” untitled2.py 래퍼 / Wrapper to untitled2.py.
  • run_dtg_pipeline_alt.py β€” untitled1.py 래퍼 / Wrapper to untitled1.py.
  • run_q3.py β€” q3.py 래퍼 / Wrapper to q3.py.
  • run_q4.py β€” q4.py 래퍼 / Wrapper to q4.py.
  • plot_dtg_links.py β€” plot5.py 래퍼 / Wrapper to plot5.py.
  • plot_dtg_links_alt.py β€” plot6.py 래퍼 / Wrapper to plot6.py.

▢️ μ‹€ν–‰ 방법 / Run Instructions

ꢌμž₯ μ‹€ν–‰ 방식 / Recommended

  • python scripts/cli.py pipeline
  • python scripts/cli.py pipeline-alt
  • python scripts/cli.py q3
  • python scripts/cli.py q4
  • python scripts/cli.py plot
  • python scripts/cli.py plot-alt

직접 μ‹€ν–‰ / Direct Mode

  • python untitled2.py
  • python untitled1.py
  • python q3.py
  • python q4.py
  • python plot5.py
  • python plot6.py

βš™οΈ μ‹€ν–‰ ν™˜κ²½ / Setup

  1. pip install -r requirements.txt
  2. ν™˜κ²½λ³„ 데이터 경둜(/data1/... λ“±)와 DB μ—°κ²° 섀정을 μ‹€μ œ 경둜둜 μˆ˜μ •
  3. λŒ€μš©λŸ‰ 데이터 νŒŒμΌμ€ Git μΆ”μ μ—μ„œ μ œμ™Έν•˜κ³  μ‹€ν–‰ μ‹œ 경둜만 맞좀

πŸ“· 이미지 경둜 점검 / Image Path Check

이미지 μ°Έμ‘°λŠ” λͺ¨λ‘ μƒλŒ€ 경둜이며, 같은 폴더 λ‚΄ 파일이 μ‘΄μž¬ν•˜λ©΄ GitHub λ Œλ”λ§ μ‹œ 문제 μ—†μŠ΅λ‹ˆλ‹€. All image references are relative; if the files exist in the repository root, they render correctly on GitHub.

πŸ“Š κ²°κ³Ό ν‘œ (μš”μ•½) / Summary Table

final_merged_gdf2μ‹œκ°„μ΄μƒ_λ°©ν–₯μΆ”κ°€251212.xlsx의 sheet1 μƒμœ„ κ²°κ³Όλ₯Ό geometryλŠ” μ‹œμž‘/μ’…λ£Œ μ’Œν‘œλ§Œ μΆ•μ•½ν•΄ ν‘œμ‹œν•©λ‹ˆλ‹€. Shown below is a summary from final_merged_gdf2μ‹œκ°„μ΄μƒ_λ°©ν–₯μΆ”κ°€251212.xlsx sheet1; geometry is shortened to start/end only.

index LINK_ID geometry vehicle_count 2μ‹œκ°„ 이상 μ—°μ†μ£Όν–‰μ°¨λŸ‰(λŒ€μˆ˜) vehicle_count κΈ°μ€€ μˆœμœ„ VLM κ΅ν†΅λŸ‰ ratio 2μ‹œκ°„ 이상 μ—°μ†μ£Όν–‰μ°¨λŸ‰ λΉ„μœ¨ direction μ£Όν–‰λ°©ν–₯
1484 3070020302 LINESTRING (297841.96527919295 3980043.9288296015, 298782.834076233 3979939.0186604057) 29551 1 242292 12.20% 동
480 3070019300 LINESTRING (294118.9405783998 3980121.988229847, 296611.921601332 3980047.724757389) 29185 2 238253 12.25% 동
1365 3110050400 LINESTRING (310858.1111337207 3972940.4928400507, 311296.56675443635 3973201.4749663696) 29110 3 268341 10.85% 동
1939 3070020402 LINESTRING (298787.34749683784 3979950.1366384136, 297842.3620516729 3980055.924890448) 29096 4 274155 10.61% μ„œ
1028 3070008801 LINESTRING (306191.9178838817 3977570.2769408426, 303503.7619772779 3979011.2397499904) 28358 5 316221 8.97% μ„œ
2969 3070022800 LINESTRING (297586.40745840943 3980116.226023371, 297225.1758749983 3980172.602097907) 28303 6 265631 10.66% μ„œ
475 3070243400 LINESTRING (296611.921601332 3980047.724757389, 296918.199608747 3980103.997398246) 28266 7 226935 12.46% 동
1562 3070022700 LINESTRING (297226.72092121094 3980160.699836365, 297582.9809467876 3980104.722794104) 28257 8 229146 12.33% 동
364 3070020301 LINESTRING (297582.9809467876 3980104.722794104, 297841.96527919295 3980043.9288296015) 28254 9 228483 12.37% 동
3173 3070014700 LINESTRING (299237.5559036793 3979776.7882304047, 299438.2845675852 3979723.68819917) 27702 10 223410 12.40% 동

🧾 정리 ν•­λͺ© / Cleanup Status

  • project_paths.pyλ₯Ό 톡해 data/ μš°μ„  탐색을 μ μš©ν–ˆμŠ΅λ‹ˆλ‹€.
  • scripts/와 루트 μ‹€ν–‰ 슀크립트의 역할을 뢄리해 μœ μ§€λ³΄μˆ˜μ„±μ„ λ†’μ˜€μŠ΅λ‹ˆλ‹€.
  • argparse 기반 μ˜΅μ…˜ 정리λ₯Ό 톡해 μ‹€ν–‰ λͺ…λ Ήμ˜ 일관성을 ν™•λ³΄ν–ˆμŠ΅λ‹ˆλ‹€.
  • Large-data assets should remain under data/ or tools/ and be excluded from Git history when possible.

πŸ™ Acknowledgement

This work was supported by the Korea Transportation Safety government agency under the Ministry of Land, Infrastructure and Transport of the Republic of Korea.