mapchete 0.30__tar.gz → 0.32__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. home/ungarj/virtualenvs/p3/bin/mapchete +12 -0
  2. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/__init__.py +1 -1
  3. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/__init__.cpython-35.pyc +0 -0
  4. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/_core.cpython-35.pyc +0 -0
  5. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/_processing.cpython-35.pyc +0 -0
  6. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/_timer.cpython-35.pyc +0 -0
  7. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/_validate.cpython-35.pyc +0 -0
  8. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/config.cpython-35.pyc +0 -0
  9. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/errors.cpython-35.pyc +0 -0
  10. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/index.cpython-35.pyc +0 -0
  11. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/log.cpython-35.pyc +0 -0
  12. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/tile.cpython-35.pyc +0 -0
  13. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/__pycache__/validate.cpython-35.pyc +0 -0
  14. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/_core.py +1 -1
  15. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/_processing.py +38 -27
  16. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/__init__.cpython-35.pyc +0 -0
  17. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/main.cpython-35.pyc +0 -0
  18. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/__pycache__/utils.cpython-35.pyc +0 -0
  19. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/__init__.cpython-35.pyc +0 -0
  20. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/convert.cpython-35.pyc +0 -0
  21. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/create.cpython-35.pyc +0 -0
  22. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/execute.cpython-35.pyc +0 -0
  23. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/formats.cpython-35.pyc +0 -0
  24. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/index.cpython-35.pyc +0 -0
  25. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/processes.cpython-35.pyc +0 -0
  26. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/__pycache__/serve.cpython-35.pyc +0 -0
  27. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/convert.py +27 -2
  28. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/execute.py +0 -0
  29. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/cli/default/processes.py +31 -0
  30. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/serve.py +0 -0
  31. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/main.py +0 -0
  32. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/utils.py +1 -1
  33. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/__init__.cpython-35.pyc +0 -0
  34. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/clip.cpython-35.pyc +0 -0
  35. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/contours.cpython-35.pyc +0 -0
  36. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/commons/__pycache__/hillshade.cpython-35.pyc +0 -0
  37. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/contours.py +12 -6
  38. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/hillshade.py +27 -13
  39. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/config.py +74 -60
  40. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/__pycache__/__init__.cpython-35.pyc +0 -0
  41. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/__pycache__/base.cpython-35.pyc +0 -0
  42. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/__pycache__/drivers.cpython-35.pyc +0 -0
  43. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/__init__.cpython-35.pyc +0 -0
  44. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/geojson.cpython-35.pyc +0 -0
  45. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/gtiff.cpython-35.pyc +0 -0
  46. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/mapchete_input.cpython-35.pyc +0 -0
  47. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/png.cpython-35.pyc +0 -0
  48. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/png_hillshade.cpython-35.pyc +0 -0
  49. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/raster_file.cpython-35.pyc +0 -0
  50. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/tile_directory.cpython-35.pyc +0 -0
  51. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/formats/default/__pycache__/vector_file.cpython-35.pyc +0 -0
  52. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/gtiff.py +113 -32
  53. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/png_hillshade.py +4 -6
  54. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/__init__.cpython-35.pyc +0 -0
  55. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/_geometry_operations.cpython-35.pyc +0 -0
  56. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/_json.cpython-35.pyc +0 -0
  57. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/_misc.cpython-35.pyc +0 -0
  58. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/_path.cpython-35.pyc +0 -0
  59. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/raster.cpython-35.pyc +0 -0
  60. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/io/__pycache__/vector.cpython-35.pyc +0 -0
  61. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/_geometry_operations.py +1 -1
  62. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/raster.py +60 -35
  63. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/__init__.py +57 -0
  64. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/__pycache__/__init__.cpython-35.pyc +0 -0
  65. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/__pycache__/contours.cpython-35.pyc +0 -0
  66. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/__pycache__/convert.cpython-35.pyc +0 -0
  67. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/__pycache__/hillshade.cpython-35.pyc +0 -0
  68. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/contours.py +116 -0
  69. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/processes/convert.py +6 -2
  70. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/examples/__pycache__/__init__.cpython-35.pyc +0 -0
  71. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/examples/__pycache__/example_process.cpython-35.pyc +0 -0
  72. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/hillshade.py +104 -0
  73. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/static/__pycache__/__init__.cpython-35.pyc +0 -0
  74. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/static/__pycache__/process_template.cpython-35.pyc +0 -0
  75. home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/validate.py +232 -0
  76. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.32-py3.5.egg-info}/PKG-INFO +6 -6
  77. {mapchete-0.30/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.32-py3.5.egg-info}/SOURCES.txt +3 -1
  78. {mapchete-0.30/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.32-py3.5.egg-info}/entry_points.txt +2 -0
  79. {mapchete-0.30/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.32-py3.5.egg-info}/requires.txt +1 -1
  80. mapchete-0.30/README.rst +0 -198
  81. mapchete-0.30/mapchete/cli/default/processes.py +0 -50
  82. mapchete-0.30/mapchete/static/__init__.py +0 -0
  83. mapchete-0.30/mapchete.egg-info/PKG-INFO +0 -219
  84. mapchete-0.30/setup.cfg +0 -10
  85. mapchete-0.30/setup.py +0 -88
  86. mapchete-0.30/test/test_cli.py +0 -822
  87. mapchete-0.30/test/test_commons.py +0 -97
  88. mapchete-0.30/test/test_config.py +0 -260
  89. mapchete-0.30/test/test_deprecated.py +0 -40
  90. mapchete-0.30/test/test_errors.py +0 -309
  91. mapchete-0.30/test/test_formats.py +0 -160
  92. mapchete-0.30/test/test_formats_geojson.py +0 -121
  93. mapchete-0.30/test/test_formats_geotiff.py +0 -315
  94. mapchete-0.30/test/test_formats_png.py +0 -107
  95. mapchete-0.30/test/test_formats_png_hillshade.py +0 -126
  96. mapchete-0.30/test/test_formats_tiledir_input.py +0 -189
  97. mapchete-0.30/test/test_index.py +0 -193
  98. mapchete-0.30/test/test_io.py +0 -871
  99. mapchete-0.30/test/test_log.py +0 -17
  100. mapchete-0.30/test/test_mapchete.py +0 -527
  101. mapchete-0.30/test/test_processes.py +0 -87
  102. mapchete-0.30/test/test_timer.py +0 -26
  103. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/_timer.py +0 -0
  104. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/_validate.py +0 -0
  105. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/__init__.py +0 -0
  106. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/__init__.py +0 -0
  107. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/create.py +0 -0
  108. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/formats.py +0 -0
  109. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/cli/default/index.py +0 -0
  110. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/__init__.py +0 -0
  111. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/commons/clip.py +0 -0
  112. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/errors.py +0 -0
  113. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/__init__.py +0 -0
  114. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/base.py +0 -0
  115. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/__init__.py +0 -0
  116. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/geojson.py +0 -0
  117. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/mapchete_input.py +0 -0
  118. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/png.py +0 -0
  119. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/raster_file.py +0 -0
  120. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/tile_directory.py +2 -2
  121. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/default/vector_file.py +0 -0
  122. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/formats/drivers.py +0 -0
  123. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/index.py +0 -0
  124. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/__init__.py +0 -0
  125. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/_json.py +0 -0
  126. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/_misc.py +0 -0
  127. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/_path.py +0 -0
  128. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/io/vector.py +0 -0
  129. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/log.py +0 -0
  130. {mapchete-0.30/mapchete/processes → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/processes/examples}/__init__.py +0 -0
  131. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/processes/examples/example_process.py +0 -0
  132. {mapchete-0.30/mapchete/processes/examples → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete/static}/__init__.py +0 -0
  133. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/index.html +0 -0
  134. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/mapchete_template.mapchete +0 -0
  135. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/static/process_template.py +0 -0
  136. {mapchete-0.30 → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages}/mapchete/tile.py +0 -0
  137. {mapchete-0.30/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.32-py3.5.egg-info}/dependency_links.txt +0 -0
  138. {mapchete-0.30/mapchete.egg-info → home/ungarj/virtualenvs/p3/lib/python3.5/site-packages/mapchete-0.32-py3.5.egg-info}/top_level.txt +0 -0
