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

9449 questions
64
votes
2 answers

How do I change the NA color from gray to white in a ggplot choropleth map?

I am trying to create a choropleth map of the US that has the default color changed from gray to white. I have records for 18 of 48 states and the code works to color by value, but for those states where I have no records the states are gray. I…
user2320821
  • 1,141
  • 3
  • 13
  • 19
62
votes
11 answers

What is the best way to create a sparse array in C++?

I am working on a project that requires the manipulation of enormous matrices, specifically pyramidal summation for a copula calculation. In short, I need to keep track of a relatively small number of values (usually a value of 1, and in rare…
Ed.
  • 1,404
  • 4
  • 17
  • 26
62
votes
6 answers

How to clear Leaflet map of all markers and layers before adding new ones?

I have the following code: map: function (events) { var arrayOfLatLngs = []; var _this = this; // setup a marker group var markers = L.markerClusterGroup(); events.forEach(function (event) { // setup the bounds …
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
61
votes
3 answers

get boundaries longitude and latitude from current zoom google maps

i need to know long and lat of my four corners of current area as in this image i have tried this but with no luck : map.getBounds(); any help ?
Samy Massoud
  • 4,295
  • 2
  • 35
  • 48
58
votes
2 answers

Get key in groovy maps

def map = [name:"Gromit", likes:"cheese", id:1234] I would like to access map in such a way that I can get the key something like the output should be map.keys returns array of string. basically i just want to get the keys output: name likes id
kumar
  • 8,207
  • 20
  • 85
  • 176
58
votes
5 answers

D3js: Automatic labels placement to avoid overlaps? (force repulsion)

How to apply force repulsion on map's labels so they find their right places automatically ? Bostock' "Let's Make a Map" Mike Bostock's Let's Make a Map (screenshot below). By default, labels are put at the point's coordinates and…
Hugolpz
  • 17,296
  • 26
  • 100
  • 187
58
votes
2 answers

Using custom map image tiles in LeafletJS?

Do my tiles need to adhere to any particular specs? I have a large image file which I'd like to turn into a map with LeafletJS. I am going to be using the Python Imaging Library to cut it up into all the various tiles I need. However, I can't find…
thisissami
  • 15,445
  • 16
  • 47
  • 74
48
votes
3 answers

Can I prevent panning Leaflet map out of the world's edge?

Is there a way to limit panning out of the world's edge? On this picture, brown is the world, grey is emptiness. I want to make it impossible to pan like this.
Terion
  • 2,396
  • 3
  • 28
  • 42
46
votes
3 answers

How to efficiently compare two maps of strings in C++ only for a subset of the keys

I'm wondering if only by applying some standard algorithms is possible to write a short function which compares two std::map and returns true if all the key-value (but some) pairs are true. For example, these two maps should be…
linello
  • 8,451
  • 18
  • 63
  • 109
46
votes
3 answers

What is the Big O performance of maps in golang?

The "Map types" section of the go language specification describes the interface and general usage of map types and the "Go maps in action" post on The Go Blog casually mentions hash tables and "fast lookups, adds, and deletes". The current…
maerics
  • 151,642
  • 46
  • 269
  • 291
46
votes
6 answers

Using java map for range searches

I have a use case where if a number lies between 0-10 it should return 0 and if it lies between 11-20 it should return 1 etc 0 => 0-3, (0 and 3 are inclusive) 1 => 4-15, (4 and 15 are inclusive) 2 => 16-40, (16 and 40 are inclusive) 3 => 41-88,…
kal
  • 28,545
  • 49
  • 129
  • 149
45
votes
4 answers

using BOOST_FOREACH with std::map

I'd like to iterate over a std::map using BOOST_FOREACH and edit the values. I can't quite get it. typedef std::pair IdSizePair_t; std::map mmap; mmap[1] = 1; mmap[2] = 2; mmap[3] = 3; BOOST_FOREACH( IdSizePair_t i, mmap ) …
kmote
  • 16,095
  • 11
  • 68
  • 91
43
votes
8 answers

Google Maps Android API v2 - Sample Code crashes

I'm trying to get the sample code of Android 'Google Maps Android API v2' working. I get the project built without errors. However, when I try to run the app on my Galaxy Nexus (connected with usb to my laptop), the app crashes immediately. I…
alexx
  • 603
  • 1
  • 6
  • 8
42
votes
2 answers

Javascript Objects vs Map performance (Chrome, V8, Node JS)

I am trying to understand whether to use JS Object or Map if I need random lookups by string key in large datasets (>1000 objects). I wrote a simple benchmark http://jsperf.com/javascript-objects-vs-map-performance and the results show that in…
Andrew Marin
  • 1,053
  • 1
  • 13
  • 15
42
votes
9 answers

Assign ID to marker in leaflet

So i try to achieve a result as on foursquare: https://foursquare.com/explore?cat=drinks&mode=url&near=Paris which is when you clik on a marker on the map, it scrolls through the listed of restaurants on the right -hand side of the screen to the…
lauWM
  • 659
  • 3
  • 10
  • 18