Skip to content

Commit

Permalink
version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ozak committed Apr 28, 2015
1 parent bc25049 commit e679661
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ before_install:
env:
- GDAL_DATA=/usr/share/gdal/1.10/
install:
- conda create --yes -n env_name python=$TRAVIS_PYTHON_VERSION pip nose cython numpy matplotlib pandas gdal scipy
- conda create --yes -n env_name python=$TRAVIS_PYTHON_VERSION pip nose cython numpy matplotlib pandas gdal scipy fiona
- source activate env_name
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then conda install --yes imaging; else pip install pillow; fi
- pip install pytest # not yet available for py3 in anaconda
Expand Down
4 changes: 2 additions & 2 deletions georasters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This file allows all subdirectories in this directroy to loaded by Python
# -*- coding: utf-8 -*-
from .georasters import get_geo_info, map_pixel, aggregate, create_geotiff, align_rasters, \
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters, \
load_tiff, union, GeoRaster, RasterGeoError, RasterGeoTError, RasterGeoTWarning, merge, \
from_file, to_pandas, from_pandas

__all__ = (['get_geo_info','map_pixel','aggregate','create_geotiff','align_rasters', \
__all__ = (['get_geo_info','map_pixel', 'map_pixel_inv','aggregate','create_geotiff','align_rasters', \
'load_tiff', 'union', 'GeoRaster', 'RasterGeoError', 'RasterGeoTError', \
'RasterGeoTWarning', 'merge', 'from_file','to_pandas', 'from_pandas'])
30 changes: 28 additions & 2 deletions georasters/georasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,29 @@ def map_pixel(point_x, point_y, cellx, celly, xmin, ymax):
NDV, xsize, ysize, GeoT, Projection, DataType = GetGeoInfo(raster)
row, col = map_pixel(x,y,GeoT[1],GeoT[-1], GeoT[0],GeoT[3])
'''
point_x=np.array(point_x)
point_y=np.array(point_y)
point_x=np.asarray(point_x)
point_y=np.asarray(point_y)
col = np.around((point_x - xmin) / cellx).astype(int)
row = np.around((point_y - ymax) / celly).astype(int)
return row,col

def map_pixel_inv(row, col, cellx, celly, xmin, ymax):
'''
Usage: map_pixel(xcoord, ycoord, x_cell_size, y_cell_size, xmin, ymax)
where:
xmin is leftmost X coordinate in system
ymax is topmost Y coordinate in system
Example:
raster = HMISea.tif'
NDV, xsize, ysize, GeoT, Projection, DataType = GetGeoInfo(raster)
row, col = map_pixel(x,y,GeoT[1],GeoT[-1], GeoT[0],GeoT[3])
'''
col=np.asarray(col)
row=np.asarray(row)
point_x = xmin+col*cellx
point_y = ymax+row*celly
return point_x, point_y

# Aggregate raster to higher resolution using sums
def aggregate(raster,NDV,block_size):
'''
Expand Down Expand Up @@ -626,6 +643,15 @@ def map_pixel(self, point_x, point_y):
row, col =map_pixel(point_x, point_y, self.x_cell_size, self.y_cell_size, self.xmin, self.ymax)
return self.raster[row, col]

def map_pixel_location(self, point_x, point_y):
'''
geo.map_pixel(point_x, point_y)
Return value of raster in location
'''
row, col =map_pixel(point_x, point_y, self.x_cell_size, self.y_cell_size, self.xmin, self.ymax)
return np.array([row, col])

def extract(self, point_x, point_y, radius=0):
'''
geo.extract(x, y, radius=r)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def readme():
return f.read()

setup(name='georasters',
version='0.1.20',
version='0.2',
description='Tools for working with Geographical Information System Rasters',
url='http://github.com/ozak/georasters',
author='Ömer Özak',
Expand Down

0 comments on commit e679661

Please sign in to comment.