Skip to content

Commit 3f5dd55

Browse files
committed
Improved raster parser dataset snapping.
Improved method should fix issues on windows environments.
1 parent 3a84a65 commit 3f5dd55

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

raster/tiles/parser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import fnmatch
55
import os
66
import tempfile
7+
import uuid
78
import zipfile
89

910
import boto3
@@ -338,11 +339,11 @@ def process_quadrant(self, indexrange, zoom):
338339

339340
# Compute quadrant bounds and create destination file
340341
bounds = utils.tile_bounds(indexrange[0], indexrange[1], zoom)
341-
dest_file = tempfile.NamedTemporaryFile(dir=self.tmpdir, suffix='.tif', delete=False)
342+
dest_file_name = os.path.join(self.tmpdir, '{}.tif'.format(uuid.uuid4()))
342343

343344
# Snap dataset to the quadrant
344345
snapped_dataset = self.dataset.warp({
345-
'name': dest_file.name,
346+
'name': dest_file_name,
346347
'origin': [bounds[0], bounds[3]],
347348
'scale': [tilescale, -tilescale],
348349
'width': (indexrange[2] - indexrange[0] + 1) * self.tilesize,
@@ -409,7 +410,7 @@ def process_quadrant(self, indexrange, zoom):
409410
RasterTile.objects.bulk_create(batch)
410411

411412
# Remove quadrant raster tempfile.
412-
os.remove(dest_file.name)
413+
os.remove(dest_file_name)
413414

414415
def push_histogram(self, data):
415416
"""

0 commit comments

Comments
 (0)