<commit_before>## Working with geospatial data formats

Geospatial data comes in a huge variety of formats. Understanding the formats you might find in the wild, how to recognise and inspect them are key skills for geospatial analysis at the command-line.

### The GDAL toolkit

The [Geospatial Data Abstraction Library (GDAL/OGR)](http://www.gdal.org/) is a set of command-line utilities for working with a wide range of different raster and vector geospatial formats.

The tools are already installed in this lesson, but if you ever need to install them on your own machine you can use:

#### OSX

> brew install gdal

#### Linux

> sudo apt-get install gdal-bin

### Getting basic information about a geospatial data file

The `ogrinfo` command from the GDAL toolkit allows us to find out what a geospatial vector data file contains.

The `~/data` directory contains 10m resolution countries data from [Natural Earth](www.naturalearthdata.com). If we want to know what layers a file contains, we can run `ogrinfo` like so:

```
ogrinfo filepath
```

For example:

```
$ ogrinfo data/ne_10m_admin_0_countries.shp
INFO: Open of `data/ne_10m_admin_0_countries.shp'
      using driver `ESRI Shapefile' successful.
1: ne_10m_admin_0_countries (Polygon)
```

`ogrinfo` has printed a message telling us that it successfully read the file, followed by a numbered list of layers in the file. In this case, there is only a single layer, `ne_10m_admin_0_countries`, which is a [polygon]().

The same `ogrinfo` command will work for the `.shx` and `.dbf` format files, but it won't work for the `.cpg` or `.prj` files. You can get a full list of the formats `ogrinfo` can read [here](http://www.gdal.org/ogr_formats.html).<commit_msg>Add man, link to ogrinfo<commit_after>## Working with geospatial data formats

Geospatial data comes in a huge variety of formats. Understanding the formats you might find in the wild, how to recognise and inspect them are key skills for geospatial analysis at the command-line.

### The GDAL toolkit

The [Geospatial Data Abstraction Library (GDAL/OGR)](http://www.gdal.org/) is a set of command-line utilities for working with a wide range of different raster and vector geospatial formats.

**The tools are already installed in this lesson**, but if you ever need to install them on your own machine you can use:

#### OSX

> brew install gdal

#### Linux

> sudo apt-get install gdal-bin

### Getting basic information about a geospatial data file

The [`ogrinfo`](http://www.gdal.org/ogrinfo.html) command from the GDAL toolkit allows us to find out what a geospatial vector data file contains.

Use `man ogrinfo` to get detailed help for `ogrinfo` at the command-line.

The `~/data` directory contains 10m resolution countries data from [Natural Earth](www.naturalearthdata.com). If we want to know what layers a file contains, we can run `ogrinfo` like so:

```
ogrinfo filepath
```

For example:

```
$ ogrinfo data/ne_10m_admin_0_countries.shp
INFO: Open of `data/ne_10m_admin_0_countries.shp'
      using driver `ESRI Shapefile' successful.
1: ne_10m_admin_0_countries (Polygon)
```

`ogrinfo` has printed a message telling us that it successfully read the file, followed by a numbered list of layers in the file. In this case, there is only a single layer, `ne_10m_admin_0_countries`, which is a [polygon]().

The same `ogrinfo` command will work for the `.shx` and `.dbf` format files, but it won't work for the `.cpg` or `.prj` files. You can get a full list of the formats `ogrinfo` can read [here](http://www.gdal.org/ogr_formats.html).
{'fraction_non_alphanumeric': 0.08109619686800895, 'fraction_numerical': 0.008389261744966443, 'mean_word_length': 4.486196319018405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 7, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '814963', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1053, 'n_words': 503}