@@ -0,0 +1,12 @@
1
+ #!/home/ungarj/virtualenvs/p3/bin/python
2
+ # EASY-INSTALL-ENTRY-SCRIPT: 'mapchete==0.32','console_scripts','mapchete'
3
+ __requires__ = 'mapchete==0.32'
4
+ import re
5
+ import sys
6
+ from pkg_resources import load_entry_point
7
+
8
+ if __name__ == '__main__':
9
+ sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10
+ sys.exit(
11
+ load_entry_point('mapchete==0.32', 'console_scripts', 'mapchete')()
12
+ )
@@ -7,7 +7,7 @@ from mapchete._timer import Timer
7
7
 
8
8
 
9
9
  __all__ = ['open', 'count_tiles', 'Mapchete', 'MapcheteProcess', 'Timer']
10
- __version__ = "0.30"
10
+ __version__ = "0.32"
11
11
 
12
12
 
13
13
  logger = logging.getLogger(__name__)
@@ -11,7 +11,7 @@ from mapchete.errors import MapcheteNodataTile
11
11
  from mapchete._processing import _run_on_single_tile, _run_area, ProcessInfo, TileProcess
12
12
  from mapchete.tile import count_tiles
13
13
  from mapchete._timer import Timer
14
- from mapchete._validate import validate_tile, validate_zooms
14
+ from mapchete.validate import validate_tile, validate_zooms
15
15
 
