Published

Country Polygons as GeoJSON

18.2K
8.3K

geodata data package providing geojson polygons for all the world's countries

Download · GEOJSON · 14.6 MB
API Access

Access dataset files directly from scripts, code, or AI agents.

Browse dataset files
Dataset Files

Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.

/core/geo-countries/
https://datahub.io/core/geo-countries/_r/-/.gitignore
https://datahub.io/core/geo-countries/_r/-/Makefile
https://datahub.io/core/geo-countries/_r/-/README.md
https://datahub.io/core/geo-countries/_r/-/data/countries.geojson
https://datahub.io/core/geo-countries/_r/-/datapackage.json
Key Files

Start with these files — they give you everything you need to understand and access the dataset.

datapackage.jsonmetadata & schema
https://datahub.io/core/geo-countries/_r/-/datapackage.json
README.mddocumentation
https://datahub.io/core/geo-countries/_r/-/README.md
Typical Usage
  1. 1. Fetch datapackage.json to inspect schema and resources
  2. 2. Download data resources listed in datapackage.json
  3. 3. Read README.md for full context

Data Previews

countries

Schema

nametypedescription
namestringCommon name of the country
ISO3166-1-Alpha-3string3 characters code for the country, according to ISO3166 standard

Data Files

FileDescriptionSizeLast modifiedDownload
countries
14.6 MB26 days ago
countries
FilesSizeFormatCreatedUpdatedLicenseSource
114.6 MBgeojson11 months agoOpen Data Commons Public Domain Dedication and License v1.0Natural Earth

badge

Description

Geodata data package providing geojson polygons for all the world's countries. Perfect for use in apps and visualizations.

Data

The data comes from Natural Earth, a community effort to make visually pleasing, well-crafted maps with cartography or GIS software at small scale.

More info about countries can be obtained from datapackage https://github.com/datasets/country-codes by a join on field ISO3166-1-Alpha-3

Preparation

To run the script and update the data:

Prerequisites

  1. Install required tools:

    • GDAL - for geographic data processing
  2. Verify GDAL installation:

    ogr2ogr --version
    

Data Processing

The project uses ogr2ogr to convert Natural Earth's country boundaries from Shapefile to GeoJSON format, with the following features:

  • Coordinate precision set to 6 decimal places
  • Geometry validation enabled (-makevalid):
    • Fixes self-intersecting polygons
    • Corrects ring orientation
    • Removes duplicate vertices
    • Ensures geometric validity for better compatibility with GIS tools
  • Selected fields:
    • name: Common name of the country (from admin field)
    • ISO3166-1-Alpha-2: Two-letter ISO country code (from iso_a2 field)
    • ISO3166-1-Alpha-3: Three-letter ISO country code (from iso_a3 field)

To process the data:

make data

This will:

  1. Download the Natural Earth countries dataset
  2. Convert it to GeoJSON format with the specified settings
  3. Save the result in data/countries.geojson

License

All data is licensed under the Open Data Commons Public Domain Dedication and License.

Note that the original data from Natural Earth is public domain. While no credit is formally required a link back or credit to Natural Earth, Lexman and the Open Knowledge Foundation is much appreciated.

All source code is licenced under the MIT licence.