My brother suggested that I should write a web app that lets students create and print blank maps. A blank map is a map that contains country borders, waters etc. but no text labels. The first use case is the following:

  1. User selects 'Hungary' from a list. A blank map of Hungary appears on screen.
  2. User enters a name of a Hungarian town or place in a textbox. A small marker appears on the map in the specified place, but without a text label.
  3. User repeats step 2 as many times as he wishes, with different towns.
  4. User prints the resulting image and uses it to practice for his upcoming history or geography exam. The exam task is the same: receiving a blank map with textless markers and you have to fill in the town names from memory.

So I started to write the app, and at step 1, I've ran into the first problem. I don't have a database of blank maps. In order to let the user select a blank map from a list, someone has to create and fill a database of blank maps, in which the maps table has the following (pseudo-)definition:

     image BLOB,
     minlat FLOAT,
     minlon FLOAT,
     maxlat FLOAT,
     maxlon FLOAT

I decided to fill out one or two rows of this table myself, for testing. I downloaded this blank map of Hungary by a quick Google Search:

blank map

Now how on earth do I determine the coordinates? Let's try and create an overlay in Google Earth:

google earth screenshot

As you can see I didn't manage to position it precisely, the eastern borders are a bit off. So my question is:

Given an image file showing a map, how do I determine the exact lat/lon coordinates of its corners?

  • It's unclear what you're asking. If you want to plot lat/lon on a flat plane, then yes, projection is important. The standard "schoolroom" projection is Mercator, and the Wikipedia article gives you all the math you need. – kdgregory Jan 18 '15 at 13:28
  • 2
    I don't know why the closers chose "too broad," but in my opinion the question remains unclear. Even with your edit, I still don't know whether you're trying to place markers on an image that contains a blank map or something else. Your comment about knowing the lat/lon for an image is particularly strange: if you create the image, you should already know what it represents. I suggest a complete rewrite of the question, in which you paste pictures and description of what you want to do at each step. Also be very clear about what you already have and what you want to achieve. – kdgregory Jan 21 '15 at 16:29
  • 1
    @kdgregory Pretty certain I went with too broad because of "good answers would be too long for this format." Most close voters will use too broad for questions like the original version which was essentially a "where do I start?" type question. – user53019 Jan 22 '15 at 13:45
  • 2
    This is a great re-write. This is not my area of expertise, though, so I can't tell if adequate answers would be too large for this Q&A format. – MetaFight Jan 22 '15 at 23:42
  • 4
    Maybe this is a candidate for migration to gis.stackexchange.com? Look into postgis.net - with a little difficulty, you can set up a map tile server and use existing browser-side tools do display them and to convert from browser window coordinates to map coordinates. – James McLeod Jan 23 '15 at 0:09

It depends on the map. Cartographic maps are projections of a (nearly) spherical surface onto a flat, two dimensional surface. That is:

(X, Y) = Fproj(Lat, Long)

where Fproj() is the projection function.

For instance, for a standard Mercator projection with the X axis on the equator, and the Y axis at the 0 Meridian:

X = Longitude
Y = ln(tan(Latitude) + sec(Latitude))

If you know the type of map projection, and the lat/long of the corners of the map, you may be able to determine the lat/long based on the X,Y coordinates by doing an inverse projection.

Wolfram MathWorld has a good catalog of map projections and their inverses.

If you are interested in displaying maps based on existing latitude and longitude data, and you are willing to write your own map projection functions (most are really easy to implement), you can use any of the several sources of databases and flat files that contain country borders, lakes, rivers, etc. A short search with my favorite search engine turns up these two:

Natural Earth Data ThematicMapping.org

If you do not know the map projection, but you know that Latitude,Longitude of several points on the map, you can use interpolation to estimate the Lat,Long of points on the map based on the Lat, Long of nearby registered points.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.