Trying to rescale earthquake magnitudes from Richter scale to points^2 using geoscatter so they appear proportional

3 views (last 30 days)
I am importing different csv files, using readmatrix(), from the USGS website that includes the latitude, longitude, and magnitude of earthquakes during a certain time period. I am uing the geoscatter command which can take vectors for lat, lon and marker size (and color scale) but the problem is that the marker size is a value with points^2 units. Magnitude is given on the richter scale (0-9 or so) which is logarithmic, so as shown in the code, I tried to convert the values back by taking the square root of 10 raised to the magnitude and rescaling but it's still not great. I dont want to have to use the rescale as a quick-fix. Im just not sure what I'm doing wrong, any help would be greatly appreciated! Also, if any one is familiar with geoscatter I would also like to explore the idea of the user being able to limit the view to only one continent or country, as well as possibly creating a time lapse of the earthquakes because the time data is included in the csv. Here is the website with the data I'm using: https://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php Here is the code I have so far: (I am using a live script and have utilized a drop down box to switch between time frames, so only the data for the past month is used to simply the helping process)
clc
clear all
close all
data = readmatrix("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv") % Pulls .csv for selected time from USGS website
data = 9929×22
NaN 62.2203 -149.9676 22.4000 1.4000 NaN NaN NaN NaN 0.5000 NaN NaN NaN NaN NaN NaN 0.3000 NaN NaN NaN NaN NaN NaN 38.4967 -122.1252 -0.4900 2.4600 NaN 8.0000 230.0000 0.5687 0.2200 NaN NaN NaN NaN NaN 4.2900 3.2900 NaN 1.0000 NaN NaN NaN NaN 19.2000 -155.4953 31.7100 2.5300 NaN 46.0000 73.0000 NaN 0.1200 NaN NaN NaN NaN NaN 0.5200 0.8200 3.8000 26.0000 NaN NaN NaN NaN 63.3242 -151.2613 8.1000 2.8000 NaN NaN NaN NaN 0.4300 NaN NaN NaN NaN NaN NaN 0.2000 NaN NaN NaN NaN NaN NaN 34.5032 -118.8275 9.7000 1.6500 NaN 36.0000 92.0000 0.0775 0.2700 NaN NaN NaN NaN NaN 0.3900 0.9000 0.1930 28.0000 NaN NaN NaN NaN 60.5260 -151.6682 65.2000 1.7000 NaN NaN NaN NaN 0.5000 NaN NaN NaN NaN NaN NaN 1.8000 NaN NaN NaN NaN NaN NaN 44.7785 -110.8063 2.5500 0.5400 NaN 7.0000 197.0000 0.0330 0.1000 NaN NaN NaN NaN NaN 0.6400 1.7600 0.3410 6.0000 NaN NaN NaN NaN 19.2663 -155.3980 33.3500 2.1400 NaN 32.0000 210.0000 NaN 0.1100 NaN NaN NaN NaN NaN 0.6400 0.7800 0.2800 4.0000 NaN NaN NaN NaN 17.9573 -67.0755 6.4400 2.3400 NaN 20.0000 225.0000 0.0321 0.1400 NaN NaN NaN NaN NaN 0.4700 0.2700 0.1843 10.0000 NaN NaN NaN NaN 55.5236 162.5373 37.8390 5.1000 NaN 113.0000 80.0000 3.3870 0.8200 NaN NaN NaN NaN NaN 8.6500 5.7450 0.0270 431.0000 NaN NaN NaN
lat = data(:,2);
lon = data(:,3);
mag = sqrt(10.^(abs(data(:,5))));
mag = rescale(mag,0,180);
C = cosd(1:length(lat));
for i = 1:length(mag) % Converts all zeros to nonzeros
if mag(i) == 0
mag(i) = 1;
end
end
A = geoscatter(lat,lon,mag,C,'filled');
geobasemap grayland;

Answers (1)

Pratyush Swain
Pratyush Swain on 10 Sep 2023
Hey Matthew ,
I understand you want a better method to map the richter scale values.Since rescale maps the values linearly, I would suggest to use ‘interp1' function instead.
Please find an example implementation of ‘interp1’ function on the same dataset as follows:
data = readmatrix("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv");%Loading Data
num_mags = 1:max(data(:,5));% taking maximum range
power_num_mag = sqrt(10.^num_mags); % creating output values which will be used for mapping reference
mags= abs(data(:,5)); % the data which we will be interpolating
interpolated_mags= interp1(num_mags,power_num_mag,mags); %Using 1-D data interpolation to map the values
The interp1 function will map the magnitude values better. Please refer to this documentation https://in.mathworks.com/help/matlab/ref/interp1.html
Hope this helps.

Categories

Find more on Seismology in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!