4

The seeds of this question were planted in my mind and have been growing since I read this answer.

I think it'd be nice to have a database from which some newcommand making use of TikZ picks up coordinates based on a text string to draw (the border of) a country. (I'm thinking of something like \drawcountry[black,fill=red]{Italy}.)

One of the points to address is how to store such coordinates in a way that they can be easily used by TikZ. I'm spontaneously thinking about a two column file with blank lines to indicate non-connected regions (e.g. islands), so that ~\draw plot file{...}` could be used.

On the other hand I read that SVG files can contain several path constructors which work in a similar fashion as TikZ's controls. With this in mind, the idea of the two-column file would be good only if M, L, and z are the only constructors to be used.

So the question becomes: how should I store coordinates retrieved from a SVG file in order to use them in TikZ?

By the way, is someone interested in such pastime? I was thinking about making a GitHub repo.

Enlico
  • 2,592
  • 1
    I really like the idea! – TeXnician Mar 19 '17 at 16:39
  • Then let's wait for someone giving us some good advice, so that we can start! – Enlico Mar 19 '17 at 16:47
  • 3
  • How didn't I think searching for SVG in the manual?! Thank you, @PaulGaborit; yours is more of an answer than a simple comment. I'll be glad to accept if you post it :) – Enlico Mar 19 '17 at 18:09
  • In my experience feeding the SVG directly to tikz is not very efficient...I think converting it to direct tikz paths would make the package more flexible and efficient. – Bordaigorl Mar 19 '17 at 19:05
  • @Bordaigorl, what do you mean by efficient? Are you talkin about the compilation time? I'd like to have your opinion about this hypotetical package. – Enlico Mar 21 '17 at 19:53
  • Yes I mean compilation time. Also I have the impression that it would be more flexible (more ways to use them) but I may be wrong. The way I see it you have three options: 1. node shapes for each state + macros to put the nodes in the right positions for larger maps 2. pics 3. custom macros all the way – Bordaigorl Mar 21 '17 at 21:59
  • I do not have time at the moment but it would also be interesting to see how the GeoJson guys did it and maybe write some interface code to translate some of their data structures to tikz paths. This could lead to a workflow like 1. query db for geo-data 2. process it with a script that produces a tex file with the paths 3. write your tikz using the paths – Bordaigorl Mar 21 '17 at 22:02
  • The GeoJson approach could also be more flexible in giving you a custom level of detail in the paths. Also, if the script is coded in Lua, it may be integrated in a lualatex package – Bordaigorl Mar 21 '17 at 22:06
  • Another reference for datasets: http://www.gadm.org/country Unfortunately the shapefile format may be a bit difficult to parse in full generality – Bordaigorl Mar 21 '17 at 22:19

1 Answers1

2

You can use the svg operation (cf. section 14.11 "The SVG operation" , pgfmanual, p.156, v3.0.1a).

Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283