16
16
  logger = logging.getLogger(__name__)
17
17
 
@@ -13,7 +13,7 @@ from mapchete.config import get_process_func
13
13
  from mapchete.errors import MapcheteNodataTile, MapcheteProcessException
14
14
  from mapchete.io import raster
15
15
  from mapchete._timer import Timer
16
- from mapchete._validate import deprecated_kwargs
16
+ from mapchete.validate import deprecated_kwargs
17
17
 
18
18
  logger = logging.getLogger(__name__)
19
19
 
@@ -133,7 +133,7 @@ class TileProcess():
133
133
  in_affine=parent_tile.affine,
134
134
  out_tile=self.tile,
135
135
  resampling=self.config_baselevels["higher"],
136
- nodataval=self.output_reader.output_params["nodata"]
136
+ nodata=self.output_reader.output_params["nodata"]
137
137
  )
138
138
  # resample from children tiles
139
139
  elif baselevel == "lower":
@@ -150,16 +150,19 @@ class TileProcess():
150
150
  lower_tiles = [
151
151
  y for y in chain(*[x.get_children() for x in output_tiles])
152
152
  ]
153
- mosaic = raster.create_mosaic([
154
- (lower_tile, self.output_reader.read(lower_tile))
155
- for lower_tile in lower_tiles
156
- ])
153
+ mosaic = raster.create_mosaic(
154
+ [
155
+ (lower_tile, self.output_reader.read(lower_tile))
156
+ for lower_tile in lower_tiles
157
+ ],
158
+ nodata=self.output_reader.output_params["nodata"]
159
+ )
157
160
  process_data = raster.resample_from_array(
158
161
  in_raster=mosaic.data,
159
162
  in_affine=mosaic.affine,
160
163
  out_tile=self.tile,
161
164
  resampling=self.config_baselevels["lower"],
162
- nodataval=self.output_reader.output_params["nodata"]
165
+ nodata=self.output_reader.output_params["nodata"]
163
166
  )
