# Distance measures on a map of a game

I have an image which my DM made of map for a DND game and I want to do two things.

• Click on two points on my map, then based on the key for scaling have Mathematica tell me how far apart those points are.

• Given a distance and a point that I click on, draw a circle about the given point that has the radius of the given distance.

If anyone will give me advice for how to get started on this project, I would be very grateful.

Both tasks you outlined could be fused into a single app - screenshot is above. I assume that because this is a game the corrections due to geodesic model (flat map from non-flat planet surface) do not really matter (this was not mentioned in the project description). Here is a quite simple code to get you started that you can modify and upgrade.

i = Import["https://i.stack.imgur.com/TVsMy.jpg"];

Manipulate[
Column[{
ToString[Round[.7595 RegionMeasure[N[Line[pt]]],.01]]
<>" miles",20,FontFamily->"Herculanum"],
HighlightImage[i,{Thickness[.003],Dashing[.01],
Line[pt],
Circle[pt[[1]],EuclideanDistance@@pt[[;;2]]]},
ImageSize->800]
},Alignment->Center],
{{pt,{{1610,100},{2005,100}}},Locator,LocatorAutoCreate->True}]


A few things to take a note:

• In addition to the distance between 2 points you can build a whole path and measure its length.

• Add or remove more path points with CMD(ALT)+CLICK on Mac (Win).

• Decreasing image size will make your app faster

• Scaling factor in front of RegionMeasure can be adjusted to match map scale. It is done by simply running app for the firs time when in initial stage the path is equal to the map scale length (see next image below). Then adjust the scaling factor so number in the title is equal to the number on the map scale.

• In the initial state there are only 2 points and a circle centered at 1st and passing through 2nd. Dragging locators around and see how number in the title changes effectively solves your second task. Place 1st point at a needed location and then drag 2nd to measure needed radius that is indicated in the plot title and you get the circle you need.

• This is amazing, thank you so much. One quick question though, I don't seem to be able to add the additional points like in your first screen shoot (in using windows) Apr 8, 2019 at 21:26
• @Wombles you are welcome :) Read docs HERE especially details section. I corrected the post - on Win it is ALT+CLICK. Thanks for noting! Apr 8, 2019 at 21:31
• Yes, fantastic answer Vitaliy. I have often wanted to use Mathematica for my own DnD game - perhaps now I will :) Apr 8, 2019 at 21:36
• Will do, i also need to download that sweet font too. Apr 8, 2019 at 21:37

I have some advice, but it is just that, and not a solution to your problem.

• Decide on a geodetic model for the world you are mapping. I recommend picking one of the geodetic models of planet Earth that Mathematica recognizes.
• Decide on what the projection from a sphere to your map grid will be.
• Use the built-in functions GeoGridPosition and GeoPosition to transform coordinates between the grid (map) and the model (sphere).
• Look at GeoProjectionData to learn about Mathematica knows about projections.

Note: depending on the projection you choose, a circle about a point on sphere may not appear as a circle on your map.

BTW, nice looking map.

• Thank you for the advice and the starting point. Apr 8, 2019 at 5:38