计算机毕业设计Hadoop+Hive地震预测系统 地震数据分析可视化 地震爬虫 大数据毕业设计 Spark 机器学习 深度学习 Flink 大数据

2024  届本科毕业论文(设计)

 基于Hadoop的地震预测的

分析与可视化研究

姓    名:____田伟情_________

系    别:____信息技术学院___

专    业:数据科学与大数据技术

学    号:__2011103094________

指导教师:_____王双喜________

年   月   日

目 录

1 绪论

2  相关技术与工具

2.1  大数据技术概述

2.2  hadoop介绍

3 地震数据分析

3.1 数据收集与处理

3.2 特征提取与选择

4 地震数据可视化

4.1 可视化技术概述

4.2 可视化设计原则

4.3 可视化实现与评估

5 实验设计

5.1首先将数据上传到hdfs上面

5.2 Hive数仓表

5.3 Hive数据分析ads表

5.4 Spark数据分析

5.5 Sqoop实现Hive数据同步至Mysql

5.6 Echarts数据可视化

5.7 地震数据维护

6 结果讨论

6.1 结果总结

6.2 结果分析

6.3 存在问题

6.4 结果展望

参考文献

致 谢

基于Hadoop的地震预测的分析与可视化研究

田伟情    指导教师:王双喜

(商丘师范学院信息技术学院,河南商丘  476000)   

  

摘  要:08年四川5·12汶川地震、10年青海玉树地震、13年四川雅安地震,到23年甘肃积石山地震,大大小小的地震无数次的上演,带给我们的不仅是肉体上的疼痛,还有无法治愈的心灵创伤。在睡梦中因地震而惊醒,轰隆隆的地裂声还有那些肉眼可见的消失的村庄恐怕是无数遭遇地震的人的噩梦,也是所有人共同的悲哀。即使没有亲身经历过,但新闻报道中倒坍的房屋,埋头救人的官兵,隔着屏幕也能感受到疼痛。 因此,准确地预测地震的发生时间、地点和震级对于人们的生命安全和财产安全具有重要意义。然而,地震预测是一个复杂而困难的问题,受到多种因素的影响,如地质构造、地下水位变化、地壳运动等。传统的地震预测方法往往依赖于经验和专家判断,准确度和效率有限。随着大数据技术的快速发展,越来越多的地震数据被收集和存储起来。大数据分析和处理技术能够对这些海量的地震数据进行高效的分析和建模,为地震预测提供更准确的预测模型。然而,大数据在地震预测中的应用也面临着一些挑战。首先,地震数据具有高维度和复杂的特征,需要选择合适的特征参数进行分析和建模。其次,地震数据的规模庞大,传统的数据处理方法无法满足实时性要求。此外,地震数据的可视化也是一个重要问题,如何将海量的地震数据以直观的方式展示给用户,提高地震预测的可理解性和可操作性,也是一个需要解决的问题。 因此,本研究基于Hadoop的大数据技术,对地震数据进行分析和可视化,提高地震预测的准确性和效率。具体而言,本研究将使用Hadoop框架对地震数据进行分析和建模,利用线性回归预测算法构建地震预测模型。同时,本研究利用echarts的可视化技术和工具,将地震数据以直观的方式展示给用户,提高地震预测的可理解性和可操作性。

关键词:大数据、地震、地震预测、Hadoop、线性回归预测算法

Analysis and visualization of earthquake prediction based on Hadoop          

TIAN Weiqing      Supervisor: WANG Shuangxi

(College of Information Technology, Shangqiu Normal University, Shangqiu 476000, China)

Abstract :The 5.12 Wenchuan earthquake in Sichuan in 08, the Yushu earthquake in Qinghai in 10, the Ya'an earthquake in Sichuan in 13, and the Jishishan earthquake in Gansu in 23 years, earthquakes of all sizes have been staged countless times, bringing us not only physical pain, but also incurable psychological wounds. Waking up in your sleep by the earthquake, the rumbling sound of the ground cracking, and the visible disappearance of the villages are probably the nightmare of countless people who have been hit by the earthquake, and it is also the sorrow shared by everyone. Even if you haven't experienced it yourself, you can feel the pain through the screen of the collapsed houses in the news reports and the officers and soldiers who buried their heads in saving people. Therefore, it is of great significance to accurately predict the time, place and magnitude of earthquakes for the safety of people's lives and property. However, earthquake prediction is a complex and difficult problem that is affected by a variety of factors, such as geological structure, changes in groundwater level, crustal movements, etc. Traditional earthquake prediction methods often rely on experience and expert judgment, and their accuracy and efficiency are limited. With the rapid development of big data technology, more and more seismic data is collected and stored. Big data analysis and processing technology can efficiently analyze and model these massive seismic data, and provide more accurate prediction models for earthquake prediction. However, the application of big data in earthquake prediction also faces some challenges. First of all, seismic data has high-dimensional and complex features, and it is necessary to select appropriate feature parameters for analysis and modeling. Secondly, the scale of seismic data is huge, and traditional data processing methods cannot meet the real-time requirements. In addition, the visualization of seismic data is also an important problem, and how to display massive seismic data to users in an intuitive way and improve the comprehensibility and operability of earthquake prediction is also a problem that needs to be solved. Therefore, this study analyzes and visualizes earthquake data based on Hadoop's big data technology to improve the accuracy and efficiency of earthquake prediction. Specifically, this study will use the Hadoop framework to analyze and model seismic data, and use the linear regression prediction algorithm to construct an earthquake prediction model. At the same time, this study uses the visualization technology and tools of ECHARTS to present earthquake data to users in an intuitive way, so as to improve the comprehensibility and operability of earthquake prediction.

