Mapping GPS Locations to A 2D U.S. Map
in
Programming Questions
•
2 years ago
I've been working on this problem for a good while. I'm trying to map GPS locations to a 2D United States map. I have this code:
- int x;
- int y;
- PImage raster;
- void setup() {
- size(1000, 500);
- ellipseMode(CENTER);
- smooth();
- String[] lines = loadStrings("csvgpscombined2.txt");
- raster = loadImage("world_longlatwgs84.png");
- image(raster, 0, 0);
- for (int i = 0; i < lines.length; i++) {
- String[] pieces = split(lines[i], ",");
- if (pieces.length == 2) {
- float mapX = float(pieces[0]);
- float mapY = float(pieces[1]);
- println(mapX + " " + mapY);
- x = int(((180+mapY)/360)*width);
- y = int(height - ((90+mapX)/180)*height);
- ellipse(x, y, 10, 10);
- }
- }
- }
x = int(((180+mapY)/360)*width);
y = int(height - ((90+mapX)/180)*height);
I'm really running out of ideas though. I've tried many different things. If anyone has any solution to this problem, it would be wonderful.
1