We’re in the middle of house hunting in Nashville (which is booming).
So, I wanted a tool that would help me vet addresses as they pop-up in my feed from our realtor.
We wanted to be able to walk to some things in our neighborhood and fortunately that criterion a pretty easy thing to map out by hand in inkscape with screenshots from Google maps. I was able to produce a png map that had those regions clearly identified. For those that remember the 2010 floods, water ways are something to be wary of. So I pulled a map from FEMA (maps.nashville.gov) and overlayed that with a transparency by hand, easy enough. I could also have tried to overlay crime maps and offender registries, but this was sufficient for triage.
Now I just needed a converter(mapper) between the x,y in inkscape and gps coordinates.
I used PIL (python image library, aka pillow) to draw on the picture I had created.
The converter looks like this:
#scale = [4528.104575164487, -162821.9551111503, 3633.747495444875, 315924.9870280141]
scale = [-5228.758169935899, 189234.5555556009, 4041.34431458903, 351362.65809204464]
There are two attempts here because a conversion from GPS coordinates to inkscape coordinates is unfortunately not the same as GPS to pillow.
I derived this via two “calibration” points on my map and the respective coordinates in pillow.
given = [[36.039065, -86.782672],[36.042890, -86.606493]]
res = [[644, 795],[1356,775]]
a = (given – given) / (res – res)
b = -a * res + given
c = (given – given) / (res – res)
d = -c * res + given
scale = [1/a, -b/a, 1/c, -d/c]
This finds slope and offset for two categories , latitude and longitude, based off of four points and is exact (those potentially off by a little depending on the accuracy of my calibration points). I should’ve picked points better, because 36.039 is not very different from 36.042. Oh well. In the end it worked.
Then I just hardcoded the values of the variable scale into the function mapper.
I have my x,y coordinates from latitude and longitude. Now I want to draw on my map.
im = Image.open(“pillow.png”)
draw = ImageDraw.ImageDraw(im)
flip = im.size[-1]
for pair in coords:
vec = [mapper(pair+0.001,pair-0.001,flip),
It makes all the points the same color which makes it difficult to judge multiple new points on a figure, but this was sufficient for my purposes.
The plus and minus 0.001 was found by trial and error to make the correct sized dots on the map.
The tool was just for me but my wife also appreciated that we could use this to quickly go through the initial barrage of home listings
and weed out the listings that were for sure not going to be of interest.
Not too bad for a few hours of work and most of that was just deciding and drawing out the regions of interest.