Vorlage Diskussion:Graph:MapRegion IDsI 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)
** 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)
legend: number formatIs 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) |