{"id":13685616,"url":"https://github.com/zverok/worldize","last_synced_at":"2025-04-05T17:07:19.520Z","repository":{"id":54832527,"uuid":"50108242","full_name":"zverok/worldize","owner":"zverok","description":"Simple coloured countries drawing","archived":false,"fork":false,"pushed_at":"2018-08-20T06:25:14.000Z","size":10452,"stargazers_count":262,"open_issues_count":1,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T16:07:52.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zverok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-21T13:08:31.000Z","updated_at":"2025-01-10T07:29:05.000Z","dependencies_parsed_at":"2022-08-14T04:10:44.795Z","dependency_job_id":null,"html_url":"https://github.com/zverok/worldize","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fworldize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fworldize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fworldize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fworldize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zverok","download_url":"https://codeload.github.com/zverok/worldize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T14:00:54.662Z","updated_at":"2025-04-05T17:07:19.502Z","avatar_url":"https://github.com/zverok.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Worldize\n========\n\n**Worldize** is a very simple and naive gem to make world map, with\ncountries painted according to some values (see also\n[choropleth map](https://en.wikipedia.org/wiki/Choropleth_map)).\n\n## Demonstration\n\n### Just monochrome countries\n\n**Code:**\n```ruby\nworldize = Worldize::Countries.new\nimg = worldize.draw # Magick::Image of RMagick\nimg.write('blank.png')\n```\n\n**Picture:**\n\u003cimg src=\"https://raw.github.com/zverok/worldize/master/examples/output/blank.png\" alt=\"Monochrome countries\"/\u003e\n\nYou can set some options (see [Usage](#usage) for details):\n```ruby\nworldize = Worldize::Countries.new\nimg = worldize.draw(ocean: '#3A3C3C', land: 'black', border: 'yellow')\nimg.write('night.png')\n```\n\u003cimg src=\"https://raw.github.com/zverok/worldize/master/examples/output/styles.png\" alt=\"Styles\"/\u003e\n\n### Some countries highlighted\n\n**Code:**\n```ruby\nWorldize::Countries.new.\n  draw_highlighted('Ukraine', 'Argentina', 'Portugal', 'India', 'Iceland').\n  write('highlighted.png')\n```\n\n**Picture:**\n\u003cimg src=\"https://raw.github.com/zverok/worldize/master/examples/output/highlighted.png\" alt=\"Highlighted countries\"/\u003e\n\n### Countries painted in custom colors\n\n**Code:**\n```ruby\nWorldize::Countries.new.\n  draw(\n    'Ukraine' =\u003e '#FCF83D',\n    'Argentina' =\u003e '#FE7ECD',\n    'Portugal' =\u003e '#FD1F30',\n    'India' =\u003e '#108400',\n    'Iceland' =\u003e 'white'\n  ).\n  write('colors.png')\n```\n\n**Picture:**\n\u003cimg src=\"https://raw.github.com/zverok/worldize/master/examples/output/colors.png\" alt=\"Countries in different colors\"/\u003e\n\n### Countries painted in gradient according to value\n\n```ruby\nworldize = Worldize::Countries.new\n\n# create hash like {country name =\u003e value}\nvalues = {\n  'Argentina' =\u003e 100,\n  'Bolivia' =\u003e 50,\n  'Chile' =\u003e 180\n  #...\n}\n\nworldize.\n  draw_gradient(\n    '#D4F6C8', # gradient from this color\n    '#247209', # ...to that color\n    values     # ...according to value\n    ).\n  write('gradient.png')\n```\n**Picture:**\n\u003cimg src=\"https://raw.github.com/zverok/worldize/master/examples/output/gradient.png\" alt=\"Countries gradient\"/\u003e\n\n**NB:** on this picture, countries associated with values according to\ntheir position in sorted countries list, just like this:\n```ruby\nvalues = worldize.country_names.sort.each_with_index.to_a.to_h\n# =\u003e {\"Afghanistan\"=\u003e0, \"Albania\"=\u003e1, \"Algeria\"=\u003e2, \"Angola\"=\u003e3, \"Antarctica\"=\u003e4, \"Argentina\"=\u003e5, \"Armenia\"=\u003e6, ...\n```\n\n## Installation\n\nIt's gem, named `worldize`. Do your usual `[sudo] gem install worldize`\nor adding `gem 'worldize'` to Gemfile routine.\n\n## Usage\n\n### From code\n\nCreate an object: `w = Worldize::Countries.new`.\n\n#### Generic draw\n\nSynopsys: `#draw('Country1' =\u003e 'color1', 'Country2' =\u003e 'color2', ... , option: value)`\n\n`Country` can be either full name or\n[ISO 3-letter code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).\nFor list of known names/codes there are service functions `#country_names`\nand `#country_codes`.\n\n`color` is any color value RMagick [can understand](http://www.imagemagick.org/script/color.php)\n(for ex., hex-codes or common color names).\n\nOptions awailable:\n\n* `width` of resulting image (default 1024 pixels, height will be\n  calculated automatically);\n* `land`—default color of land (for countries not specified in list);\n* `ocean`—color of ocean;\n* `border`—color of country borders.\n\nBoth countries and options can be omitted completely (resulting in\nall countries being drawn in default color).\n\n#### Select several countries with one color\n\nSynopsys: `#draw_selected('Country1', 'Country2', ... , option: value)`.\n\nOptions are the same as for `#draw` plus `:selected` background color\n(reasonable default exists, so can be omitted).\n\n#### Paint countries proportionally to some measurement\n\nSynopsys: `#draw_gradient('from_color', 'to_color', 'Country1' =\u003e value1, 'Country2' =\u003e value2, ... option: value)`\n\nValues should be numeric and colors will be scaled to gradient between\n`from_color` and `to_color`.\n\n### From command line\n\nUse `worldize --help` for details.\n\n**Highlight countries:**\n```\nworldize -o highlighted.png \\\n  --highlight-countries Ukraine,Argentina,Portugal,India,Iceland \n```\n\n**Colors for countries:**\n```\nworldize -o color.png \\\n  --paint-countries \"Ukraine:#FCF83D,Argentina:#FE7ECD,Portugal:#FD1F30,India:#108400,Iceland:white\" \n```\nor from CSV file\n```\nworldize -o color.png \\\n  --paint-countries country_colors.csv --csv-columns 0,1 \n```\nmeans firs and second columns contain country name and color. Or from CSV\nwith headers:\n```\nworldize -o color.png \\\n  --paint-countries country_colors.csv\n  --csv-headers --csv-columns Country,Color \n```\n\n**Color-coded statisitcs**\n```\nworldize  -o gradient.png \\\n  --from-color '#D4F6C8' --to-color '#247209' \\\n  --grad-countries \"Argentina:100,Bolivia:50,Chile:180\"\n```\nor from CSV file, like above:\n```\nworldize  -o gradient.png \\\n  --from-color '#D4F6C8' --to-color '#247209' \\\n  --grad-countries country_stats.csv --csv-headers --columns \"Country,Population 2015\"\n```\n\n## How this was done\n\n* Country borders are taken from [geojson](http://data.okfn.org/data/datasets/geo-boundaries-world-110m)\n  (sourced from Natural Earth by OpenData license);\n* Web Mercator map projection calculated according to [formulae](https://en.wikipedia.org/wiki/Web_Mercator#Formulas);\n* Result is cropped to exclude polar areas (which has nothing interesting\n  in any case!);\n* RMagick for drawing, awesome [color](https://rubygems.org/gems/color/versions/1.8)\n  gem for gradients calculation.\n\n## TODO\n\n_(or not TODO, depends on whether somebody needs this)_\n\n* Options to draw legend and other text labels;\n* Use of some open-licensed tiles/picture of the world as background\n  image.\n\n## Authors\n\n[Victor Shepelev](http://zverok.github.io/)\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Fworldize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzverok%2Fworldize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Fworldize/lists"}