Questions tagged [maps]

A map is a visual representation of an area—a symbolic depiction highlighting relationships between elements of that space such as objects, regions, and themes. For the key-value data structure, use dictionary tag instead.

Modern maps

Many maps are static two-dimensional, geometrically accurate (or approximately accurate) representations of three-dimensional space, while others are dynamic or interactive, even three-dimensional.

Although most commonly used to depict geography, maps may represent any space, real or imagined, without regard to context or scale; e.g. brain mapping, DNA mapping, and extraterrestrial mapping.

Many, but not all, maps are drawn to a scale, expressed as a ratio such as 1:10,000, meaning that 1 of any unit of measurement on the map corresponds exactly, or approximately, to 10,000 of that same unit on the ground.

Maps of the world or large areas are often either 'political' or 'physical'. Topographic maps show elevations and relief with contour lines or shading. Geological maps show not only the physical surface, but characteristics of the underlying rock, fault lines, and subsurface structures.

Maps that depict the surface of the Earth also use a projection, a way of translating the three-dimensional real surface of the geoid to a two-dimensional picture. Perhaps the best-known world-map projection is the Mercator projection, originally designed as a form of nautical chart.

Aeroplane pilots use aeronautical charts based on a Lambert conformal conic projection, in which a cone is laid over the section of the earth to be mapped.

From the last quarter of the 20th century, the indispensable tool of the cartographer has been the computer. Much of cartography, especially at the data-gathering survey level, has been subsumed by Geographic Information Systems (GIS).

A complex problem when dealing with maps is to calculate the distance between two points. The simplest approach is to work as if the map was a simple plane and use Euclidean distance function. However, this might be inadequate, especially in the case when we are dealing with large distances. In that case the differences between the real shape of the planet and a plane will get more accent. A significant improvement over this is to calculate the distance between two coordinates using the Haversine formula, but even this might be imprecise in some cases where high precision is needed, due to the differences of altitude or other geometrical, or non-geometrical distance modificators, like speed limits on roads, closed borders of countries, travel costs, etc.

More info on Wikipedia

8638 questions
991
votes
46 answers

Calculate distance between two latitude-longitude points? (Haversine formula)

How do I calculate the distance between two points specified by latitude and longitude? For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches…
Robin Minto
  • 13,373
  • 3
  • 32
  • 40
454
votes
21 answers

What is the ideal data type to use when storing latitude / longitude in a MySQL database?

Bearing in mind that I'll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database?
Codebeef
  • 41,810
  • 20
  • 83
  • 116
176
votes
12 answers

Iterating over Typescript Map

I'm trying to iterate over a typescript map but I keep getting errors and I could not find any solution yet for such a trivial problem. My code is: myMap : Map; for(let key of myMap.keys()) { console.log(key); } And I get the…
mwe
  • 2,072
  • 2
  • 8
  • 16
121
votes
5 answers

C++ map access discards qualifiers (const)

The following code says that passing the map as const into the operator[] method discards qualifiers: #include #include #include using namespace std; class MapWrapper { public: const int &get_value(const int &key)…
cdleary
  • 63,281
  • 49
  • 155
  • 190
111
votes
17 answers

rgdal package installation

The issue here is not exactly how to plot maps through R, as I have found already a pretty nice example here, but rather how to make it work. In fact, I am unable to load library rgdal: library(rgdal) Error in library(rgdal) : there is no package…
user706838
  • 4,494
  • 10
  • 47
  • 73
110
votes
9 answers

Get the distance between two geo points

I want to make an app which checks the nearest place where a user is. I can easily get the location of the user and I have already a list of places with latitude and longitude. What would be the best way to know the nearest place of the list against…
Chmouel Boudjnah
  • 2,413
  • 3
  • 23
  • 25
104
votes
8 answers

Openstreetmap: embedding map in webpage (like Google Maps)

Is there a way to embed/mashup the OpenStreetMap in your page (like the way Google Maps API works)? I need to show a map inside my page with some markers and allow dragging/zooming around, maybe routing. I suspect there would be some Javascript API…
Piskvor left the building
  • 87,797
  • 43
  • 170
  • 220
101
votes
12 answers

How to import JSON File into a TypeScript file?

I am building a map application using Angular Maps and want to import a JSON file as a list of markers defining locations. I'm hoping to use this JSON file as marker[] array inside the app.component.ts . Instead of defining a hardcoded array of…
aonepathan
  • 1,386
  • 2
  • 10
  • 14
98
votes
7 answers

How to test the equivalence of maps in Golang?

I have a table-driven test case like this one: func CountWords(s string) map[string]int func TestCountWords(t *testing.T) { var tests = []struct { input string want map[string]int }{ {"foo", map[string]int{"foo":1}}, {"foo bar…
andras
  • 5,667
  • 4
  • 21
  • 21
78
votes
5 answers

How can I merge two STL maps?

How can I merge two STL maps into one? They both have the same key and value types (map). If there is an overlap of the keys, I would like to give preference to one of the maps.
JonF
  • 2,109
  • 5
  • 33
  • 54
75
votes
2 answers

Dynamically add data to a javascript map

Is there a way I can dynamically add data to a map in javascript. A map.put(key,value)? I am using the yui libraries for javascript, but didn't see anything there to support this.
stevebot
  • 21,481
  • 26
  • 107
  • 176
75
votes
11 answers

Google Maps Android API v2 - detect touch on map

I can't find an example on how to intercept the map touch on the new Google Maps API v2. I need to know when the user touches the map in order to stop a thread (the centering of the map around my current location).
Gaucho
  • 1,298
  • 1
  • 17
  • 32
71
votes
6 answers

Convert latitude/longitude point to a pixels (x,y) on mercator projection

I'm trying to convert a lat/long point into a 2d point so that I can display it on an image of the world-which is a mercator projection. I've seen various ways of doing this and a few questions on stack overflow-I've tried out the different code…
drunkmonkey
  • 1,041
  • 1
  • 15
  • 26
67
votes
4 answers

How to work with Maps in Kotlin

The code below is creating a new map called nameTable, then adding an entry named example to it, then trying to print the name property of the Value. When I run it, it seems that the plus operation didn't add a new entry to the map like I thought it…
Dina Kleper
  • 1,475
  • 2
  • 14
  • 20
61
votes
8 answers

How can I quickly estimate the distance between two (latitude, longitude) points?

I want to be able to get a estimate of the distance between two (latitude, longitude) points. I want to undershoot, as this will be for A* graph search and I want it to be fast. The points will be at most 800 km apart.
fread2281
  • 1,089
  • 1
  • 11
  • 28
1
2 3
99 100