164
167
  logger.debug((self.tile.id, "generated from baselevel", str(t)))
165
168
  return process_data
@@ -286,7 +289,9 @@ class MapcheteProcess(object):
286
289
  -------
287
290
  hillshade : array
288
291
  """
289
- return commons_hillshade.hillshade(elevation, self, azimuth, altitude, z, scale)
292
+ return commons_hillshade.hillshade(
293
+ elevation, self.tile, azimuth, altitude, z, scale
294
+ )
290
295
 
291
296
  def contours(
292
297
  self, elevation, interval=100, field='elev', base=0
@@ -361,6 +366,9 @@ class Executor():
361
366
  "init %s Executor with start_method %s and %s workers",
362
367
  self.multiprocessing_module, self.start_method, self.max_workers
363
368
  )
369
+ self._pool = self.multiprocessing_module.get_context(self.start_method).Pool(
370
+ self.max_workers
371
+ )
364
372
 
365
373
  def as_completed(
366
374
  self,
@@ -381,19 +389,23 @@ class Executor():
381
389
  "open multiprocessing.Pool and %s %s workers",
382
390
  self.start_method, self.max_workers
383
391
  )
384
- with self.multiprocessing_module.get_context(self.start_method).Pool(
385
- self.max_workers
386
- ) as pool:
387
- for finished_task in pool.imap_unordered(
388
- partial(_exception_wrapper, func, fargs, fkwargs),
389
- iterable,
390
- chunksize=chunksize
391
- ):
392
- yield finished_task
393
- logger.debug("closing %s and workers", pool)
394
- pool.close()
395
- pool.join()
396
- logger.debug("%s closed", pool)
392
+ for finished_task in self._pool.imap_unordered(
393
+ partial(_exception_wrapper, func, fargs, fkwargs),
394
+ iterable,
395
+ chunksize=chunksize
396
+ ):
397
+ yield finished_task
398
+
399
+ def __enter__(self):
400
+ """Enter context manager."""
401
+ return self
402
+
403
+ def __exit__(self, *args):
404
+ """Exit context manager."""
405
+ logger.debug("closing %s and workers", self._pool)
406
+ self._pool.close()
407
+ self._pool.join()
408
+ logger.debug("%s closed", self._pool)
397
409
 
398
410
 
399
411
  class FinishedTask():
@@ -526,12 +538,11 @@ def _run_multi(
526
538
  # also in "continue" mode in case there were updates at the baselevel
527
539
  overview_parents = set()
528
540
 
529
- with Timer() as t:
530
- executor = Executor(
531
- max_workers=workers,
532
- start_method=multiprocessing_start_method,
533
- multiprocessing_module=multiprocessing_module
534
- )
541
+ with Timer() as t, Executor(
542
+ max_workers=workers,
543
+ start_method=multiprocessing_start_method,
544
+ multiprocessing_module=multiprocessing_module
545
+ ) as executor:
535
546
 
536
547
  for i, zoom in enumerate(zoom_levels):
537
548
 
@@ -20,12 +20,20 @@ from mapchete.formats import (
20
20
  from mapchete.io import read_json, get_best_zoom_level
21
21
  from mapchete.io.vector import reproject_geometry
22
22
  from mapchete.tile import BufferedTilePyramid
23
- from mapchete._validate import validate_zooms
23
+ from mapchete.validate import validate_zooms
24
24
 
25
25
  logger = logging.getLogger(__name__)
26
26
  OUTPUT_FORMATS = available_output_formats()
27
27
 
28
28
 
29
+ def _validate_bidx(ctx, param, bidx):
30
+ if bidx:
31
+ try:
32
+ return list(map(int, bidx.split(",")))
33
+ except ValueError:
34
+ raise click.BadParameter("band indexes must be positive integer values")
35
+
36
+
29
37
  @click.command(help="Convert outputs or other geodata.")
30
38
  @utils.arg_input
31
39
  @utils.arg_output
@@ -38,6 +46,11 @@ OUTPUT_FORMATS = available_output_formats()
38
46
  type=click.Path(exists=True),
39
47
  help="Clip output by geometry"
40
48
  )
49
+ @click.option(
50
+ "--bidx",
51
+ callback=_validate_bidx,
52
+ help="Band indexes to copy."
53
+ )
41
54
  @click.option(
42
55
  "--output-pyramid",
43
56
  type=click.Choice(tilematrix._conf.PYRAMID_PARAMS.keys()),
@@ -83,6 +96,11 @@ OUTPUT_FORMATS = available_output_formats()
83
96
  default="cubic_spline",
84
97
  help="Resampling method used for overviews. (default: cubic_spline)"
85
98
  )
99
+ @click.option(
100
+ "--cog",
101
+ is_flag=True,
102
+ help="Write a valid COG. This will automatically generate verviews. (GTiff only)"
103
+ )
86
104
  @utils.opt_overwrite
87
105
  @utils.opt_verbose
88
106
  @utils.opt_no_pbar
@@ -99,6 +117,7 @@ def convert(
99
117
  point=None,
100
118
  wkt_geometry=None,
101
119
  clip_geometry=None,
120
+ bidx=None,
102
121
  output_pyramid=None,
103
122
  output_metatiling=None,
104
123
  output_format=None,
@@ -109,6 +128,7 @@ def convert(
109
128
  resampling_method=None,
110
129
  overviews=False,
111
130
  overviews_resampling_method=None,
131
+ cog=False,
112
132
  overwrite=False,
113
133
  logfile=None,
114
134
  verbose=False,
@@ -171,14 +191,19 @@ def convert(
171
191
  zoom_levels=zoom or input_info["zoom_levels"],
172
192
  scale_ratio=scale_ratio,
173
193
  scale_offset=scale_offset,
174
- resampling=resampling_method
194
+ resampling=resampling_method,
195
+ band_indexes=bidx
175
196
  )
176
197
 
177
198
  # assert all required information is there
178
199
  if mapchete_config["output"]["format"] is None:
179
200
  # this happens if input file is e.g. JPEG2000 and output is a tile directory
180
201
  raise click.BadOptionUsage("output-format", "Output format required.")
202
+ if mapchete_config["output"]["format"] == "GTiff":
203
+ mapchete_config["output"].update(cog=cog)
181
204
  output_type = OUTPUT_FORMATS[mapchete_config["output"]["format"]]["data_type"]
205
+ if bidx is not None:
206
+ mapchete_config["output"].update(bands=len(bidx))
182
207
  if mapchete_config["pyramid"] is None:
183
208
  raise click.BadOptionUsage("output-pyramid", "Output pyramid required.")
184
209
  elif mapchete_config["zoom_levels"] is None:
@@ -0,0 +1,31 @@
1
+ """CLI to list processes."""
2
+
3
+ import click
4
+ import logging
5
+
6
+ from mapchete.cli import utils
7
+ from mapchete.processes import process_names_docstrings
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ @click.command(help="List available processes.")
13
+ @click.option(
14
+ "--process_name", "-n", type=click.STRING, help="Print docstring of process."
15
+ )
16
+ @utils.opt_debug
17
+ def processes(process_name=None, docstrings=False, debug=False):
18
+ """List available processes."""
19
+ processes = process_names_docstrings(process_name=process_name)
20
+ click.echo("%s processes found" % len(processes))
21
+ for process_info in processes:
22
+ _print_process_info(process_info, print_docstring=process_name is not None)
23
+
24
+
25
+ def _print_process_info(process_info, print_docstring=False):
26
+ name, docstring = process_info
27
+ # print process name
28
+ click.echo(click.style(name, bold=print_docstring, underline=print_docstring))
29
+ # print process docstring
30
+ if print_docstring:
31
+ click.echo(docstring)
@@ -12,7 +12,7 @@ from mapchete.config import raw_conf, bounds_from_opts
12
12
  from mapchete.formats import available_output_formats
13
13
  from mapchete.index import zoom_index_gen
14
14
  from mapchete.log import set_log_level, setup_logfile
15
- from mapchete._validate import validate_bounds, validate_zooms
15
+ from mapchete.validate import validate_bounds, validate_zooms
16
16
 
17
17
 
18
18
  logger = logging.getLogger(__name__)
@@ -3,22 +3,28 @@
3
3
  from shapely.geometry import LineString, mapping
4
4
 
5
5
 
6
- def extract_contours(array, tile, interval=100, field='elev', base=0):
6
+ def extract_contours(
7
+ array,
8
+ tile,
9
+ interval=100,
10
+ field='elev',
11
+ base=0
12
+ ):
7
13
  """
