Skip to content

Commit

Permalink
Merge pull request #3 from TUW-GEO/develop
Browse files Browse the repository at this point in the history
add travis support
  • Loading branch information
bbauerma authored Sep 27, 2017
2 parents 5d0d9fd + 6991f89 commit ad44253
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ install:
# Useful for debugging any issues with conda
- conda info -a

- conda create -q -n test-environment -c conda-forge python=$TRAVIS_PYTHON_VERSION numpy scipy pytest pip gdal
pyproj numba astropy toolz dask
- conda create -q -n test-environment -c conda-forge python=$TRAVIS_PYTHON_VERSION numpy scipy pytest pip gdal pyproj numba astropy toolz
- source activate test-environment
- python setup.py install
- pip list
Expand Down
5 changes: 3 additions & 2 deletions pytileproj/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import itertools

import numpy as np
import dask.array as da
#import dask.array as da
from osgeo import osr

import geometry as geometry
Expand Down Expand Up @@ -615,7 +615,7 @@ def create_tiles_overlapping_xybbox(self, bbox):

return tiles


'''
def create_daskarray_overlapping_xybbox(self, bbox):
tiles = self.create_tiles_overlapping_xybbox(bbox)
Expand All @@ -637,6 +637,7 @@ def create_daskarray_overlapping_xybbox(self, bbox):
m = g.map_blocks(func)
y = da.ghost.trim_internal(m, {0: 1, 1: 1})
'''



Expand Down
12 changes: 6 additions & 6 deletions pytileproj/gdalport.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_raster_nodata(self):
"""

nodata = list()
for i in xrange(0, self.dataset.RasterCount):
for i in range(0, self.dataset.RasterCount):
nodata.append(self.dataset.GetRasterBand(i + 1).GetNoDataValue())

return nodata if len(nodata) >= 0 and not all(d is None for d in nodata) else None
Expand All @@ -139,7 +139,7 @@ def read_all_band(self):
"""read the data of all the bands"""
m = np.full((self.band_count(), self.YSize(), self.XSize()), 0.0)

for bandIdx in xrange(self.band_count()):
for bandIdx in range(self.band_count()):
m[bandIdx] = self.read_band(bandIdx + 1)

return m
Expand Down Expand Up @@ -167,7 +167,7 @@ def colormap(self, band_idx=1):
return None

colormap = []
for i in xrange(ct.GetCount()):
for i in range(ct.GetCount()):
colormap.append(ct.GetColorEntry(i))

return colormap
Expand Down Expand Up @@ -403,14 +403,14 @@ def write_image(image, filename, frmt="GTiff", nodata=None,
if image.ndim == 2:
ds.GetRasterBand(1).WriteArray(image, 0, 0)
else:
for i in xrange(ds.RasterCount):
for i in range(ds.RasterCount):
ds.GetRasterBand(i + 1).WriteArray(image[i] if dtype is None else image[i].astype(dtype), 0, 0)

ds.FlushCache()
# set nodata for each band
if nodata is not None:
assert ds.RasterCount == len(nodata) or len(nodata) == 1, "Mismatch of nodata values and RasterCount"
for i, val in izip(xrange(ds.RasterCount), cycle(nodata)):
for i, val in izip(range(ds.RasterCount), cycle(nodata)):
ds.GetRasterBand(i + 1).SetNoDataValue(val)

# colormaps are only supported for 1 band rasters
Expand All @@ -421,7 +421,7 @@ def write_image(image, filename, frmt="GTiff", nodata=None,
color = list(color) + [0,]
ct.SetColorEntry(i, tuple(color))

for i in xrange(ds.RasterCount):
for i in range(ds.RasterCount):
ds.GetRasterBand(i + 1).SetRasterColorTable(ct)

return ds
Expand Down
40 changes: 39 additions & 1 deletion pytileproj/warp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@

# Copyright (c) 2017, Vienna University of Technology (TU Wien), Department of
# Geodesy and Geoinformation (GEO).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of the FreeBSD Project.


'''
Created on September 26, 2017
Code for converting raster images to TPS grids.
@author: Bernhard Bauer-Marschallinger, [email protected]
'''

import os
import errno
Expand All @@ -19,6 +56,7 @@ def warp2tiledgeotiff(TPS, image, output_dir,

"""warp the image to tiles in target TPS.
Parameters
----------
grid : TiledProjectionSystem
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Add your requirements here like:
astropy>2.0.1
numpy>1.13.1
dask>0.15.3
astropy>=2.0.1
numpy>=1.13.1
toolz>=0.8.2
pyproj>=1.9.5.1

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ packages =
# py.test options when running `python setup.py test`
addopts = tests

[pytest]
[tool:pytest]
# Options for py.test:
# Specify command line options as you would do when invoking py.test directly.
# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml
Expand Down

0 comments on commit ad44253

Please sign in to comment.