Determine exact coordinates for a map image?

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> CREATE TABLE maps (
name TEXT PRIMARY KEY,
image BLOB,
minlat FLOAT,
minlon FLOAT,
maxlat FLOAT,
maxlon FLOAT
);
</code>
<code> CREATE TABLE maps ( name TEXT PRIMARY KEY, image BLOB, minlat FLOAT, minlon FLOAT, maxlat FLOAT, maxlon FLOAT ); </code>
 CREATE TABLE maps (
     name TEXT PRIMARY KEY,
     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?

9

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>(X, Y) = Fproj(Lat, Long)
</code>
<code>(X, Y) = Fproj(Lat, Long) </code>
(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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>X = Longitude
Y = ln(tan(Latitude) + sec(Latitude))
</code>
<code>X = Longitude Y = ln(tan(Latitude) + sec(Latitude)) </code>
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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Determine exact coordinates for a map image?

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> CREATE TABLE maps (
name TEXT PRIMARY KEY,
image BLOB,
minlat FLOAT,
minlon FLOAT,
maxlat FLOAT,
maxlon FLOAT
);
</code>
<code> CREATE TABLE maps ( name TEXT PRIMARY KEY, image BLOB, minlat FLOAT, minlon FLOAT, maxlat FLOAT, maxlon FLOAT ); </code>
 CREATE TABLE maps (
     name TEXT PRIMARY KEY,
     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?

9

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>(X, Y) = Fproj(Lat, Long)
</code>
<code>(X, Y) = Fproj(Lat, Long) </code>
(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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>X = Longitude
Y = ln(tan(Latitude) + sec(Latitude))
</code>
<code>X = Longitude Y = ln(tan(Latitude) + sec(Latitude)) </code>
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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật