collapse

* Forum Staff

PeterC admin PeterC
Administrator
admin webmasterOPS
Administrator

Author Topic: Notes on tiling using free software  (Read 264 times)

PeterC

  • Administrator
  • Member
  • *****
  • Posts: 382
  • Passionate about my one-place study
    • View Profile
    • Holywell-cum-Needingworth History
Notes on tiling using free software
« on: 21 December 2016, 19:28:04 »
THIS IS JUST ROUGH NOTES FOR NOW

Given a GeoTiff file C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818.tif
that is to become tiles called: 00967 Hunts XIX_14 1885

My question 20/12/16 https://gis.stackexchange.com/questions/222114/output-of-gdal2tiles-has-black-edges-round-it

Stage 0? Do something to get rid of Black edges (not found correct answer yet)
========
https://gis.stackexchange.com/questions/154387/how-do-i-convince-gdal2tiles-to-output-pngs-with-transparency
NOT the answer: gdal_translate -mask 4 x y  as there is no Band 4 (alpha)
see gdalinfo -stats "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818.tif" > C:\Temp\114489818tif.txt

NOT the answer
gdal_translate -a_nodata 255 "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818.tif" "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818_NoD.tif"

NOT the answer
gdalwarp -srcnodata 255 -dstalpha "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818.tif" "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818_ALPH5.tif"
gdal2tiles.py --profile=mercator –-resampling=lanczos –-s_srs=EPSG:27700 -z 13-14 "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818_ALPH5.tif" "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\working\00967 Hunts XIX_14 1885_ALPH5"
gdalinfo -stats "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818_ALPH5.tif" > C:\Temp\114489818tif_ALPH5.txt

(Double hyphen precedes options when they are written in full)

Stage 1 Prepare Tiles into working directory (LET IT DO ITS STUFF for about 20 minutes!!!)
=======
If you are re-running then delete the working directory - it must not exist
In production have Zoom 13-19
gdal2tiles.py --profile=mercator –-resampling=lanczos –-s_srs=EPSG:27700 --srcnodata=255 -z 13-14 "C:\Users\Peter_2\Documents\Mapping\Data\NLS 3xHunts XIX.14\114489818.tif" "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\working\00967 Hunts XIX_14 1885"
You can check the output by opening openlayers.html, or
gdalinfo -stats "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\working\00967 Hunts XIX_14 1885X\14\8192\10996.png" > C:\Temp\10996pngX.txt

Issue is these are in /{z}/{x}/{-y} (tms) format so they need to be flipped to be displayed in tileserver

Stage 2 Flip the tiles into their final place (allow console logging and stdout print to output, but ignore it)
=======
2a) Tiles from gdal2tiles in tms format --> MBTiles (MapBoxTiles) - which must not exist
python C:\Users\Peter_2\Documents\Mapping\Software\mbutil-master\mb-util --scheme=tms "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\working\00967 Hunts XIX_14 1885" "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\working\00967 Hunts XIX_14 1885.mbtiles"

2b) MBTiles --> Tiles in xyz format for tileserver
python C:\Users\Peter_2\Documents\Mapping\Software\mbutil-master\mb-util --scheme=xyz "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\working\00967 Hunts XIX_14 1885.mbtiles" "C:\Users\Peter_2\Documents\Mapping\Software\M4OPS\OPS\HcN Holywell-cum-Needingworth\AA Not to FTP\00967 Hunts XIX_14 1885" >> "C:\Temp\00967 Hunts XIX_14 1885-output.txt"

Stage 3 FTP tiles, and amend LayerDefs_Other, upload, compile

================================

Tileserver-php has limits - https://github.com/klokantech/tileserver-php
Tiles produced by open-source GDAL2Tiles or MapTiler and tiles in .mbtiles files can be easily converted to required structure (XYZ with top-left origin and metadata.json file). The open-source utility mbutil produces exactly the required format.
https://github.com/mapbox/mbutil
https://gis.stackexchange.com/questions/50646/is-there-any-way-to-use-mbutil-on-windows

======================================================

Notes on installation

OSGeo4W
https://trac.osgeo.org/osgeo4w/64 Do Express Install (of GDAL only) first, then rerun and add Python, GDAL/Python bindings, and Pythn/windows bindings
Run OSGeo4W Shell (batch file) and enter commands

GDAL2Tiles http://www.gdal.org/gdal2tiles.html    https://wiki.openstreetmap.org/wiki/GDAL2Tiles (useful)
Installation (Windows)
An easy way to get GDAL2tiles is to use the OSGeo4W installer and install all GDAL-packages and the Python-package. After installation, run the OSGeo4W-shell using the desktop icon or, equivalently, run C:\OSGeo4W\bin\o4w_env.bat, in order to setup the necessary environment variables.

OR (GUI version)
MapSlicer https://wiki.osgeo.org/wiki/MapSlicer https://github.com/geopython/mapslicer
On OSGEO Live disc:  https://live.osgeo.org/en/overview/mapslicer_overview.html

https://alastaira.wordpress.com/2011/07/11/maptiler-gdal2tiles-and-raster-resampling/ useful about maptiler and gdal2tiles (2011)
about dependencies, parameters etc

??https://pythongisandstuff.wordpress.com/2016/04/13/installing-gdal-ogr-for-python-on-windows/

Python and gdal are all in C:\OSGeo4W64\bin

echo %PYTHONPATH% > x.txt
PYTHONPATH is C:\PYTHON27;C:\PYTHON27\DLLs;C:\PYTHON27\LIB;C:\PYTHON27\LIB\LIB-TK;C:\MapServer\ms4w\Apache\cgi-bin
set PYTHONPATH=%PYTHONPATH%;C:\OSGeo4W64;C:\OSGeo4W64\bin;C:\OSGeo4W64\lib
and set GDAL_PAM_ENABLED=NO (no aux.xml)
ABOVE done in C:\Users\Peter_2\Documents\Mapping\Software\gdal\OSGeo.bat

In admin cmd: maybe done permanently
C:\OSGeo4W64\OSGeo4W.bat
assoc .py=Python.File
ftype Python.File=C:\OSGeo4W64\bin\pythonw.exe "%1" %*
=================

Tried Mapslicer, but there is an issue
https://github.com/geopython/mapslicer/issues/21 "unpack requires a string argument of length 8"
Notes on installation
Misleading: Or depending on the installation method there should be a program icon in the programs menu
Why the iss (windows installation file)?

https://live.osgeo.org/en/quickstart/mapslicer_quickstart.html
mapslicer needs python, gdal, wxpython
From this I have GDAL 2.1.2; Python 2.7.5 64 bit
https://wxpython.org/what.php >> at https://wxpython.org/download.php#msw download wxPython3.0-win64-3.0.2.0-py27.exe
No entry of Python 2.7 in Registry Be sure to put in PYTHONPATH
Unable to execute file C:\Put a directory on PYTHONPATH here\python.exe
no module named py2.exe

=============================

For Python

https://www.learnpython.org/en/Hello%2C_World%21
https://docs.python.org/2.7/contents.html
https://docs.python.org/2.7/faq/windows.html?highlight=path


 

mapping4ops.org is a Society for One-Place Studies project supported by Grassroots Giving from Skipton Building Society
Glossary | BBCodes | Feedback