5

In TikZ, I want to draw a world map with time zone lines and mark locations/cities on the map.

Essentially, use the world map (with timezone lines) as a canvas to draw tikz nodes at select latitude-longitude values and use those nodes to do regular tikz stuff like labeling, coloring, connecting nodes, etc.

Timezone lines and country boundaries are necessary for me, the state boundaries and color coding are optional.

Is there a tikz package or a process that can help me do this?

Thanks in advance.

World map with time zone lines

This map is from www.shutterstock.com

userOne
  • 147
  • 3
    look at the answer of https://tex.stackexchange.com/questions/183087/draw-colored-world-us-map-in-latex – rpapa Oct 02 '19 at 09:21
  • I did look at that answer before posting my question, it is a very good one, but it does not show how to draw a node at a given latitude-longitude. The mapping between latitude-longitude and diagram coordinates is not clear. Is there a site where I can get the inputs to draw timezone lines? – userOne Oct 02 '19 at 14:35
  • 1
    There are two aspects. Can one set up a coordinate system such that a latitude and longitude gets mapped on a point on the map? Easy. Does anyone have the patience to punch in the contours of the time zones of our planet? Less likely. –  Oct 02 '19 at 15:35
  • 1
    E.g. Mathematica is able to provide you with the time zone of a given location, try e.g. TimeZoneOffset[GeoPosition[{40.2, 111}]]. It does get the data from somewhere in the internet. So the data must be somewhere publicly available. Where? I do not know. Maybe https://apps.gis.ucla.edu/geodata/dataset/world_time_zones –  Oct 02 '19 at 15:43
  • 1
    There is the map of India on TeXample. – vi pa Oct 03 '19 at 09:15

1 Answers1

8

To use a pre-existing map, you need to know the type of projection used.. In my example, I choose a map with a null (or bilinear) projection: https://fr.m.wikipedia.org/wiki/Fichier:World_map_with_nations.svg (converted to PDF).

If you find a map with time zones using the same projection, you can convert it to PDF and use it directly in my code (replacing the World_map_nations map).

If you find a map with time zones but using another type of projection, you will need to improve the calculation of coordinates from latitude and longitude.

\documentclass[tikz]{standalone}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usetikzlibrary{calc,positioning}
\begin{document}
\begin{tikzpicture}
  % map <https://fr.m.wikipedia.org/wiki/Fichier:World_map_with_nations.svg>
  \node[inner sep=0] (W) {\includegraphics[width=28cm]{World_map_nations}};
  \path let \p1=(W.center), \p2=(W.north), \p3=(W.east), \n1={(\x3-\x1)/180}, \n2={(\y2-\y1)/90}
  in \pgfextra{ \xdef\laty{\n1} \xdef\lonx{\n2} };
  \begin{scope}[shift={(W.center)},x=\laty,y=\lonx]
    \draw[thin,cyan] (W.north) node[above, node font=\tiny]{0} -- (W.south);
    \draw[thin,cyan] (W.west) node[left, node font=\tiny]{0} -- (W.east);
    \foreach \lat in {10,20,...,90}{
      \draw[thin,cyan] (-180,\lat) node[left, node font=\tiny]{\lat{}N} --  (180,\lat);
      \draw[thin,cyan] (-180,-\lat) node[left, node font=\tiny]{\lat{}S} -- (180,-\lat);
    }
    \foreach \lon in {10,20,...,170}{
      \draw[thin,cyan] (\lon,90) node[above, node font=\tiny]{\lon{}E} --  (\lon,-90);
      \draw[thin,cyan]  (-\lon,90) node[above, node font=\tiny]{\lon{}W} --  (-\lon,-90);
    }
    \foreach \town/\lat/\lon in {%
      Paris/48.8534100/2.3488,%
      New York/40.7168669/-74.0059700,%
      Cape Town/-33.9258400/18.4232200%
    }{
      \fill[black] (\lon,\lat) circle(1pt) node[right]{\town};
    }
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

You can draw the grid lines behind the map via the backgrounds TikZ library:

\documentclass[tikz]{standalone}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usetikzlibrary{calc,positioning,backgrounds}
\begin{document}
\begin{tikzpicture}
  % map <https://fr.m.wikipedia.org/wiki/Fichier:World_map_with_nations.svg>
  \node[inner sep=0] (W) {\includegraphics[width=28cm]{World_map_nations}};
  \path let \p1=(W.center), \p2=(W.north), \p3=(W.east), \n1={(\x3-\x1)/180}, \n2={(\y2-\y1)/90}
  in \pgfextra{ \xdef\laty{\n1} \xdef\lonx{\n2} };
  \begin{scope}[shift={(W.center)},x=\laty,y=\lonx]
    \begin{scope}[on background layer]
      \draw[thin,cyan] (0,90) node[above, node font=\tiny]{0} -- (0,-90);
      \draw[thin,cyan] (-180,0) node[left, node font=\tiny]{0} -- (180,0);
      \foreach \lat in {10,20,...,90}{
        \draw[thin,cyan] (-180,\lat) node[left, node font=\tiny]{\lat{}N} --  (180,\lat);
        \draw[thin,cyan] (-180,-\lat) node[left, node font=\tiny]{\lat{}S} -- (180,-\lat);
      }
      \foreach \lon in {10,20,...,170,180}{
        \draw[thin,cyan] (\lon,90) node[above, node font=\tiny]{\lon{}E} --  (\lon,-90);
        \draw[thin,cyan]  (-\lon,90) node[above, node font=\tiny]{\lon{}W} --  (-\lon,-90);
      }
    \end{scope}
    \foreach \town/\lat/\lon in {%
      Paris/48.8534100/2.3488,%
      New York/40.7168669/-74.0059700,%
      Cape Town/-33.9258400/18.4232200%
    }{\fill[black] (\lon,\lat) circle(1pt) node[right]{\town};}
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
  • Nice solution. Is it possible to send the grid lines behind the map, instead of placing it above the map? – userOne Oct 04 '19 at 08:40
  • Amazing!!! A million thanks to Paul Gaborit. A big part of the question (coordinate mapping) is addressed, I will take up timezone lines now. – userOne Oct 08 '19 at 12:02