Vorlage Diskussion:Graph:Map

aus Wikipedia, der freien Enzyklopädie
Dies ist die aktuelle Version dieser Seite, zuletzt bearbeitet am 25. Oktober 2021 um 12:14 Uhr durch imported>Kuhni74(826579) (Neuer Abschnitt →‎legend: number format).
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

Region IDs

I would strongly advise against storing the TopoJson file with country codes for region IDing. There are many regions that do not have country codes, but only 3-digit values. It would be fairly easy to create a Lua module that re-codes country codes into 3 digit IDs, so that editors can use country codes. Also, this way there will be only one topojson file stored, used by multiple templates. --Yurik (Diskussion) 19:32, 12. Jun. 2015 (CEST)

P.S. I think we should move these kinds of templates to mw:, e.g. mw:Extension:Graph/Guide, and have a bot sync them to all interested wikis. This way everyone would benefit from this work. Thanks! --Yurik (Diskussion) 21:21, 12. Jun. 2015 (CEST)
The country codes are only examples and of course only intended for maps with country borders only and for adm1st divisions at most. If maps contain subnational entities, like counties/municipalities/and so on of appropriate keys should be used. The general point I wanted to make is just that localized names should be avoided as IDs and instead language-independent keys should be used instead for the IDs. That being said, the module itself doesn't really care what the IDs are, and would also except numbers and names. The only restriction is that the keys/IDs must not be all-lowercase, as such parameters names are reserved for the module parameters. Anything else is usable as an ID.
Regarding mw:Extension:Graph/Guide, I could copy my documentation over there as I had actually already written an English documentation (Wikipedia:Lua/Modul/Graph/en) as I wanted to copy this module to enWP.
FYI, I also looked into how we can actually create maps to be used in the Graph module. I will also write a guide on this based on my notes below:
 
** Tool installation **

Linux (Ubuntu)
- install GDAL/OGR
  - add ubuntugis repository (https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable): sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
  - sudo apt-get install gdal-bin
  - Verification: ogrinfo
- install Node.js package manager (npm)
  - sudo apt-get install npm
- install Topojson
  - sudo npm install -g topojson
  - executing topojson will return an error that "node" could not be found, as the script is (now?) called "nodejs"
	- sudo ln -s /usr/bin/nodejs /usr/bin/nodejs
	or
	- sudo nano -w /usr/local/bin/topojson
	- change #!/usr/bin/env node to #!/usr/bin/env nodejs
	- save Ctrl+O, enter key, Ctrl+X

Windows
- install GDAL/OGR (https://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries#Windows)
  - http://www.gisinternals.com/release.php --> http://download.gisinternals.com/sdk/downloads/release-1800-x64-gdal-1-11-1-mapserver-6-4-1.zip --> \bin\gdal\apps
  - already included in MySQL Workbench (first step can be skipped)
- install Node.js (https://nodejs.org/)
- install Topojson
  - Open command prompt window: npm install -g topojson
  - C:\Users\<username>\AppData\Roaming\npm\topojson.cmd
  
** Map creation **
1. get free map data

- http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ (public domain)
  - Admin 0 – Countries
  - Admin 1 – States, Provinces
  - ogrinfo -al -geom=no Filename.shp to show the field keys and values

2. convert to GeoJSON and extract the wanted geographical features using ogr2ogr
 
Examples:
ogr2ogr -f GeoJSON -where "CONTINENT = 'Europe'" Europe.json ne_10m_admin_0_map_subunits.shp
ogr2ogr -f GeoJSON -where "ADM0_A3 in ('BEL', 'NLD', 'LUX')" Benelux.json ne_10m_admin_0_map_subunits.shp
ogr2ogr -f GeoJSON -where "adm0_a3='DEU'" Germany.json ne_10m_admin_1_states_provinces.shp

3. convert to TopoJSON format

- provide "--id-property" parameter with proper field key (see ogrinfo)
- optionally also provide "--properties name=NAME" parameter to include the descriptive name of the geo object

Example:

topojson --id-property code_hasc --properties name=NAME -o Germany.json.topo.json Germany.json (code_hasc is the ISO code of the German states)
topojson --id-property gn_a1_code --properties name=NAME -o Japan.json.topo.json Japan.json (gn_a1_code corresponds to the ISO code of the Japanese prefectures)

Preview map:
- http://mapstarter.com/

** Map normalization (work in progress) **
- normalize IDs
  - e.g. code_hasc and gn_a1_code use "." instead of "-": search-replace "DE." -> "DE-", "JP." -> "JP-"
- normalize geodata:
  - for the maps to be properly shown knowledge of the proper scaling factor and translation is necessary, i.e. extracting map parts from a larger map (like a country from a world map) will leave a large part of the map empty (the removed parts) and need to be compensated
    - research if automatically doable: see http://bl.ocks.org/mbostock/4699541
    - otherwise: the maps need to be normalized manually (how?) or the maps should give hints to module for the proper normalization parameters 

--Mps、かみまみたDisk. 23:15, 12. Jun. 2015 (CEST)

@Mps:, would it make sense to use a service like this for GeoJson->TopoJson conversion? GeoJson with open license should be easier to find on the web - I doubt that many people will be installing Linux for this :) Btw, from what I have read so far, even though Graph extension supports GeoJson, TopoJson uses less space, thus is probably preferred.
As for the copying - my main point is that I think we should set up an automated bot copying of the templates - this way you can keep the master copy on mediawiki.org, and let the bot copy it to all other wikis - to de, en, and all others that want it.
And the last thing - I think "Template:Graph:Map" is a better name for this template - this way it clearly sets up a separate "virtual" namespace for graph-related templates. See guide for more info on this. Thanks!!! --Yurik (Diskussion) 04:57, 13. Jun. 2015 (CEST)
One doesn't need Linux, as there are also Windows versions of the programs which I mainly use. I will look at the web site – it will for sure be more convenient if one doesn't have to install the Node.js framework required for the Topojson tool.
W.r.t. the copying: I agree with you on this, but I would prefer to do some fixes over the weekend to the map function before I put the version on Mediawiki. This map function is basically the oldest part of the module and mostly based on the example given on the extension's Mediawiki page, but testing it with other maps I noticed some deficiencies I wanted to correct. As these won't take long, I think I will copy the new version in one or two days.
I will think about it as GraphMap and especially GraphChart are already used in some articles – the latter was also imported to enWP. But anyway it shouldn't be a problem to fix the inclusions or maybe do a redirection from GraphMap → Graph:Map for backward compatibility. --Mps、かみまみたDisk.

legend: number format

Is it possible to make the format of the numbers in the legend adjustable? E.g. if you want to display years on the map (the point of time, when something occurred for the first or last time), it is confusing if the year is displayed with group separators like in 1,890 instead of 1890. One example is discussed on Diskussion:Frauenwahlrecht#Grafik "Frauenwahlrecht_weltweit", referring to Frauenwahlrecht#Frauenwahlrecht weltweit. --Kuhni74 (Diskussion) 14:14, 25. Okt. 2021 (CEST)