Read and convert grids from KMS.
Project description
kmsgrid is a small utility that makes it easy to work with the various datum grid files made by KMS/DTU for the transformation library TrLib (KSMTrans).
Using kmsgrid
kmsgrid is both a Python module and a command line utility.
Command line
The kmsgrid command line utility is made up of two sub-utilities: “info” and “translate”.
$ kmsgrid --help usage: kmsgrid [-h] {translate,info,help} ... Read binary grid files from trlib. optional arguments: -h, --help show this help message and exit Subcommands: Valid subcommands {translate,info,help} additional help
Info
The info sub-command is used for getting information about a grid. Either information about the whole file can be presented on screen or information about a single point.
$ kmsgrid info --help usage: kmsgrid info [-h] [--datum] [--mode] [--point I J] grid positional arguments: grid Binary grid file. optional arguments: -h, --help show this help message and exit --point I J Value(s) at a grid index (I,J). Prints values from all dimensions of the grid.d
Get information about a 3D grid:
$ kmsgrid info nkgrf03vel.01 filename: nkgrf03vel.01 dimensions: 3 latmin: 53.0 latmax: 73.0 lonmin: 3.0 lonmax: 40.0 data[0].min: -0.96 data[0].max: 1.75 data[0].mean: 0.204704 data[1].min: -1.65 data[1].max: 0.86 data[1].mean: -0.194318 data[2].min: -0.72 data[2].max: 9.97 data[2].mean: 2.34521 dlat: 0.0833333333333 dlon: 0.166666666667 nlat: 241 nlon: 223 datum: ITRF19yy/20yy mode: KMSGrid tabletype: 3D
Values in a single grid cell at index 55,12:
$ kmsgrid info Geoids2013\nkgrf03vel.01 --point 55 12 0.649999976158 -0.200000002980 -0.720000028610
Translate
The translate sub-command work similar to gdal_translate in that it translates from one format to another. In fact it uses GDAL behind the scenes to convert KMS grids to more standardized formats. Only a small subset of the available GDAL formats can be used with kmsgrid.
$ kmsgrid translate --help usage: kmsgrid translate [-h] [--driver DRIVER] [--creation_options CREATION_OPTIONS] grid out dimensions [dimensions ...] positional arguments: grid Binary grid file. out Name of output grid file dimensions List of dimensions in output grid, e.g. "1 2" optional arguments: -h, --help show this help message and exit --driver DRIVER, -d DRIVER Output format. Currently supports: GTiff, GTX, NTv2 --creation_options CREATION_OPTIONS, -co CREATION_OPTIONS Additional GDAL creation options. Has to be formatted like "PARAM1=foo PARAM2=bar".
Translate the DVR90 geoid grid to GTX format:
$ kmsgrid translate --driver=GTX dvr90g2013.01 dvr90.gtx 1
Translate the NKG velocity model to two grids, one for the horizontal part in NTv2 format and one for the vertical part in GTX format:
$ kmsgrid translate –driver=NTv2 nkgrf03vel.01 nkgrf03vel_xy.gsb 1 2 $ kmsgrid translate –driver=GTX nkgrf03vel.01 nkgrf03vel_z.gtx 3
API
This is just a simple example of how the API can be used:
from kmsgrid import KMSGrid # print some useful info grid = KMSGrid('dvr90g.2013.01') print('Dimensions of grid: {0}'.format(grid.dims)) print('Datum of grid: {0}'.format(grid.datum)) print('Bounding boix of grid: [{0}, {1}, {2}, {3}'.format( grid.lonmix, grid.latmin, grid.lonmax, grid.latmax)) # convert grid to a TIFF file grid.export(filename='dvr90.tif', dimensions=1)
Installing
Clone the repository from GitHub and run the following command in the local repository folder:
$ python setup.py install
Alternatively kmsgrid can be installed from the Python Package Index with pip:
pip install kmsgrid
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kmsgrid-1.0.0.linux-x86_64.tar.gz
.
File metadata
- Download URL: kmsgrid-1.0.0.linux-x86_64.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69a2f5d8cd10df33ae899ecc2ce7077d3db4b49d2f621ea7fdd0a0ab151eadae |
|
MD5 | 4a065955820d89951ea8fe96caa5a8ab |
|
BLAKE2b-256 | ad2887c63b72c91e8f2eead23c2ceedd650b359341ce8cddb947d2ff2e6ab030 |
File details
Details for the file kmsgrid-1.0.0-py2.7.egg
.
File metadata
- Download URL: kmsgrid-1.0.0-py2.7.egg
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1539245f6e831dd4c633d690f84ced261c72c7cdab4917a29538186a56955b29 |
|
MD5 | 7e16d9a52cff874a3ce05dce58ad5ce6 |
|
BLAKE2b-256 | 18d1a9973a0150866e581a747469b084b18bb763d5738f9cb35a736c614e6fb8 |