Skip to content

Instantly share code, notes, and snippets.

View IReese's full-sized avatar

Ian Reese IReese

  • Land Information New Zealand (LINZ)
  • Wellington, New Zealand
View GitHub Profile
#!/bin/bash
xmlfile=/gebco_template.xml
base_file=$1
export_dir=
export_png=
export_xml=
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map background-color="#2a383e" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<Style comp-op="color-dodge" filter-mode="first" name="gebco2019webmercator2">
<Rule>
<RasterSymbolizer default-color="rgba(0, 0, 0, 0)" default-mode="linear" scaling="bilinear">
<stop color="#222222" value="0" />
<stop color="#ebebeb" value="255" />
</RasterSymbolizer>
#!/bin/bash
FILE_IN=$1
TILE_NUM=$2
file_name=$( basename $FILE_IN | sed 's/.tif//' )
function tiff_dims() {
EXTENT=$(tiffinfo "$1" | grep 'Image Width:' | sed 's/Image Width://' | sed 's/Image Length://' )
#!/bin/bash
FILE_IN=$1
file_name=$( basename $FILE_IN | sed 's/.tif//' )
function gdal_extent_gdalwarp_te() {
if [ -z "$1" ]; then
echo "Missing arguments. Syntax:"
echo " gdal_extent <input_raster>"
#!/bin/bash
FILE_IN=$1
function gdal_get_proj() {
PROJ4=$(gdalinfo -nomd $1 |\
grep "EXTENSION" |\
sed 's/EXTENSION//g' |\
sed 's/PROJ4//g' |\
#!/bin/bash
#Run script from within package directory. Be sure XML file is stored in this directory.
#Download data here
#wget https://www.bodc.ac.uk/data/open_download/gebco/GEBCO_15SEC/zip/
#unzip GEBCO_2019.zip
#gdal_translate -of GTiff GEBCO_2019/GEBCO_2019.nc GEBCO_2019.tif
#gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3857 GEBCO_2019.tif GEBCO_2019_webmer.tif
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map background-color="#2a383e" srs="PROJECTION_STRING">
<Style comp-op="color-dodge" filter-mode="first" name="gebco2019webmercator2">
<Rule>
<RasterSymbolizer default-color="rgba(0, 0, 0, 0)" default-mode="linear" scaling="bilinear">
<stop color="#222222" value="0" />
<stop color="#ebebeb" value="255" />
</RasterSymbolizer>
#!/bin/bash
A_json=./world_all_test.json
B_json=./gizzy_full_extent_test.json
#extract coord for world poly
Aulx=$( jq .coordinates[0][0][0] $A_json )
Auly=$( jq .coordinates[0][0][1] $A_json )
{
"type": "Polygon",
"coordinates": [
[
[-180.0000, 90.0000],
[-180.0000, -90.0000],
[180.0000, -90.0000],
[180.0000, 90.0000],
[-180.0000, 90.0000]
]
{
"type": "Polygon",
"coordinates": [
[
[
177.4832659,
-37.617147
],
[
177.5549797,