Key words:big data,earthquake, earthquake prediction、Hadoop、Linear regression prediction algorithm

1 绪论

    1. 研究背景

  关于地震的具体成因,纵观国内外研究,目前来说没有具体的共识,国内外学者关于地震的成因和预警进行了多方面的研究,将理论研究应用到具体实践,为探索地震发生的机制提供了宝贵的经验。而地震预警是应对当前地震灾害,减轻国家和人民生命和财产损失的有效方法。当前地震检测预警的方法主要有多指标数据预警法、震波强度预警法。但是关于地震预测仍存着困难,比如地震大小难测定,无法准确计算出地震的等级;震源位置难测定,震源的定位主要是通过计算地震波到达不同观测地点的时间,再根据地震波再介质中的传播速度来计算震源的具体位置,但是地球介质存在不匀质性,所以导致计算困难。

    1. 国内研究现状

关于当前国内关于地震的研究主要有以下几个方面。首先是不确定的地震具体成因但是关于诱发地震的人为原因,我国科学家也做出了具体的研究,比如注水、开采活动以及水库诱发等原因。自从08年经济快速发展以来,人们对地球的破坏越来越严重,从而导致地震发生的频率越来越高,有可能会导致从来不发生地震的地区变成地震频发地区。

关于地震学,现在也有了机器学习方法在其上面的具体应用,比如图像处理和影音处理,通过搭建卷积神经网络去识别震相和挑到时(下图为利用机器学习来识别汶川地震的震相和挑到时)。

核心算法代码分享如下:

import pymysql
from flask import Flask, request, jsonify
import json
from flask_mysqldb import MySQL

# 创建应用对象
app = Flask(__name__)
app.config['MYSQL_HOST'] = 'bigdata'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '123456'
app.config['MYSQL_DB'] = 'hive_earthquake'
mysql = MySQL(app)  # this is the instantiation


@app.route('/tables01')
def tables01():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table01''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['province','num']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables02')
def tables02():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table02 ORDER BY stime_year asc ''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['stime_year','num']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables03')
def tables03():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table03 order by avg_depth desc''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['data_type','avg_depth']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables04')
def tables04():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table04''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['data_type','max_magnitude']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route("/getmapcountryshowdata")
def getmapcountryshowdata():
    filepath = r"D:\\hadoop_spark_hive_mooc2024\\server\\data\\maps\\china.json"
    with open(filepath, "r", encoding='utf-8') as f:
        data = json.load(f)
        return json.dumps(data, ensure_ascii=False)


@app.route('/tables05')
def tables05():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table05''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['addr','num']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables06')
def tables06():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table06''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['addr','num']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables07')
def tables07():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table07''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['stime_month','num']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables08')
def tables08():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table08''')
    #row_headers = [x[0] for x in cur.description]  # this will extract row headers
    row_headers = ['name','num']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)

@app.route('/tables09')
def tables09():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM table09''')
    row_headers = [x[0] for x in cur.description]  # this will extract row headers
    #row_headers = ['car_name','score']  # this will extract row headers
    rv = cur.fetchall()
    json_data = []
    #print(json_data)
    for result in rv:
        json_data.append(dict(zip(row_headers, result)))
    return json.dumps(json_data, ensure_ascii=False)


@app.route('/data',methods=['GET'])
def data():
    limit = int(request.args['limit'])
    page = int(request.args['page'])
    page = (page-1)*limit
    conn = pymysql.connect(host='bigdata', user='root', password='123456', port=3306, db='hive_earthquake',
                           charset='utf8mb4')

    cursor = conn.cursor()
    if (len(request.args) == 2):
        cursor.execute("select count(*) from tb_earthquake");
        count = cursor.fetchall()
        cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
        cursor.execute("select * from tb_earthquake limit "+str(page)+","+str(limit));
        data_dict = []
        result = cursor.fetchall()
        for field in result:
            data_dict.append(field)
    else:
        data_type = str(request.args['data_type'])
        stime_long = str(request.args['stime_long']).lower()
        if(data_type=='不限'):
            cursor.execute("select count(*) from tb_earthquake where stime_long like '%"+stime_long+"%'");
            count = cursor.fetchall()
            cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
            cursor.execute("select * from tb_earthquake where stime_long like '%"+stime_long+"%' limit " + str(page) + "," + str(limit));
            data_dict = []
            result = cursor.fetchall()
            for field in result:
                data_dict.append(field)
        else:
            cursor.execute("select count(*) from tb_earthquake where stime_long like '%"+stime_long+"%' and data_type = '"+data_type+"'");
            count = cursor.fetchall()
            cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
            cursor.execute("select * from tb_earthquake where stime_long like '%"+stime_long+"%' and data_type = '"+data_type+"' limit " + str(page) + "," + str(limit));
            data_dict = []
            result = cursor.fetchall()
            for field in result:
                data_dict.append(field)
    table_result = {"code": 0, "msg": None, "count": count[0], "data": data_dict}
    cursor.close()
    conn.close()
    return jsonify(table_result)

if __name__ == "__main__":
    app.run(debug=False)

  • 24
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

B站计算机毕业设计大厂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值