Trying to rescale earthquake magnitudes from Richter scale to points^2 using geoscatter so they appear proportional
3 views (last 30 days)
Show older comments
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
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;
0 Comments
Answers (1)
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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!