usgs地震记录如何下载
One of the many services provided by the US Geological Survey (USGS) is the monitoring and tracking of seismological events worldwide. I recently stumbled upon their earthquake datasets provided at the website below.
美国地质调查局(USGS)提供的众多服务之一是对全球地震事件的监视和跟踪。 我最近偶然发现了下面网站提供的地震数据集。
The site has data feeds that contain ‘live’ csv data for every significant earthquake over the past hour, day, week, or month. The data is updated every minute and contains magnitudes, lat/long, depth, and other earthquake descriptors.
该站点的数据源包含过去一小时,一天,一周或一个月中每次重大地震的“实时” csv数据。 数据每分钟更新一次,其中包含震级,纬度/经度,深度和其他地震描述符。
While there are lots of earthquake visualizations out there, I thought it would be a fun exercise to see what could be easily created in Folium from the raw data. For this project, we will be plotting every earthquake worldwide using just Pandas and Folium. We will also add some tectonic plate boundaries with geoJSON just for fun.
尽管那里有很多地震可视化内容,但我认为从原始数据中轻松地在Folium中创建什么内容将是一个有趣的练习。 对于此项目,我们将仅使用熊猫和大叶子绘制全球每次地震的图。 我们还将通过geoJSON添加一些构造板块边界,只是为了好玩。
导入我们的数据 (Importing Our Data)
I will be using the data feed located at the following URL.
我将使用位于以下URL的数据提要。
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.csv
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.csv
That is the direct link to a csv formatted file containing every earthquake greater than magnitude 2.5, worldwide, over the last month. I encourage you to try out the other data feeds, but I found that the size of the dataset really balloons when you include smaller quakes.
这是指向csv格式文件的直接链接,该文件包含最近一个月在世界范围内发生的每一次大于2.5级的地震。 我鼓励您尝试其他数据馈送,但是我发现当包含较小的地震时,数据集的大小实际上会膨胀。
In the code below, we import our libraries, and use the pandas.read_csv() function to create a DataFrame object directly from the URL.
在下面的代码中,我们导入我们的库,并使用pandas.read_csv()函数直接从URL创建一个DataFrame对象。
The data column descriptions are well documented on the USGS website. The relevant columns for our project will be: latitude, longitude, and mag (magnitude of the quake). All are stored as float objects and there is no preprocessing necessary. Thank you USGS for keeping these datasets clean and user friendly.
数据列的说明在USGS网站上有详细记录。 为我们的项目相关列将是:纬度,经度和MAG(地震的大小)。 所有这些都存储为浮点对象,并且不需要任何预处理。 感谢USGS保持这些数据集干净和用户友好。
在Folium中制作底图 (Making a Base Map in Folium)
We will start by making a simple map in Folium using the code below.
我们将使用下面的代码在Folium中制作一个简单的地图开始。
We chose a lat/long of (0, 0) since we are plotting the whole world. A zoom value of 2 worked well for me to see the entire Earth in openstreetmap. My resulting earthquakes.html file looked like this.
由于绘制整个世界,因此我们选择了纬度/经度(0,0) 。 缩放值为2可以很好地使我在openstreetmap中看到整个地球。 我生成的地震.html文件看起来像这样。
使用Folium Circles添加地震数据 (Adding Earthquake Data using Folium Circles)
Now that we have a working base map, let’s plot our earthquakes. We will use Folium’s Circle object to represent each quake. To start, we will just make all the earthquakes the same size.
现在我们有了工作底图,让我们绘制地震图。 我们将使用Folium的Circle对象来表示每个地震。 首先,我们将使所有地震大小相同。
In the code above, we iterated through each earthquake in the DataFrame, created a Circle object at that location, and added it to my map using the add_to() method. We end up with an already impressive map showing all of the significant earthquakes over the past month. The data is constantly changing, so your attempt might look different.
在上面的代码中,我们遍历了DataFrame中的每次地震,在该位置创建了一个Circle对象,然后使用add_to()方法将其添加到我的地图中。 最后,我们得到了一张已经令人印象深刻的地图,显示了过去一个月中所有的重大地震。 数据在不断变化,因此您的尝试可能看起来有所不同。
可视化地震幅度 (Visualizing Earthquake Magnitudes)
To give us a quick visual representation of the magnitudes, I chose to alter the size of each circle based on the size of the quake. (alternately, you could experiment with colormaps or heatmaps)
为了让我们快速直观地看到震级,我选择根据地震的大小来改变每个圆的大小。 (或者,您可以尝试使用颜色图或热图)
For the last map, I used a radius of 10 for every Circle and we saw each earthquake represented by a blue dot. The Circle object’s radius is displayed in meters on your map, so each Circle marker shows up as a 10m ring when you zoom all the way in on your interactive map.
对于最后一张地图,我为每个圆使用了10的半径,并且我们看到每个地震都由一个蓝点表示。 “圆”对象的半径以米为单位显示在地图上,因此当您在交互式地图上一直放大时,每个“圆”标记都显示为10m的圆环。
We will make the radius a function of the earthquake’s magnitude. Large magnitude quakes will be represented by large radius Circle markers.
我们将半径作为地震震级的函数。 大地震将由大半径圆形标记表示。
I chose to set my radius equal to 50,000 times the magnitude. A 4.0 earthquake would show on my map as having a radius of 200,000m or 200km. That value felt right for me, but you could certainly change it, especially if you were plotting regional data.
我选择将半径设置为等于半径50,000倍。 我的地图上会显示4.0级地震的半径为200,000m或200km。 该值对我来说很合适,但是您可以更改它,尤其是在绘制区域数据时。
Now we can clearly see the relative size of the plotted earthquakes, although we certainly have some work to do on the formatting.
现在我们可以清楚地看到绘制的地震的相对大小,尽管我们当然需要进行一些格式化工作。
使它漂亮 (Making it Pretty)
The map is now functional with minimal coding. We can now use the Circle object’s keyword arguments to make them more attractive.
该地图现在可以以最少的编码运行。 现在,我们可以使用Circle对象的关键字参数使它们更具吸引力。
This time, we specified five new keyword arguments (weight, color, opacity, fill_color, and fill_opacity) in our Circle objects. We now see multiple earthquakes on top of each other. In addition to the relative sizes to represent magnitude, the darker red now represents hot spots (multiple quakes), and gives it a heatmap effect.
这次,我们在Circle对象中指定了五个新的关键字参数(权重,颜色,不透明度,fill_color和fill_opacity)。 现在,我们可以看到多个地震相互叠加。 除了代表大小的相对大小外,深红色现在还代表热点(多次地震),并赋予其热图效果。
使用GeoJSON添加构造板块 (Adding Tectonic Plates Using GeoJSON)
When we look at the resulting map, we see a visualization of the Pacific rim’s ‘ring of fire’. I immediately had the thought of laying the actual tectonic plate boundaries as an overlay to my map.
当查看生成的地图时,我们看到了太平洋边缘的“火环”的可视化图像。 我立刻想到放置实际的构造板块边界作为我的地图的叠加层。
A quick google search led me to this file on github with the polygons for the tectonic boundaries stored in geoJSON format.
谷歌的快速搜索将我带到github上的该文件,其中以geoJSON格式存储了构造边界的多边形。
GeoJSON is my personal favorite filetype for shapes when using Python and Folium, but you could use other shape files as well. The geoJSON format has the advantage of working as a JSON file and can be treated like a dictionary in Python should you need to.
在使用Python和Folium时,GeoJSON是我个人最喜欢的形状文件类型,但是您也可以使用其他形状文件。 geoJSON格式的优点是可以作为JSON文件使用,如果需要,可以将其视为Python中的字典。
The code below shows how Folium can easily handle a GeoJson file to add a map overlay.
下面的代码显示Folium如何轻松处理GeoJson文件以添加地图叠加层。
The GeoJson object is added directly to the map we just created. Resaving the map gives the following result.
GeoJson对象直接添加到我们刚刚创建的地图中。 重新保存地图将得到以下结果。
The map results are exactly as you might expect. Earthquakes are neatly placed along the boundaries of our tectonic plates, just like they were in my middle school science textbook.
地图结果完全符合您的预期。 地震沿我们构造板块的边界整齐地放置,就像在我的中学科学教科书中一样。
走得更远 (Going Further)
Now that we have an attractive earthquake map, you may want to do some additional work to create something even more amazing.
现在我们有了一张引人入胜的地震图,您可能想要做一些额外的工作来创建更令人惊奇的东西。
Consider making a web application with controls for magnitude, time ranges, and locations. In the photo below, we see all of the earthquakes in San Francisco over the past seven days.
考虑制作一个具有幅度,时间范围和位置控件的Web应用程序。 在下面的照片中,我们看到了过去七天旧金山的所有地震。
Consider looking into the significant formatting options of the Folium Circle class. With the popup kwarg, you can insert html tags for every earthquake. You could then add the magnitude and description for every quake worldwide. The image below is an example of a popup that displays the string from the ‘place’ column
考虑研究Folium Circle类的重要格式化选项。 使用弹出式kwarg,您可以为每次地震插入html标签。 然后,您可以添加全球每个地震的震级和描述。 下图是显示“ place ”列中的字符串的弹出窗口的示例
See what you can create with these fantastic datasets. If you make something beautiful, let me know. Good luck!
看看您可以使用这些出色的数据集创建什么。 如果您做的很漂亮,请告诉我。 祝好运!
翻译自: https://levelup.gitconnected.com/plotting-usgs-earthquake-data-with-folium-8f11ddc21950
usgs地震记录如何下载
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388119.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!