8
14
  Extract contour lines from an array.
9
15
 
10
16
  Parameters
11
17
  ----------
12
18
  array : array
13
- input elevation data
19
+ Input elevation data.
14
20
  tile : Tile
15
- tile covering the array
21
+ Tile covering the array.
16
22
  interval : integer
17
- elevation value interval when drawing contour lines
23
+ Elevation value interval when drawing contour lines.
18
24
  field : string
19
- output field name containing elevation value
25
+ Output field name containing elevation value.
20
26
  base : integer
21
- elevation base value the intervals are computed from
27
+ Elevation base value the intervals are computed from.
22
28
 
23
29
  Returns
24
30
  -------
@@ -86,29 +86,40 @@ def calculate_slope_aspect(elevation, xres, yres, z=1.0, scale=1.0):
86
86
  return slope, aspect
87
87
 
88
88
 
89
- def hillshade(elevation, tile, azimuth=315.0, altitude=45.0, z=1.0, scale=1.0, ):
89
+ def hillshade(
90
+ elevation,
91
+ tile,
92
+ azimuth=315.0,
93
+ altitude=45.0,
94
+ z=1.0,
95
+ scale=1.0,
96
+ ):
90
97
  """
91
98
  Return hillshaded numpy array.
92
99
 
93
100
  Parameters
94
101
  ----------
95
102
  elevation : array
96
- input elevation data
103
+ Input elevation data.
97
104
  tile : Tile
98
- tile covering the array
105
+ Tile covering the array.
106
+ azimuth : float
107
+ Light source direction in degrees. (default: 315, top left)
108
+ altitude : float
109
+ Light source altitude angle in degrees. (default: 45)
99
110
  z : float
100
- vertical exaggeration factor
111
+ Vertical DEM exaggeration factor. (default: 1)
101
112
  scale : float
102
- scale factor of pixel size units versus height units (insert 112000
103
- when having elevation values in meters in a geodetic projection)
113
+ Scale factor of pixel size units versus height units (insert 112000
114
+ when having elevation values in meters in a geodetic projection).
104
115
  """
