From bd2c6e857ae00b3df208280e81f4f7e7a9a503dd Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Sun, 5 Jun 2016 20:21:36 +0100 Subject: [PATCH] imagery: NEW add za_ngi_topo --- .../files/default/za_ngi_250k_prepare_vrt.py | 28 +++++++++++++ .../files/default/za_ngi_50k_prepare_vrt.py | 32 ++++++++++++++ cookbooks/imagery/recipes/za_ngi_topo.rb | 42 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 cookbooks/imagery/files/default/za_ngi_250k_prepare_vrt.py create mode 100644 cookbooks/imagery/files/default/za_ngi_50k_prepare_vrt.py create mode 100644 cookbooks/imagery/recipes/za_ngi_topo.rb diff --git a/cookbooks/imagery/files/default/za_ngi_250k_prepare_vrt.py b/cookbooks/imagery/files/default/za_ngi_250k_prepare_vrt.py new file mode 100644 index 000000000..8405e59be --- /dev/null +++ b/cookbooks/imagery/files/default/za_ngi_250k_prepare_vrt.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# The MIT License (MIT) +# Copyright (c) 2016 Adrian Frith (htonl) +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import sys, os, subprocess, glob, csv + +tiffdir = 'source' +coldir = 'colvrts' +finaldir = 'vrts' + +reader = csv.reader(open('ngi-250k-sheet-edges.csv')) +next(reader) #discard header row + +for row in reader: + sheet = row[0] + + orfile = '%s/%s' % (tiffdir, row[1]) + colfile = '%s/%s.vrt' % (coldir, sheet) + trimfile = '%s/%s.vrt' % (finaldir, sheet) + + (west, south, east, north) = map(float, row[2:]) + + print('gdal_translate -expand rgba -of VRT %s %s' % (orfile, colfile)) + print('gdalwarp -tps -r cubicspline -s_srs EPSG:4326 -t_srs EPSG:3857 -te %f %f %f %f -of VRT %s %s' % (west, south, east, north, colfile, trimfile)) diff --git a/cookbooks/imagery/files/default/za_ngi_50k_prepare_vrt.py b/cookbooks/imagery/files/default/za_ngi_50k_prepare_vrt.py new file mode 100644 index 000000000..82312520f --- /dev/null +++ b/cookbooks/imagery/files/default/za_ngi_50k_prepare_vrt.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# The MIT License (MIT) +# Copyright (c) 2016 Adrian Frith (htonl) +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import sys, os, subprocess, glob, csv + +tiffdir = 'source' +coldir = 'colvrts' +finaldir = 'vrts' + +reader = csv.reader(open('ngi-50k-sheet-edges.csv')) +next(reader) #discard header row + +for row in reader: + sheet = row[0] + dsq = sheet[:4] + +# if not dsq in ['3121', '3120']: +# continue + + orfile = '%s/%s' % (tiffdir, row[1]) + colfile = '%s/%s.vrt' % (coldir, sheet) + trimfile = '%s/%s.vrt' % (finaldir, sheet) + + (west, south, east, north) = map(float, row[2:]) + + print('gdal_translate -expand rgba -of VRT %s %s' % (orfile, colfile)) + print('gdalwarp -r cubicspline -t_srs EPSG:3857 -te %f %f %f %f -of VRT %s %s' % (west, south, east, north, colfile, trimfile)) diff --git a/cookbooks/imagery/recipes/za_ngi_topo.rb b/cookbooks/imagery/recipes/za_ngi_topo.rb new file mode 100644 index 000000000..9bfac98c8 --- /dev/null +++ b/cookbooks/imagery/recipes/za_ngi_topo.rb @@ -0,0 +1,42 @@ +# +# Cookbook Name:: imagery +# Recipe:: za-ngi-topo +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "imagery" + +imagery_site "topo.openstreetmap.org.za" do + title "OpenStreetMap - NGI - Topographic Series" + aliases ["topo.osm.org.za"] + bbox [[16.23, -35.12], [,33.18, -22.1]] +end + +imagery_layer "za_ngi_topo_250k" do + site "topo.openstreetmap.org.za" + title "NGI Topo 250k" + projection "EPSG:3857" + source "/data/imagery/za/ngi-250k/ngi-topo-250k-combined.vrt" + copyright "State Copyright © 1996–2010 Chief Directorate: National Geo-spatial Information" +end + +imagery_layer "za_ngi_topo_50k" do + site "topo.openstreetmap.org.za" + title "NGI Topo 50k" + projection "EPSG:3857" + source "/data/imagery/za/ngi-50k/ngi-topo-50k-combined.vrt" + copyright "State Copyright © 1996–2013 Chief Directorate: National Geo-spatial Information" +end -- 2.43.2