Blockdit Logo
Blockdit Logo (Mobile)
สำรวจ
ลงทุน
คำถาม
เข้าสู่ระบบ
มีบัญชีอยู่แล้ว?
เข้าสู่ระบบ
หรือ
ลงทะเบียน
Inspired by data
•
ติดตาม
30 ธ.ค. 2022 เวลา 10:43 • ยานยนต์
จุดเสี่ยง !!! อุบัติเหตุจราจรใน กทม. (ข้อมูล 23 มีนาคม 2564)
วันหยุด หาจุดเสี่ยงอุบัติเหตุใน กทม. จากข้อมูลเปิด
https://opendata.data.go.th/dataset/riskzone
(ข้อมูล 23 มีนาคม 2564)
ใช้ python ดึงข้อมูลแล้วนำมา plot ใน map เลยครับ
import requests
import json
import pandas as pd
url = "
https://opend.data.go.th/get-ckan/datastore_search?resource_id=6cc7a43f-52b3-4381-9a8f-2b8a35c3174a
"
payload={}
headers = {
'api-key': 'ํYOUR-API-KEY'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
# Load the JSON object
data = json.loads(response.text)
# Extract the records from the JSON object
records = data['result']['records']
# Create a list to store the latitude and longitude values
coordinates = []
# Loop over the records
for record in records:
# Extract the latitude and longitude values
lat, lon = map(float, record['พิกัด'].split(','))
# Append the values to the list
coordinates.append((lat, lon))
# Create a DataFrame from the list of coordinates
df = pd.DataFrame(coordinates, columns=['latitude', 'longitude'])
df
แสงในแผนที่ด้วย folium
import folium
# Create a Map instance
m = folium.Map(location=None, zoom_start=13)
# Loop over the rows in the DataFrame
for index, row in df.iterrows():
# Add a marker for the row
folium.Marker([row['latitude'], row['longitude']]).add_to(m)
# Display the map
m
พื้นที่ สน.ไหนเหตุเยอะสุด?
บางขุนเทียน 12 เหตุ
ราษฎร์บูรณะ 9 เหตุ
ปัจจุบันคงเปลี่ยนไปแล้ว แต่ยังไม่มี data update
บันทึก
โฆษณา
ดาวน์โหลดแอปพลิเคชัน
© 2025 Blockdit
เกี่ยวกับ
ช่วยเหลือ
คำถามที่พบบ่อย
นโยบายการโฆษณาและบูสต์โพสต์
นโยบายความเป็นส่วนตัว
แนวทางการใช้แบรนด์ Blockdit
Blockdit เพื่อธุรกิจ
ไทย