105
116
  elevation = elevation[0] if elevation.ndim == 3 else elevation
106
117
  azimuth = float(azimuth)
107
118
  altitude = float(altitude)
108
119
  z = float(z)
109
120
  scale = float(scale)
110
- xres = tile.tile.pixel_x_size
111
- yres = -tile.tile.pixel_y_size
121
+ xres = tile.pixel_x_size
122
+ yres = -tile.pixel_y_size
112
123
  slope, aspect = calculate_slope_aspect(
113
124
  elevation,
114
125
  xres,
@@ -117,13 +128,16 @@ def hillshade(elevation, tile, azimuth=315.0, altitude=45.0, z=1.0, scale=1.0, )
117
128
  scale=scale
118
129
  )
119
130
  deg2rad = math.pi / 180.0
131
+ # shaded has values between -1.0 and +1.0
120
132
  shaded = np.sin(altitude * deg2rad) * np.sin(slope) \
121
133
  + np.cos(altitude * deg2rad) * np.cos(slope) \
122
134
  * np.cos((azimuth - 90.0) * deg2rad - aspect)
123
- # shaded now has values between -1.0 and +1.0
124
- # stretch to 0 - 255 and invert
125
- shaded = (((shaded + 1.0) / 2) * -255.0).astype("uint8")
126
- # add one pixel padding using the edge values
135
+ # stretch to 0 - 255 and add one pixel padding using the edge values
127
136
  return ma.masked_array(
128
- data=np.pad(shaded, 1, mode='edge'), mask=elevation.mask
137
+ data=np.pad(
138
+ np.clip(shaded * 255.0, 1, 255).astype("uint8"),
139
+ 1,
140
+ mode='edge'
141
+ ),
142
+ mask=elevation.mask
129
143
  )
@@ -27,7 +27,7 @@ from shapely.ops import cascaded_union
27
27
  from tilematrix._funcs import Bounds
28
28
  import warnings
29
29
 
30
- from mapchete._validate import (
30
+ from mapchete.validate import (
31
31
  validate_bounds, validate_zooms, validate_values, validate_bufferedtilepyramid
32
32
  )
33
33
  from mapchete.errors import (
@@ -194,6 +194,17 @@ class MapcheteConfig(object):
194
194
  if mode not in ["memory", "continue", "readonly", "overwrite"]:
195
195
  raise MapcheteConfigError("unknown mode %s" % mode)
196
196
  self.mode = mode
197
+ # don't inititalize inputs on readonly mode or if only overviews are going to be
198
+ # built
199
+ self._init_inputs = False if (
200
+ self.mode == "readonly" or (
201
+ not len(
202
+ set(self.baselevels["zooms"]).intersection(set(self.init_zoom_levels))
203
+ )
204
+ if self.baselevels
205
+ else False
206
+ )
207
+ ) else True
197
208
 
198
209
  # (5) prepare process parameters per zoom level without initializing
199
210
  # input and output classes
@@ -344,8 +355,13 @@ class MapcheteConfig(object):
344
355
  """
345
356
  Input items used for process stored in a dictionary.
346
357
 
347
- Keys are the hashes of the input parameters, values the respective
348
- InputData classes.
358
+ Keys are the hashes of the input parameters, values the respective InputData
359
+ classes.
360
+
361
+ If process mode is `readonly` or if only overviews are about to be built, no
362
+ inputs are required and thus not initialized due to performance reasons. However,
363
+ process bounds which otherwise are dependant on input bounds, may change if not
364
+ explicitly provided in process configuration.
349
365
  """
350
366
  # get input items only of initialized zoom levels
351
367
  raw_inputs = OrderedDict([
@@ -359,62 +375,59 @@ class MapcheteConfig(object):
359
375
  if v is not None
360
376
  ])
361
377
 
362
- init_as_readonly = (
363
- self.mode == "readonly" or
364
- (
365
- # in case only overview levels are about to be built
366
- not len(
367
- set(self.baselevels["zooms"]).intersection(set(self.init_zoom_levels))
368
- )
369
- if self.baselevels
370
- else False
371
- )
372
- )
373
-
374
378
  initalized_inputs = OrderedDict()
375
- for k, v in raw_inputs.items():
376
-
377
- # for files and tile directories
378
- if isinstance(v, str):
379
- logger.debug("load input reader for simple input %s", v)
380
- try:
381
- reader = load_input_reader(
382
- dict(
383
- path=absolute_path(path=v, base_dir=self.config_dir),
384
- pyramid=self.process_pyramid,
385
- pixelbuffer=self.process_pyramid.pixelbuffer,
386
- delimiters=self._delimiters
387
- ),
388
- readonly=init_as_readonly
389
- )
390
- except Exception as e:
391
- logger.exception(e)
392
- raise MapcheteDriverError("error when loading input %s: %s" % (v, e))
393
- logger.debug("input reader for simple input %s is %s", v, reader)
394
-
395
- # for abstract inputs
396
- elif isinstance(v, dict):
397
- logger.debug("load input reader for abstract input %s", v)
398
- try:
399
- reader = load_input_reader(
400
- dict(
401
- abstract=deepcopy(v),
402
- pyramid=self.process_pyramid,
403
- pixelbuffer=self.process_pyramid.pixelbuffer,
404
- delimiters=self._delimiters,
405
- conf_dir=self.config_dir
406
- ),
407
- readonly=init_as_readonly
408
- )
409
- except Exception as e:
410
- logger.exception(e)
411
- raise MapcheteDriverError("error when loading input %s: %s" % (v, e))
412
- logger.debug("input reader for abstract input %s is %s", v, reader)
413
- else:
414
- raise MapcheteConfigError("invalid input type %s", type(v))
415
- # trigger bbox creation
416
- reader.bbox(out_crs=self.process_pyramid.crs)
417
- initalized_inputs[k] = reader
379
+
380
+ if self._init_inputs:
381
+ for k, v in raw_inputs.items():
382
+ # for files and tile directories
383
+ if isinstance(v, str):
384
+ logger.debug("load input reader for simple input %s", v)
385
+ try:
386
+ reader = load_input_reader(
387
+ dict(
388
+ path=absolute_path(path=v, base_dir=self.config_dir),
389
+ pyramid=self.process_pyramid,
390
+ pixelbuffer=self.process_pyramid.pixelbuffer,
391
+ delimiters=self._delimiters
392
+ ),
393
+ readonly=self.mode == "readonly"
394
+ )
395
+ except Exception as e:
396
+ logger.exception(e)
397
+ raise MapcheteDriverError(
398
+ "error when loading input %s: %s" % (v, e)
399
+ )
400
+ logger.debug("input reader for simple input %s is %s", v, reader)
401
+
402
+ # for abstract inputs
403
+ elif isinstance(v, dict):
404
+ logger.debug("load input reader for abstract input %s", v)
405
+ try:
406
+ reader = load_input_reader(
407
+ dict(
408
+ abstract=deepcopy(v),
409
+ pyramid=self.process_pyramid,
410
+ pixelbuffer=self.process_pyramid.pixelbuffer,
411
+ delimiters=self._delimiters,
412
+ conf_dir=self.config_dir
413
+ ),
414
+ readonly=self.mode == "readonly"
415
+ )
416
+ except Exception as e:
417
+ logger.exception(e)
418
+ raise MapcheteDriverError(
419
+ "error when loading input %s: %s" % (v, e)
420
+ )
421
+ logger.debug("input reader for abstract input %s is %s", v, reader)
422
+ else:
423
+ raise MapcheteConfigError("invalid input type %s", type(v))
424
+ # trigger bbox creation
425
+ reader.bbox(out_crs=self.process_pyramid.crs)
426
+ initalized_inputs[k] = reader
427
+
428
+ else:
429
+ for k in raw_inputs.keys():
430
+ initalized_inputs[k] = None
418
431
 
419
432
  return initalized_inputs
420
433
 
@@ -532,6 +545,8 @@ class MapcheteConfig(object):
532
545
  -------
533
546
  process area : shapely geometry
534
547
  """
548
+ if not self._init_inputs:
549
+ return box(*self.process_pyramid.bounds)
535
550
  if zoom is None:
536
551
  if not self._cache_full_process_area:
537
552
  logger.debug("calculate process area ...")
@@ -541,8 +556,7 @@ class MapcheteConfig(object):
541
556
  return self._cache_full_process_area
542
557
  else:
543
558
  if zoom not in self.init_zoom_levels:
544
- raise ValueError(
545
- "zoom level not available with current configuration")
559
+ raise ValueError("zoom level not available with current configuration")
546
560
  return self._area_at_zoom(zoom)
547
561
 
548
562
  def _area_at_zoom(self, zoom):