We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey, I'm trying to make a data visualization with a dataset about central power stations, that I put here, but when I try to visualize there are few power station "ball". When I try to understand the problem with Println(longitude), it tells me "map(NaN, -180, 180, 0, 1000) called, which returns NaN (not a number)". I think that the code is right, and I don't understand the problem with the .csv. Thank You!
https://docs.google.com/spreadsheets/d/1B6ezcmjntEI-nI6_miO6UQaOU78ZXnDep-qtyVUWmJ4/edit?usp=sharing
PImage mappa;
Table dati;
void setup(){
size(1000, 500);
mappa= loadImage("world.png");
dati= loadTable("energydata.csv", "header");
}
void draw(){
image(mappa, 0, 0, width, height);
for( int riga=0; riga < dati.getRowCount(); riga++){
float lat= dati.getFloat(riga,0);
float lon= dati.getFloat(riga,1);
/*String nome = dati.getString(riga,2);
String stato = dati.getString(riga,3);
float potenza= dati.getFloat(riga,4);
String tipo= dati.getString(riga,5);
float la=map(lat, 90, -90, 0, height);
float lo=map(lon, -180,180,0,width);
println(lon);
fill(#4AF2A1,80);
noStroke();
ellipse(lo,la,10,10);
noLoop(); }}
Answers
Maybe try this: http://stackoverflow.com/questions/1456566/how-do-you-test-to-see-if-a-double-is-equal-to-nan
Kf
Is it breaking early or partway through the data?
Can you add some debug to show which line is being processed?
My suspicion is that it's trying to parse the headers as numbers.
Move line 25 before the map. Add a line to print riga.
Check this recent post where they show how to manage a nan field: https://forum.processing.org/two/discussion/comment/97437/#Comment_97437
Kf