In [2]:
import georasters as gr
import numpy as np
import matplotlib.pyplot as plt

raster = './data/nasa-worldview-2016-07-20.tiff'
data = gr.from_file(raster)
data.raster = data.raster[0]

data.plot()
plt.show()


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-7c3de294e460> in <module>()
----> 1 import georasters as gr
      2 import numpy as np
      3 import matplotlib.pyplot as plt
      4 
      5 raster = './data/nasa-worldview-2016-07-20.tiff'

/usr/local/lib/python3.5/site-packages/georasters/__init__.py in <module>()
      1 # This file allows all subdirectories in this directory to be loaded by Python
      2 # -*- coding: utf-8 -*-
----> 3 from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters, \
      4                         load_tiff, union, GeoRaster, RasterGeoError, RasterGeoTError, RasterGeoTWarning, merge, \
      5                         from_file, to_pandas, to_geopandas, from_pandas, raster_weights, map_vector

/usr/local/lib/python3.5/site-packages/georasters/georasters.py in <module>()
     31 from __future__ import division
     32 import numpy as np
---> 33 from osgeo import gdal, gdalnumeric, ogr, osr, gdal_array
     34 from gdalconst import GA_ReadOnly
     35 from skimage.measure import block_reduce

/usr/local/lib/python3.5/site-packages/GDAL-2.1.3-py3.5-macosx-10.12-x86_64.egg/osgeo/__init__.py in <module>()
     19                 fp.close()
     20             return _mod
---> 21     _gdal = swig_import_helper()
     22     del swig_import_helper
     23 else:

/usr/local/lib/python3.5/site-packages/GDAL-2.1.3-py3.5-macosx-10.12-x86_64.egg/osgeo/__init__.py in swig_import_helper()
     15         if fp is not None:
     16             try:
---> 17                 _mod = imp.load_module('_gdal', fp, pathname, description)
     18             finally:
     19                 fp.close()

/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py in load_module(name, file, filename, details)
    240                 return load_dynamic(name, filename, opened_file)
    241         else:
--> 242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:
    244         return load_package(name, filename)

/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py in load_dynamic(name, path, file)
    340         spec = importlib.machinery.ModuleSpec(
    341             name=name, loader=loader, origin=path)
--> 342         return _load(spec)
    343 
    344 else:

ImportError: dlopen(/usr/local/lib/python3.5/site-packages/GDAL-2.1.3-py3.5-macosx-10.12-x86_64.egg/osgeo/_gdal.cpython-35m-darwin.so, 2): Symbol not found: _CSLParseCommandLine
  Referenced from: /usr/local/lib/python3.5/site-packages/GDAL-2.1.3-py3.5-macosx-10.12-x86_64.egg/osgeo/_gdal.cpython-35m-darwin.so
  Expected in: flat namespace
 in /usr/local/lib/python3.5/site-packages/GDAL-2.1.3-py3.5-macosx-10.12-x86_64.egg/osgeo/_gdal.cpython-35m-darwin.so

In [10]:
NDV, xsize, ysize, GeoT, Projection, DataType = gr.get_geo_info(raster)

x = 58.5283
y = 35#82.2626
col, row = gr.map_pixel(x,y,GeoT[1],GeoT[-1], GeoT[0],GeoT[3])
print (row, col)
print(data.raster.shape)
value = data.raster[row, col]
print("%d, %d: %s" % (col, row, repr(value)))


616 7328
(2976, 13666)
7328, 616: 97

In [1]:
raster = './data/nasa-worldview-2016-07-18.tiff'

from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
im = Image.open(raster)
#im.show()
img = np.array(im)
ar = img[:, :, 0]
img[:, :, 1] = ar
import math
step = 200
for x in range(math.ceil(step / 2), math.floor(ar.shape[0] - step / 2), step):
    for y in range(math.ceil(step / 2), math.floor(ar.shape[1] - step / 2), step):
        square = ar[math.ceil(x - step / 2):math.floor(x + step / 2), math.ceil(y - step / 2):math.floor(y + step / 2)]
        if square.mean() > 40 and square.max() < 167:
            img[math.ceil(x - step / 2):math.floor(x + step / 2), math.ceil(y - step / 2):math.floor(y + step / 2), 0] += 60
img[:, :, 2] = np.ones(ar.shape) * 127
print(img.shape)

#plt.imshow(ar)
#plt.show()
im = Image.fromarray(img)
im.show()
im.save('sample_model_output.jpg')


(4673, 13532, 3)

In [ ]: