4

I would like to know the file formats of the following files data files in Matplotlib Basemap toolkit

  • countries*.dat
  • countriesmeta*.dat
  • gshhs*.dat
  • rivers*.dat
  • riversmeta*.dat
  • states*.dat
  • statesmeta*.dat

Also I would like to know if there are tools available to manipulate these files.

bmu
  • 35,119
  • 13
  • 91
  • 108
Andy Stow Away
  • 649
  • 1
  • 8
  • 17

1 Answers1

2

I have just experimented a bit:

"gshhs_c.dat" is a binary file containing a long list of lon,lat points of all coasts as single precision 32b floating point numbers:

lon1,lat1, lon2,lat2, ..., lonn,latn.

the file "gshhsmeta_c.dat" contains the connectivity information of these points:

1, area, numpoints, limit_south, limit_north, startbyte, numbytes, id-(E/W crosses dateline east or west)

In my case the first entry (eurasia) is:

1 50654050.7558 1004   1.26950  77.71625 0 8032 0-E

We can read and plot it with:

import numpy as np
import matplotlib.pyplot as plt

binfile = open('gshhs_c.dat','rb')
data = np.fromfile(binfile,'<f4')
data = data.reshape(len(data)/2,2)
plt.plot(data[:1004,0],data[:1004,1])
plt.show()

The other files should have more or less the same format because they are read in by the same function.

EDIT: some basemap versions don't have the dateline crossing. The file format is essentially the same

Matthias123
  • 882
  • 9
  • 15