Hey, I’m still pretty new to processing so I doubt this a very complicated issue.
I’m trying to visualise a data set of earthquakes around the world, but I’m struggling to make the markers increase in size based on the magnitude.
I am trying to create different categories of size for my marketsize based on the magnitudes 6,7,8 and 9 for earthquakes. the myData[i][4] is referencing the magnitude from a CSV file I am using.
Here is the code I’m working with:
//LIBRARIES
import processing.pdf.*;
//GLOBAL VARIABLES
PShape baseMap;
String csv[];
String myData[][];
PFont f;
//SETUP
void setup() {
size(1800, 900);
noLoop();
f = createFont("Avenir-Medium", 12);
baseMap = loadShape("WorldMap.svg");
csv = loadStrings("Earthquake.csv");
myData = new String[csv.length][7];
for(int i=0; i<csv.length; i++) {
myData[i] = csv[i].split(",");
}
}
//DRAW
void draw() {
//beginRecord(PDF, "Earthquakes.pdf");
shape(baseMap,0, 0, width, height);
noStroke();
for(int i =0; i<myData.length; i++){
fill(255,0,0, 20);
textMode(MODEL);
noStroke();
float graphLong = map(float(myData[i][2]), -180, 180, 0, width);
float graphLat = map(float(myData[i][1]), 90, -90, 0, height);
float markerSize = float(myData[i][4]);
ellipse(graphLong,graphLat,markerSize,markerSize);
println(myData[i][4]);
println(graphLong + " / " + graphLat);
}
//endRecord();
//println("PDF saved!");
}