View Full Version : How Do I: Convert a list of Lat/Long|X/Y coordinates into points in an image?
07-27-2011, 03:35 PM
If I have an Excel list of lat/long coordinates (which I can easily convert into X/Y image coordinates), what is a good way of placing points or drawing lines in an image using those coordinates? Obviously, I can do it manually, but I'm trying to construct a new process, and manual doesn't work for that.
I am not sure what programs might be best to use, probably something that has a scripting language. I can convert coords into script commands pretty easily. Then I would just run the script and it would draw the stuff onto the image, which I could bring into Photoshop or Fractal Terrains as an overlay.
I'd use imagemagick and the scripting language of your choice
07-27-2011, 10:14 PM
Those links look very good. Now all I need to do is remember all my basic geometry. Seems having a degree in the stuff doesn't do any good if you never use it. ;)
Repped. Thx for the assist!
07-28-2011, 01:14 AM
If your data is already in Excel, have you considered just drawing an XY scatter plot in Excel itself?... It also has a built-in scripting language, that lets you create the chart and save the image.
07-28-2011, 01:48 AM
I had thought of that briefly, but didn't know I could export it to an image and still be precise with the coords. I can generally make Excel jump through hoops, so that's a good option if possible. I'll look into that further, thanks.
07-28-2011, 06:34 AM
The community members location map is done exactly like this and I did that in ImageMagick. If you have a world map in a mercatory style such that its stretched to linearize the lat/long coords or a local map small enough such that the lat/long range is approximately linear then all you need is the bounds in lat long coords of the map and the image pixel size and then you just use the ratios to go from one coordinate system to the other. If the map is in some other projection and is large enough such that increasing the lat/longs produce curved point sets then you need to do some math. It can get a bit tricky then but libraries such as GDAL can do that calculation for you.
If you have the X/Y points and you just need to plot them well, image magick does make that very easy indeed. I would suggest using a scripting language with it to make it faster such as Perl where you can get PerlMagick which is the interface of image magick with it. Then its just a loop and a few calls to get it to plot it out. There are other interfaces too such as Python etc as well. Your kinda spoiled for choice with IM.
07-30-2011, 07:45 AM
I'd probably write a little program to generate SVG or WKT, which are both fairly straightforward structured text formats. SVG is more readily converted to graphics, but WKT can be fed into GIS tools.
08-06-2011, 04:03 PM
Here are the results in an Excel graph plot. I wrote a VBA routine to try and build believable random tectonic plate boundaries. It's very slow to run, a couple of hours, but then this laptop is not necessarily the world's most powerful computer. There are ways I can speed it up, and I still want to add directional and speed arrows for each of the plates, so it's not quite finished yet.
This would have been a helluva lot easier if I knew spherical trigonometry. I assume I covered it during getting that BS in Math, but I've never used it since and didn't remember any of it. Fortunately I was able to eventually find everything I needed online once I figured out what terms to search for. If anyone else wants to delve into the topic, I suggest looking for an aviation navigation page - all the formulas you could ever want are listed out right there, already put into a form perfect for doing calculations based on a planetary surface. I've actually had the general process in mind for a month or more, but didn't know how to implement it until I started finding the right equations.
Any critiques or suggestions from the geologically-knowledgeable crowd out there?
08-07-2011, 12:49 AM
Here's another one, with the centerpoints added, and a slightly faster algorithm for the edges (a bit over 3 hrs), although that apparently comes with the drawback of the edges having a lot more smooth curves to it.
And I should probably mention that I know the centerpoints aren't at the center of the final plates. :) They're at the center of the source of each plate, and that the plates build out from those spots to fill the available space.
08-07-2011, 09:09 AM
Would you like to explain what it is that your doing to get these diagrams. I dont see the connect between the lat long points to this diagram. I can see that they are supposed to be tectonic plates but I dont understand where the edges are derived from or why its taking 3 hrs to calculate or plot them. What are these calculations referring to ?
08-07-2011, 09:35 AM
Oh, it's probably a very inefficient method, but it's one I came up with myself, and I couldn't find any others out there to steal. ;) Each plate starts with 2 overlapping circles (the centerpoints shown above are the midpoint between these circles). The circles may or may not be the same size. Every place 2 circles intersect, a new potential circle is defined and added to a pick list. The program picks a circle at random from the pick list and, if it is not within an existing circle, creates it and adds new circles to the pick list based on all of it's intersections. If the new circle intersects a circle from a different plate, a borderline may be drawn.
Due to the randomness involved, plates will grow unevenly - the size of the starting circles, the radius of the followup circles, and a plate that has a lot of potential circles in the list is more likely to grow quickly than a plate with fewer.
It's slow because there are a lot of trig calculations every time a new circle is added. It does a distance calc against every existing point to see if there is an intersection, an then it calculates the coords of those intersections. I ran a 3rd map overnight, and it ended up with 17 plates, 5038 circles, and 3344 border line segments. Oh, and 5038 is just the number of circles it actually created. I don't have a count of how many circles it discarded because they were inside an area already covered by an existing circle.
I'm mostly wondering if the boundaries themselves look believable. I know the processes faults already. ;) Here is the output from the 3rd run, with the circle centerpoints shown.
Here's the clean version without the points:
I can see I still haven't tweaked the round boundaries out of existence yet. I know what to do about those and will add it in. And some of the borderlines at the poles are off, the seem to be rotated 90 degrees. And the two plates at the north pole not having any border at all between them is completely new... I'll have to investigate that and see what's up.
08-07-2011, 09:52 AM
Oh, and the topic has drifted a bit from the original question in the thread. The original question was how do I move from a list of coords in Excel to a map image. Waldonrate's suggestion of just using a chart in Excel is what I went with (and part of the slowness of the routine is that since I'm still in development, I haven't turned off screen updates). Rather than create a new thread to discuss the boundaries, I just continued this one. I apologize if I should have closed this and started anew.
08-07-2011, 01:20 PM
Went ahead and moved the discussion to: http://www.cartographersguild.com/showthread.php?15487-WIP-Tectonic-Plate-building
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.