Skip to content

Instantly share code, notes, and snippets.

from openpyxl import Workbook
import os
COLUMNS = [
'Name', 'Data Lead', 'Description', 'Date Obtained', 'Time Period of Content Date', 'Publication Date',
'URL', 'Contact', 'Processing Notes', 'Keywords', 'Relative Path', 'Absolute Path'
]
def parse_readme(f):
@nikmolnar
nikmolnar / convert_grid.py
Created June 3, 2015 17:43
This script converts from a simple binary elevation format to ArcASCII.
"""
This script converts from a simple binary elevation format to ArcASCII. The format of the binary file is:
Offset Type Description
-----------------------------
0 uint Grid width
4 uint Grid height
8 float* Elevation values as floats in row-major order from lower-left to upper-right.
"""
@nikmolnar
nikmolnar / render_geotiff.py
Last active March 17, 2016 15:56
Simple example of rendering a GeoTIFF using the mapnik RasterSymbolizer
import mapnik
m = mapnik.Map(600, 600)
m.srs = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
rs = mapnik.RasterSymbolizer()
# COLORIZER_DISCRETE is a binned/classified rendere. Other options are COLORIZER_LINEAR (stretched) and
# COLORIZER_EXACT (unique)
rs.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color(0, 0, 0, 0))
@nikmolnar
nikmolnar / databasin_webhook.php
Last active November 9, 2015 03:26
Example PHP code for handling a webhook callback from Data Basin
<?php
$SECRET_KEY = "<secret key here>";
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function is_valid($secret, $value, $salt, $signature) {
$verify = base64url_encode(hash_hmac("sha1", $value, sha1($salt . $secret, true), true));
return $signature === $verify;
@nikmolnar
nikmolnar / netcdf_for_databasin.py
Last active October 20, 2015 20:53
This script takes a directory of NetCDF datasets and a single JSON style file and creates one ZIP archive per dataset, ready to upload to Data Basin.
"""
This script takes a directory of NetCDF datasets and a single JSON style file and creates one ZIP archive
per dataset, ready to upload to Data Basin.
"""
import json
import os
import sys
from zipfile import ZipFile, ZIP_DEFLATED
#!C:\Users\nik\Documents\environments\databasin_web\Scripts\python2.7.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'celery==3.1.17','console_scripts','celery'
__requires__ = 'celery==3.1.19'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('celery==3.1.19', 'console_scripts', 'celery')()
)
@nikmolnar
nikmolnar / databasin_client_example.py
Created December 2, 2015 01:22
Example of importing a NetCDF dataset with the Data Basin client library.
from databasin.client import Client
c = Client()
c.login('user', 'pass')
# Package must have complete metadata and style necessary for one-step import
dataset = c.import_netcdf_dataset('/path/to/netcdf_with_metadata_and_style.zip')
# One-step imports are private by default
dataset.make_public()

Keybase proof

I hereby claim:

  • I am nikmolnar on github.
  • I am nikmolnar (https://keybase.io/nikmolnar) on keybase.
  • I have a public key whose fingerprint is 183C 6E34 83E2 035C 2BE3 9A75 F3D6 201C 27A6 6A6C

To claim this, I am signing this object:

@nikmolnar
nikmolnar / settings_1_8.py
Created March 24, 2016 01:35
Django 1.8 Settings
"""
Django settings for untitled1 project.
Generated by 'django-admin startproject' using Django 1.8.10.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
@nikmolnar
nikmolnar / settings_1_9.py
Created March 24, 2016 01:37
Django 1.9 Settings
"""
Django settings for foo project.
Generated by 'django-admin startproject' using Django 1.9.4.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/