ozak / georasters Goto Github PK
View Code? Open in Web Editor NEWGeoRasters is a Python module that provides a fast and flexible tool to work with GIS raster files.
License: GNU General Public License v3.0
GeoRasters is a Python module that provides a fast and flexible tool to work with GIS raster files.
License: GNU General Public License v3.0
I have a GeoPandas dataFrame, named selection
, which I want to use to compute stats over a georaster, named data
.
When I try this command, the kernel dies, without giving any error:
means = data.stats(selection, stats = 'mean')
Any idea of where the problem might be?
I'm using python 3.6.4 and georasters 0.5.8.
As per https://stackoverflow.com/a/56331273/3000741, using the scipy block reduce loses all mask information. This can cause lots of calculation errors. The one that I'm running into at the moment is with the CHELSEA dataset. When I try to block reduce, the masked array is filled with the no data value and the mean calculation is completely thrown off in blocks with masked pixels.
Hello everyone,
I am quite new with georasters and I try to use it with ArcGIS to find the values of shading at specific cells.
The issue is that when I use map_pixel(x,y) I got a vector even if x,y are specific coordinates.
So I don't understand how map_pixel and what should be put for x and y.
The raster file is a raster created from a LAS file, with pipeline found at pdal.io.
Regards
I was unable to use merge() with 3-band images until I added a third dimension to the shape expression in union():
shape = (np.abs(np.floor((latmax-latmin)/rasters[0].y_cell_size)).astype(int), np.floor((lonmax-lonmin)/rasters[0].x_cell_size).astype(int), 3)
Was I using merge() incorrectly or does there need to be a test for the number of bands in the input imagery?
Add function that uses raster stats to produce stats based on the raster and a shapefile/GeoPandas frame.
It would be good for it to create GeoRasters as output also. See my raster-stats options and discussion.
(try_georasters3) adil@adil-HP-Pavilion-Notebook:~/burkstream$ python3 sample.py
Traceback (most recent call last):
File "sample.py", line 1, in
import georasters as gr
File "/home/adil/anaconda3/envs/try_georasters3/lib/python3.5/site-packages/georasters/init.py", line 3, in
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters,
File "/home/adil/anaconda3/envs/try_georasters3/lib/python3.5/site-packages/georasters/georasters.py", line 33, in
from osgeo import gdal, gdalnumeric, ogr, osr, gdal_array
File "/home/adil/anaconda3/envs/try_georasters3/lib/python3.5/site-packages/osgeo/init.py", line 21, in
_gdal = swig_import_helper()
File "/home/adil/anaconda3/envs/try_georasters3/lib/python3.5/site-packages/osgeo/init.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/home/adil/anaconda3/envs/try_georasters3/lib/python3.5/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/adil/anaconda3/envs/try_georasters3/lib/python3.5/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libpoppler.so.76: cannot open shared object file: No such file or directory
I tried installing georasters 0.5.3 for Python 2.7, in a virtual environment on macos 10.12.2. I tried installing with pip, but got the same errors regardless of which package repo I used:
pip install georasters
pip install git+git://github.com/ozak/georasters.git
In both cases, setup.py
seemed to proceed normally, until I got these build errors associated with the 'pyproj._proj' extension. FYI "geospatial_py2" is the name of the env:
src/pj_fwd3d.c:6:2: error: unknown type name 'XYZ'; did you mean 'XY'?
XYZ /* forward projection entry */
^~~
XY
/Users/Mike/anaconda/envs/geospatial_py2/include/projects.h:155:37: note: 'XY' declared here
typedef struct { double x, y; } XY;
^
src/pj_fwd3d.c:7:10: error: unknown type name 'LPZ'; did you mean 'LP'?
pj_fwd3d(LPZ lpz, PJ *P) {
^~~
LP
/Users/Mike/anaconda/envs/geospatial_py2/include/projects.h:156:37: note: 'LP' declared here
typedef struct { double lam, phi; } LP;
^
src/pj_fwd3d.c:8:2: error: unknown type name 'XYZ'; did you mean 'XY'?
XYZ xyz;
^~~
XY
/Users/Mike/anaconda/envs/geospatial_py2/include/projects.h:155:37: note: 'XY' declared here
typedef struct { double x, y; } XY;
^
src/pj_fwd3d.c:13:23: error: no member named 'z' in 'XY'
xyz.x = xyz.y = xyz.z = HUGE_VAL;
~~~ ^
src/pj_fwd3d.c:29:24: error: no member named 'fwd3d' in 'struct PJconsts'
if (P->fwd3d != NULL)
~ ^
src/pj_fwd3d.c:31:18: error: no member named 'fwd3d' in 'struct PJconsts'
xyz = (*P->fwd3d)(lpz, P); /* project */
~ ^
src/pj_fwd3d.c:33:24: error: no member named 'z' in 'XY'
xyz.x = xyz.y = xyz.z = HUGE_VAL;
~~~ ^
src/pj_fwd3d.c:43:41: error: no member named 'z' in 'XY'
xyz.x = xyz.y = xyz.z = HUGE_VAL;
~~~ ^
8 errors generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Users/Mike/anaconda/envs/geospatial_py2/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/n1/4zz_xfnj29j4hmm3x505b39c0000gp/T/pip-build-IqbSaQ/pyproj/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/n1/4zz_xfnj29j4hmm3x505b39c0000gp/T/pip-SpvZBh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/n1/4zz_xfnj29j4hmm3x505b39c0000gp/T/pip-build-IqbSaQ/pyproj/
I've attached the complete output of setup.py as a txt file:
georasters install errors.txt
Based on the above errors, is there a problem in the source code for pyproj? Can you help?
Please let me know what you think. Any advice you can give toward getting georasters installed on OSX would be much appreciated.
Mike
(geo_env) dells-MacBook-Air:georasters dell$ python
Python 2.7.14 |Intel Corporation| (default, Oct 16 2017, 10:29:14)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
import georasters
Traceback (most recent call last):
File "", line 1, in
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/georasters/init.py", line 3, in
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters,
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/georasters/georasters.py", line 44, in
from rasterstats import zonal_stats
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/rasterstats-0.11.0-py2.7.egg/rasterstats/init.py", line 2, in
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/rasterstats-0.11.0-py2.7.egg/rasterstats/main.py", line 8, in
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/rasterstats-0.11.0-py2.7.egg/rasterstats/io.py", line 13, in
BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its
ImportError: cannot import name ReadingError
import georaster
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named georaster
import georasters
Traceback (most recent call last):
File "", line 1, in
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/georasters/init.py", line 3, in
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters,
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/georasters/georasters.py", line 44, in
from rasterstats import zonal_stats
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/rasterstats-0.11.0-py2.7.egg/rasterstats/init.py", line 2, in
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/rasterstats-0.11.0-py2.7.egg/rasterstats/main.py", line 8, in
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/rasterstats-0.11.0-py2.7.egg/rasterstats/io.py", line 13, in
BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its
ImportError: cannot import name ReadingError
I have a raster with 8 bands that I load via:
raster = '../../Data/21-Mar-2016_part1.tif'
data = gr.from_file(raster)
The data shape is (8, 3485, 3617).
The bounds I obtain via data.bounds is not correct because it does not use the correct shape size.
data.bounds
(-49.061416, -22.462534226398855, -48.72194693862317, -22.461815)
While
geot = data.geot
shape = data.shape
geot[3]+geot[5]*shape[1]
returns the correct value of -22.775128 instead of -22.462534226398855 and
geot[0]+geot[1]*shape[2]
returns the correct value of -48.709089 instead of -48.72194693862317.
Perhaps, the bounds method need to be modified as to be aware which axis corresponds to x and y and not to the band?
Here's an example that is unclear:
# Load raster
data = load_tiff(raster)
load_tiff
is not imported. Please, show me how it can be fixed, and I'll submit you a pull request with a fix.
I am attempting to perform the following
f1='file1.tif'
f2='file2.tif'
data1t=gr.load_tiff(f1)
data2t=gr.load_tiff(f2)
NDV, xsize, ysize, GeoT, Projection, DataType = gr.get_geo_info(f1)
data1ta=gr.aggregate(data1t,NDV,(10,10))
data2ta=gr.aggregate(data2t,NDV,(10,10))
driver = gdal.GetDriverByName('GTiff')
driver.Register()
NoDataValue=0.0
GeoT=list(GeoT)
GeoT[1]=GeoT[1]*10
GeoT[5]=GeoT[5]*10
d1fname=gr.create_geotiff('test1d',data1ta,driver,NoDataValue,data1ta.shape[1], data1ta.shape[0], GeoT, Projection, DataType)
d2fname=gr.create_geotiff('test2d',data2ta,driver,NoDataValue,data2ta.shape[1], data2ta.shape[0], GeoT, Projection, DataType)
# Agregate raster by summing over cells in order to increase pixel size by e.g. 10
(alignedraster_o, alignedraster_a, GeoT_a) = gr.align_rasters(d1fname, d2fname, how=np.sum)
data1t=gr.load_tiff('test1d.tif')
data2t=gr.load_tiff('test2d.tif')
A=gr.GeoRaster(data1t, GeoT, nodata_value=NDV)
NDV, xsize, ysize, GeoT, Projection, DataType = gr.get_geo_info('test1d.tif')
A.projection=Projection
B=gr.GeoRaster(data2t, GeoT, nodata_value=NDV)
B.projection=Projection
C=B.merge(A)
mergedname=gr.create_geotiff('test_merged',C,driver,NoDataValue,alignedraster_o.shape[1], alignedraster_o.shape[0], GeoT_a, Projection, DataType
ValueError: operands could not be broadcast together with shapes (138,166) (138,166) (118,166)
Generalize #11 and address pysal/pysal/issues/895
Upon updating my python installation with conda update --all, I started seeing the following error when importing georasters with command -
import georasters as grs
AppData\Local\Continuum\anaconda3\lib\site-packages\dask\config.py:168: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
data = yaml.load(f.read()) or {}
I have a raster file which has -inf whenever no data is present at a location, georasters seems to not able to handle this:
data2 = load_tiff(raster2)
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/gisrastertools/gisrastertools.py", line 190, in load_tiff
data=np.ma.masked_array(data, mask=data==NDV,fill_value=-np.inf)
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/numpy/ma/core.py", line 2892, in new
_data._fill_value = _check_fill_value(fill_value, _data.dtype)
File "/Volumes/MacBookData/dell/anaconda3/envs/geo_env/lib/python2.7/site-packages/numpy/ma/core.py", line 477, in _check_fill_value
raise TypeError(err_msg % (fill_value, ndtype))
TypeError: Fill value -inf overflows dtype uint8
was just playing around with this package, really cool! Anyway I noticed there should be an import in the georasters.py script for the shapely.geometry Polygon when using the method to_geopandas(). I tested it out and seemed to work fine when added.
from shapely.geometry import Polygon
add the above to the georasters.py script to eliminate the error:
NameError: ("global name 'Polygon' is not defined", u'occurred at index 0')
I am rather new to python, let me know if I'm incorrect here, thanks!
~rickD
first of all thank you for this library, looks very promising!
I noticed an issue when loading a raster. If I do gr.load_tiff(raster)
I get MemoryError
.
If I load the same rater with rasterio
(rasterio.open(raster)
) it loads fine.
The raster I am trying to load can be found here.
I wanted to add compression to GeoTiff, and turns out that there's no such option, and the functions code is quite coupled.
create_geotiff
function receives gdal driver as a parameter, and it's not reused anywhere. Does it really need the driver parameter?
https://github.com/ozak/georasters/blob/master/georasters/georasters.py#L478
Are there any updates planned to support the commands that depend on pysal? Pysal 2.0 was a major refactor and modularized the library; e.g. pysal.lat2w
(weight matrix) was moved to pysal.lib.weights.lat2w
link. As a result, running commands like graster.pysal_G_local()
fail.
I have used the following command for raster allignment.
(alignedraster_o, alignedraster_a, GeoT_a) = gr.align_rasters(raster, raster2, how=np.mean)
Can anyone tell where are the aligned rasters stored? and how to save the aligned rasters?
import georasters as gr
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ
currently work around
import matplotlib
matplotlib.use('TkAgg')
import georasters as gr
will be great if matplotlib can be lazily imported
I tried to clip a raster to a shapefile in a python 3.5 environment and get an error. clip(shp,return=False)
does not cause an error. I get a `dict object has no attribute iterkeys' error, so looks like that is a standard python 2 vs python 3 issue.
replication code (requires DMSP, i bet a student of Weil and Galor's needs no intro to that dataset 😄 )
import geopandas as gpd
import georasters as gr
raster = gr.from_file('dmsp_stable_nightlights_1992.tif')
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
countries = world[world.name.isin(['Nepal','India'])
clipped = raster.clip(countries, keep = True)
error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-34-82e70efc2e93> in <module>()
----> 1 clipped = raster0.clip(subset_shape(['Nepal']),keep=True)
~/anaconda3/envs/gds/lib/python3.5/site-packages/georasters/georasters.py in clip(self, shp, keep, *args, **kwargs)
698 projection=self.projection,
699 datatype=self.datatype))
--> 700 cols = list(set([i for i in df.properties[0].iterkeys()]).intersection(set(shp.columns)))
701 df2 = pd.DataFrame([df.properties.apply(lambda x: x[i]) for i in df.properties[0].iterkeys()
702 if i in cols]).T.merge(df[['GeoRaster']], left_index=True, right_index=True,)
AttributeError: 'dict' object has no attribute 'iterkeys'
Hi @ozak
I'd like to ask if it's possible to create tiles from GeoTiff with your lib?
I can't find such def, but maybe I miss something.
Thanks.
Hello,
I am getting an error when trying to convert back and forth from Pandas.
I open the file like so:
states_gr = gr.from_file(state_class_file)
states_pd = states_gr.to_pandas()
... Do some pandas work on states_pd...
temp_raster = gr.from_pandas(states_pd,value='new_value',projection=Projection,geot=GeoT)
This gives me the error
ValueError: Index contains duplicate entries, cannot reshape
Data is here:
https://drive.google.com/open?id=1TwgMMEM3GRxc5yEz1MfRZPuuijnd9f-k
I have done this process in other code. Not sure what the issue is with data.
Trying to explore the example and I am getting:
data = data**2
data2.to_tiff('./data2)
AttributeError Traceback (most recent call last)
<ipython-input-10-5bea72a36895> in <module>()
----> 1 data2.to_tiff('./data2')
/home/serge/anaconda3/envs/georaster/lib/python2.7/site-packages/georasters/georasters.pyc in to_tiff(self, filename)
474 self.raster.data[self.raster.mask] = self.nodata_value
475 create_geotiff(filename, self.raster, gdal.GetDriverByName('GTiff'), self.nodata_value,
--> 476 self.shape[1], self.shape[0], self.geot, self.projection, self.datatype)
477
478 def to_pandas(self):
/home/serge/anaconda3/envs/georaster/lib/python2.7/site-packages/georasters/georasters.pyc in create_geotiff(name, Array, driver, ndv, xsize, ysize, geot, projection, datatype)
126 DataSet = driver.Create(newfilename, xsize, ysize, 1, datatype)
127 # the '1' is for band 1.
--> 128 DataSet.Setgeotransform(geot)
129 DataSet.SetProjection(projection.ExportToWkt())
130 # Write the array
/home/serge/anaconda3/envs/georaster/lib/python2.7/site-packages/osgeo/gdal.pyc in <lambda>(self, name)
1671 __swig_getmethods__ = {}
1672 for _s in [MajorObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
-> 1673 __getattr__ = lambda self, name: _swig_getattr(self, Dataset, name)
1674 def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
1675 __repr__ = _swig_repr
/home/serge/anaconda3/envs/georaster/lib/python2.7/site-packages/osgeo/gdal.pyc in _swig_getattr(self, class_type, name)
55 method = class_type.__swig_getmethods__.get(name,None)
56 if method: return method(self)
---> 57 raise AttributeError(name)
58
59 def _swig_repr(self):
AttributeError: Setgeotransform
It seems like GDAL has changed and this package needs to be updated to account for that. A bit of digital decay has occurred. Or maybe someone can suggest a workaround for me? Thanks!
To recreate:
Windows 10 powershell / pip install georaster
ERROR: Command errored out with exit status 1:
command: 'c:\python\python37-64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'X:\\Temp\\pip-install-zce_47at\\fiona\\setup.py'"'"'; __file__='"'"'X:\\Temp\\pip-install-zce_47at\\fiona\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'X:\Temp\pip-install-zce_47at\fiona\pip-egg-info'
cwd: X:\Temp\pip-install-zce_47at\fiona\
Complete output (1 lines):
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
In these lines np.round
should be replaced by np.floor
, otherwise half of the points get matched to the next pixel, which might not even exist in the data
Add function to reproject GeoRaster to other projection
Line of code and stack trace:
>>> raster = gr.from_file(os.path.expanduser("~/Downloads/datasets/elevation/one_deg.tif"))
Traceback (most recent call last):
File "/home/benjamin/.pyenv/versions/georasters/lib/python3.7/site-packages/numpy/ma/core.py", line 473, in _check_fill_value
fill_value = np.array(fill_value, copy=False, dtype=ndtype)
ValueError: cannot convert float NaN to integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/benjamin/.pyenv/versions/georasters/lib/python3.7/site-packages/georasters/georasters.py", line 1231, in from_file
data = np.ma.masked_array(data, mask=data == ndv, fill_value=ndv)
File "/home/benjamin/.pyenv/versions/georasters/lib/python3.7/site-packages/numpy/ma/core.py", line 2893, in __new__
_data._fill_value = _check_fill_value(fill_value, _data.dtype)
File "/home/benjamin/.pyenv/versions/georasters/lib/python3.7/site-packages/numpy/ma/core.py", line 479, in _check_fill_value
raise TypeError(err_msg % (fill_value, ndtype))
TypeError: Cannot convert fill_value nan to dtype int16
I dumped this file using the to_tiff
method. I then tried to load it again, and got this stack trace. Are there any workarounds?
I ran pip install georasters
in a fresh 3.6.4 virtualenv on a fairly new Ubuntu 16.04 install, which generated the following output:
Collecting georasters
Downloading georasters-0.5.9-py2.py3-none-any.whl
Collecting geopandas (from georasters)
Downloading geopandas-0.3.0-py2.py3-none-any.whl (888kB)
100% |████████████████████████████████| 890kB 269kB/s
Collecting affine (from georasters)
Downloading affine-2.1.0-py3-none-any.whl
Collecting pandas (from georasters)
Downloading pandas-0.22.0-cp36-cp36m-manylinux1_x86_64.whl (26.2MB)
100% |████████████████████████████████| 26.3MB 25kB/s
Collecting pyproj (from georasters)
Downloading pyproj-1.9.5.1.tar.gz (4.4MB)
100% |████████████████████████████████| 4.4MB 132kB/s
Collecting pysal (from georasters)
Downloading PySAL-1.14.3.tar.gz (17.8MB)
100% |████████████████████████████████| 17.8MB 36kB/s
Collecting matplotlib (from georasters)
Using cached matplotlib-2.1.2-cp36-cp36m-manylinux1_x86_64.whl
Collecting scikit-image (from georasters)
Downloading scikit_image-0.13.1-cp36-cp36m-manylinux1_x86_64.whl (35.8MB)
100% |████████████████████████████████| 35.8MB 16kB/s
Collecting GDAL (from georasters)
Downloading GDAL-2.2.3.tar.gz (475kB)
100% |████████████████████████████████| 481kB 495kB/s
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/GDAL.egg-info
writing pip-egg-info/GDAL.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/GDAL.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/GDAL.egg-info/top_level.txt
writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 131, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 179, in get_gdal_config
return fetch_config(option, gdal_config = self.gdal_config)
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 135, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 131, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 339, in <module>
**extra )
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 278, in run
self.find_sources()
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 293, in find_sources
mm.run()
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 524, in run
self.add_defaults()
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 560, in add_defaults
sdist.add_defaults(self)
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/command/py36compat.py", line 36, in add_defaults
self._add_defaults_ext()
File "/home/benjamin/.pyenv/versions/3.6.4/envs/georasters/lib/python3.6/site-packages/setuptools/command/py36compat.py", line 119, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/distutils/cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "/home/benjamin/.pyenv/versions/3.6.4/lib/python3.6/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 214, in finalize_options
self.gdaldir = self.get_gdal_config('prefix')
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 188, in get_gdal_config
return fetch_config(option)
File "/tmp/pip-build-hul8gsn8/GDAL/setup.py", line 135, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hul8gsn8/GDAL/
pip list
after running that command:
pip (9.0.1)
setuptools (38.5.1)
I was trying out georasters today, specifically for plotting paletted geotiff files.
Here's a few comments, in no particular order.. i might not be able to help with PRs at this point, due to time restrictions and although because I'm not fully sure georasters will work for me (main blocker for me right now is lack of reprojection and deficiencies in downsampling, esp. with paletted data).
But I wanted to at least leave these comments to help with thoughts for improvements (compare gist linked at bottom).
Most geotiffs I work with are in some metric coordinates and pixels are aligned rectangular in X and Y. Those plots should take into account map extent, which is trivial, extracted from data.geot
. It's possible to manually do it and pass it in to data.plot(..., extent=..)
but it could be done automatically. See gist.
Methods like .resize
and .extract
change the map extents (compare above). Derived georaster should have it's .geot
attribute updated, otherwise it's not correct anymore (e.g. adjust the dx
and dy
on resize and adjust x/y boundaries when doing an extract)
Some geotiffs use paletted colormaps and these won't plot correct with just a default divergent colormap. With gdal it's easy to extract paletted colors and create a matplotlib linear segmented colormap for the array plot (see gist).
Calculating new pixel values from an array of old pixels might need some other measure to compute new pixel, like a mode
measure for example.
self.shape
should be a propertyWhen modifying data.raster
(e.g. in a multiband geotif getting rid of 3rd dimension in array by reducing to one band), self.shape
breaks as it is not reflecting current state of the raster anymore. I think it should just return what self.raster.shape
is currently saying.
Multiband files, like most interestingly 3-band RGB geotiffs, are not handled correctly right now. It only needs one line of numpy to plot them correctly, moving the band-axis to the rear. Above problems with cropping/resampling the data will apply as well, though and code might need some love to take third axis into account, I bet.
Gist for the Natural Earth RGB plot: https://gist.github.com/b1d03ec98cb54656644d95a8f7abffb8
gdal.Open(filename).GetRasterBand(1).GetRasterColorTable()
) and plot with a linear segmented custom colormapdata.geot
self.shape
should be read-only property linking to self.raster.shape
I think, so that it doesn't get out of syncFor reference, here's my scripts I was playing around with..
I had a few questions about the Georasters Python package which I emailed to Omer Ozak.
Where I ran into some questions is around multi band rasters. I am doing some processing to create rasters by year. I want to stack those rasters into a multi band raster to make the file management easier – just one file instead of dozens. I can’t figure out how to create a multi band raster from a set of georaster objects.
I am also wondering how to work with multi band rasters. I loaded a multi band raster. That worked find but I could not figure out how to access the individual bands. I assumed that a pythonic/pandas syntax like my_raster[1] or my_raster[‘band_1’] would work but they didn’t. Finally assuming I could get to each band how can the band name be accessed and changed?
His response
Regarding your questions…sadly at the moment the package is really written to handle single bands. We added the ability to load a specific band, but it has not been expanded to work with real multband rasters. Given that in my own work I do not use them much, I never wrote it for that purpose. But as more and more users use the package and request the feature it may be added. I think it should not be too difficult to extend the package, but have not had time to work on this. If you are interested I always welcome help on the project.
Hello - I'm getting an UnboundLocalError: local variable 'raster2' referenced before assignment when I call the gr.aggregate function. Code is below and test dataset KEN.tif attached as zip (clipped version of SEDAC-CIESIN population density raster).
Is this an problem with my code or with the aggregate function?
Thanks!
import georasters as gr
raster = 'KEN.tif'
data = gr.from_file(raster)
NDV, xsize, ysize, GeoT, Projection, DataType = gr.get_geo_info(raster)
gr.aggregate(data,NDV,(10,10))
In code:
one_deg.to_tiff(os.path.expanduser("~/path/to/dir/one_deg.tif"))
In file:
$ ls
one_deg.tif.tif
I expected that the file would just be named one_deg.tif
, not .tif.tif
I get a ModuleNotFoundError: No module named 'numba.targets.linalg' when importing georasters:
import georasters as grs
Traceback (most recent call last):
File "C:\Users\kahy\OneDrive - Skogforsk\Documents\Projekt\RöjSat\RöjSat_GPS.py", line 12, in <module>
import georasters as grs
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\georasters\__init__.py", line 3, in <module>
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters, \
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\georasters\georasters.py", line 45, in <module>
import pysal
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\pysal\__init__.py", line 3, in <module>
from . import explore
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\pysal\explore\__init__.py", line 2, in <module>
import giddy
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\giddy\__init__.py", line 11, in <module>
from . import ergodic
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\giddy\ergodic.py", line 10, in <module>
import quantecon as qe
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\quantecon\__init__.py", line 14, in <module>
from . import game_theory
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\quantecon\game_theory\__init__.py", line 12, in <module>
from .support_enumeration import support_enumeration, support_enumeration_gen
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\quantecon\game_theory\support_enumeration.py", line 14, in <module>
from ..util.numba import _numba_linalg_solve
File "C:\Program Files\Miniconda3\envs\gps_env\lib\site-packages\quantecon\util\numba.py", line 7, in <module>
from numba.targets.linalg import _LAPACK
ModuleNotFoundError: No module named 'numba.targets.linalg'
conda info:
active environment : gps_env
active env location : C:\Program Files\Miniconda3\envs\gps_env
shell level : 2
user config file : C:\Users\kahy.condarc
populated config files : C:\Users\kahy.condarc
conda version : 4.8.3
conda-build version : 3.18.11
python version : 3.7.6.final.0
virtual packages :
base environment : C:\Program Files\Miniconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Program Files\Miniconda3\pkgs
C:\Users\kahy.conda\pkgs
C:\Users\kahy\AppData\Local\conda\conda\pkgs
envs directories : C:\Program Files\Miniconda3\envs
C:\Users\kahy.conda\envs
C:\Users\kahy\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.8.3 requests/2.23.0 CPython/3.7.6 Windows/10 Windows/10.0.18362
administrator : True
netrc file : None
offline mode : False
conda list:
Name Version Build Channel
affine 2.3.0 py_0 conda-forge
alabaster 0.7.12 py_0
argh 0.26.2 py38_0
astroid 2.4.1 py38_0
atomicwrites 1.4.0 py_0
attrs 19.3.0 py_0 conda-forge
autopep8 1.4.4 py_0
babel 2.8.0 py_0
backcall 0.1.0 py38_0
bcrypt 3.1.7 py38he774522_0
beautifulsoup4 4.9.1 py38h32f6830_0 conda-forge
blas 1.0 mkl
bleach 3.1.4 py_0
blosc 1.18.1 h6538335_0 conda-forge
boost-cpp 1.72.0 h0caebb8_0 conda-forge
bzip2 1.0.8 hfa6e2cd_2 conda-forge
ca-certificates 2020.4.5.1 hecc5488_0 conda-forge
celluloid 0.2.0 pypi_0 pypi
certifi 2020.4.5.1 py38h32f6830_0 conda-forge
cffi 1.14.0 py38h7a1dbc1_0
cfitsio 3.470 he774522_5 conda-forge
chardet 3.0.4 py38_1003
click 7.1.2 pyh9f0ad1d_0 conda-forge
click-plugins 1.1.1 py_0 conda-forge
cligj 0.5.0 py_0 conda-forge
cloudpickle 1.4.1 py_0
colorama 0.4.3 py_0
coverage 5.1 py38h1e8a9f7_0 conda-forge
cryptography 2.9.2 py38h7a1dbc1_0
curl 7.69.1 h1dcc11c_0 conda-forge
cycler 0.10.0 py38_0
cytoolz 0.10.1 py38hfa6e2cd_0 conda-forge
dask-core 2.17.0 py_0 conda-forge
decorator 4.4.2 py_0
defusedxml 0.6.0 py_0
deprecated 1.2.10 pyh9f0ad1d_0 conda-forge
descartes 1.1.0 py_4
diff-match-patch 20181111 py_0
docopt 0.6.2 py_1 conda-forge
docutils 0.16 py38_0
entrypoints 0.3 py38_0
esda 2.2.1 py_0 conda-forge
expat 2.2.9 he025d50_2 conda-forge
fastcache 1.1.0 py38h9de7a3e_1 conda-forge
fiona 1.8.13 py38h41bf4fa_1 conda-forge
flake8 3.7.9 py38_0
freetype 2.9.1 ha9979f8_1
freexl 1.0.5 hd288d7e_1002 conda-forge
future 0.18.2 py38_0
gdal 3.0.4 py38h3ba59e7_9 conda-forge
geopandas 0.7.0 py_1 conda-forge
georaster 1.27 pyh9f0ad1d_0 conda-forge
georasters 0.5.15 py_2 conda-forge
geos 3.8.1 he025d50_0 conda-forge
geotiff 1.5.1 h3d29ae3_10 conda-forge
gettext 0.19.8.1 hb01d8f6_1002 conda-forge
giddy 2.3.0 py_0 conda-forge
glib 2.64.3 he4de6d7_0 conda-forge
hdf4 4.2.13 hf8e6fe8_1003 conda-forge
hdf5 1.10.6 nompi_ha405e13_100 conda-forge
icc_rt 2019.0.0 h0cc432a_1
icu 64.2 he025d50_1 conda-forge
idna 2.9 py_1
imagecodecs-lite 2019.12.3 py38h9de7a3e_0 conda-forge
imageio 2.8.0 py_0
imagesize 1.2.0 py_0
importlib-metadata 1.6.0 py38_0
importlib_metadata 1.6.0 0
inequality 1.0.0 py_0 conda-forge
intel-openmp 2020.1 216
intervaltree 3.0.2 py_0
ipykernel 5.1.4 py38h39e3cac_0
ipython 7.13.0 py38h5ca1d4c_0
ipython_genutils 0.2.0 py38_0
ipywidgets 7.5.1 py_0 conda-forge
isort 4.3.21 py38_0
jedi 0.15.2 py38_0
jinja2 2.11.2 py_0
joblib 0.15.1 py_0
jpeg 9c hfa6e2cd_1001 conda-forge
jsonschema 3.2.0 py38_0
jupyter_client 6.1.3 py_0
jupyter_core 4.6.3 py38_0
kealib 1.4.13 h3b59ab9_1 conda-forge
keyring 21.1.1 py38_2
kiwisolver 1.2.0 py38h74a9793_0
krb5 1.17.1 hdd46e55_0 conda-forge
lazy-object-proxy 1.4.3 py38he774522_0
libclang 9.0.1 default_hf44288c_0 conda-forge
libcurl 7.69.1 h1dcc11c_0 conda-forge
libffi 3.2.1 h6538335_1007 conda-forge
libgdal 3.0.4 h6f60a84_9 conda-forge
libiconv 1.15 hfa6e2cd_1006 conda-forge
libkml 1.3.0 h7e985d0_1011 conda-forge
libnetcdf 4.7.4 nompi_h256d12c_104 conda-forge
libpng 1.6.37 h2a8f88b_0
libpq 12.2 hd9aa61d_1 conda-forge
libpysal 4.2.2 py_0 conda-forge
libsodium 1.0.16 h9d3ae62_0
libspatialindex 1.9.3 he025d50_3 conda-forge
libspatialite 4.3.0a h51df0ed_1038 conda-forge
libssh2 1.9.0 h3235a2c_2 conda-forge
libtiff 4.1.0 h885aae3_6 conda-forge
libwebp-base 1.1.0 hfa6e2cd_3 conda-forge
libxml2 2.9.10 h5d81f1c_1 conda-forge
libxslt 1.1.33 h579f668_1 conda-forge
llvmlite 0.32.1 py38ha925a31_0
lz4-c 1.9.2 h62dcd97_1 conda-forge
m2w64-expat 2.1.1 2
m2w64-gcc-libgfortran 5.3.0 6
m2w64-gcc-libs 5.3.0 7
m2w64-gcc-libs-core 5.3.0 7
m2w64-gettext 0.19.7 2
m2w64-gmp 6.1.0 2
m2w64-libiconv 1.14 6
m2w64-libwinpthread-git 5.0.0.4634.697f757 2
m2w64-xz 5.2.2 2
mapclassify 2.2.0 py_0 conda-forge
markupsafe 1.1.1 py38he774522_0
matplotlib 3.1.3 py38_0
matplotlib-base 3.1.3 py38h64f37c6_0
mccabe 0.6.1 py38_1
mgwr 2.1.1 py_0 conda-forge
mistune 0.8.4 py38he774522_1000
mkl 2020.1 216
mkl-service 2.3.0 py38hb782905_0
mkl_fft 1.0.15 py38h14836fe_0
mkl_random 1.1.1 py38h47e9c7a_0
mock 4.0.2 py38h32f6830_0 conda-forge
mpmath 1.1.0 py_0 conda-forge
msys2-conda-epoch 20160418 1
munch 2.5.0 py_0 conda-forge
nbconvert 5.6.1 py38_0
nbformat 5.0.6 py_0
networkx 2.4 py_1 conda-forge
nose 1.3.7 py38h32f6830_1004 conda-forge
notebook 6.0.3 py38h32f6830_0 conda-forge
numba 0.49.1 py38h47e9c7a_0
numexpr 2.7.1 py38hb99c5c2_1 conda-forge
numpy 1.18.1 py38h93ca92e_0
numpy-base 1.18.1 py38hc3f5095_1
numpydoc 0.9.2 py_0
olefile 0.46 py_0
openjpeg 2.3.1 h57dd2e7_3 conda-forge
openssl 1.1.1g he774522_0 conda-forge
packaging 20.3 py_0
pandas 1.0.3 py38h47e9c7a_0
pandoc 2.2.3.2 0
pandocfilters 1.4.2 py38_1
paramiko 2.7.1 py_0
parso 0.5.2 py_0
pathtools 0.1.2 py_1
patsy 0.5.1 py_0 conda-forge
pcre 8.44 h6538335_0 conda-forge
pexpect 4.8.0 py38_0
pickleshare 0.7.5 py38_1000
pillow 7.1.2 py38hcc1f983_0
pip 20.0.2 py38_3
pluggy 0.13.1 py38_0
pointpats 2.1.0 py_1 conda-forge
poppler 0.87.0 h0cd1227_1 conda-forge
poppler-data 0.4.9 1 conda-forge
postgresql 12.2 he14cc48_1 conda-forge
proj 7.0.0 haa36216_3 conda-forge
prometheus_client 0.8.0 pyh9f0ad1d_0 conda-forge
prompt-toolkit 3.0.4 py_0
prompt_toolkit 3.0.4 0
psutil 5.7.0 py38he774522_0
pycodestyle 2.5.0 py38_0
pycparser 2.20 py_0
pydocstyle 4.0.1 py_0
pyflakes 2.1.1 py38_0
pygments 2.6.1 py_0
pylint 2.5.2 py38_0
pynacl 1.3.0 py38h62dcd97_0
pyopenssl 19.1.0 py38_0
pyparsing 2.4.7 py_0
pyproj 2.6.1.post1 py38h1dd9442_0 conda-forge
pyqt 5.12.3 py38h7ae7562_3 conda-forge
pyqt5-sip 4.19.18 pypi_0 pypi
pyqtchart 5.12 pypi_0 pypi
pyqtwebengine 5.12.1 pypi_0 pypi
pyrsistent 0.16.0 py38he774522_0
pysal 2.2.0 py_0 conda-forge
pyside2 5.13.2 py38hfa7ce6d_2 conda-forge
pysocks 1.7.1 py38_0
pytables 3.6.1 py38hd2a2a0e_2 conda-forge
python 3.8.3 he1778fa_0
python-dateutil 2.8.0 py_0 conda-forge
python-jsonrpc-server 0.3.4 py_0
python-language-server 0.31.10 py38_0
python_abi 3.8 1_cp38 conda-forge
pytz 2020.1 py_0
pywavelets 1.1.1 py38h40bdaab_1 conda-forge
pywin32 227 py38he774522_1
pywin32-ctypes 0.2.0 py38_1000
pywinpty 0.5.7 py38_0 conda-forge
pyyaml 5.3.1 py38he774522_0
pyzmq 18.1.1 py38ha925a31_0
qdarkstyle 2.8.1 py_0
qt 5.12.5 h7ef1ec2_0 conda-forge
qtawesome 0.7.0 py_0
qtconsole 4.7.4 py_0
qtpy 1.9.0 py_0
quantecon 0.4.5 py38_0
rasterio 1.1.4 py38h151dc71_0 conda-forge
rasterstats 0.14.0 py_0 conda-forge
requests 2.23.0 py38_0
rope 0.17.0 py_0
rtree 0.9.4 py38h7ad75cc_1 conda-forge
scikit-image 0.17.2 py38he6e81aa_0 conda-forge
scikit-learn 0.22.1 py38h6288b17_0
scipy 1.4.1 py38h9439919_0
seaborn 0.10.1 py_0 conda-forge
segregation 1.2.0 py_1 conda-forge
send2trash 1.5.0 py_0 conda-forge
setuptools 46.4.0 py38_0
shapely 1.7.0 py38hbf43935_3 conda-forge
simplejson 3.17.0 py38h9de7a3e_1 conda-forge
sip 4.19.13 py38ha925a31_0
six 1.14.0 py38_0
snowballstemmer 2.0.0 py_0
snuggs 1.4.7 py_0 conda-forge
sortedcontainers 2.1.0 py38_0
soupsieve 2.0.1 py38h32f6830_0 conda-forge
spaghetti 1.5.0 py_0 conda-forge
spglm 1.0.7 py_0 conda-forge
sphinx 3.0.3 py_0
sphinxcontrib-applehelp 1.0.2 py_0
sphinxcontrib-devhelp 1.0.2 py_0
sphinxcontrib-htmlhelp 1.0.3 py_0
sphinxcontrib-jsmath 1.0.1 py_0
sphinxcontrib-qthelp 1.0.3 py_0
sphinxcontrib-serializinghtml 1.1.4 py_0
spint 1.0.6 py_0 conda-forge
splot 1.1.3 py_0 conda-forge
spreg 1.1.1 py_0 conda-forge
spvcm 0.3.0 py_0 conda-forge
spyder 4.1.3 py38_0
spyder-kernels 1.9.1 py38_0
sqlite 3.31.1 h2a8f88b_1
statsmodels 0.11.1 py38h9de7a3e_1 conda-forge
sympy 1.6 py38h32f6830_0 conda-forge
tbb 2020.1 he980bc4_0 conda-forge
terminado 0.8.3 py38h32f6830_1 conda-forge
testpath 0.4.4 py_0
tifffile 2020.5.11 py_0 conda-forge
tiledb 1.7.7 h0b90766_3 conda-forge
tk 8.6.10 hfa6e2cd_0 conda-forge
tobler 0.3.0 py_0 conda-forge
toml 0.10.0 pyh91ea838_0
toolz 0.10.0 py_0 conda-forge
tornado 6.0.4 py38he774522_1
tqdm 4.46.0 pyh9f0ad1d_0 conda-forge
traitlets 4.3.3 py38_0
ujson 1.35 py38he774522_0
urllib3 1.24.3 py38_0 conda-forge
vc 14.1 h0510ff6_4
vs2015_runtime 14.16.27012 hf0eaf9b_2
watchdog 0.10.2 py38_0
wcwidth 0.1.9 py_0
webencodings 0.5.1 py38_1
wheel 0.34.2 py38_0
widgetsnbextension 3.5.1 py38_0 conda-forge
win_inet_pton 1.1.0 py38_0
wincertstore 0.2 py38_0
winpty 0.4.3 4 conda-forge
wrapt 1.11.2 py38he774522_0
xerces-c 3.2.2 h6538335_1004 conda-forge
xlrd 1.2.0 py_0
xz 5.2.5 h2fa13f4_0 conda-forge
yaml 0.1.7 hc54c509_2
yapf 0.28.0 py_0
zeromq 4.3.1 h33f27b4_3
zipp 3.1.0 py_0
zlib 1.2.11 h62dcd97_4
zstd 1.4.4 h9f78265_3 conda-forge
TypeError Traceback (most recent call last)
in
----> 1 data.plot()
2
~\Anaconda3\lib\site-packages\georasters\georasters.py in plot(self, **kwargs)
502 Returns plot of raster data
503 '''
--> 504 return plt.matshow(self.raster, **kwargs)
505
506 def union(self, other):
~\Anaconda3\lib\site-packages\matplotlib\pyplot.py in matshow(A, fignum, **kwargs)
2182 fig = figure(fignum, figsize=figaspect(A))
2183 ax = fig.add_axes([0.15, 0.09, 0.775, 0.775])
-> 2184 im = ax.matshow(A, **kwargs)
2185 sci(im)
2186 return im
~\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in matshow(self, Z, **kwargs)
7922 'aspect': 'equal', # (already the imshow default)
7923 **kwargs}
-> 7924 im = self.imshow(Z, **kw)
7925 self.title.set_y(1.05)
7926 self.xaxis.tick_top()
~\Anaconda3\lib\site-packages\matplotlib_init_.py in inner(ax, data, *args, **kwargs)
1587 def inner(ax, *args, data=None, **kwargs):
1588 if data is None:
-> 1589 return func(ax, *map(sanitize_sequence, args), **kwargs)
1590
1591 bound = new_sig.bind(ax, *args, **kwargs)
~\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
--> 369 return func(*args, **kwargs)
370
371 return wrapper
~\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
--> 369 return func(*args, **kwargs)
370
371 return wrapper
~\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5658 resample=resample, **kwargs)
5659
-> 5660 im.set_data(X)
5661 im.set_alpha(alpha)
5662 if im.get_clip_path() is None:
~\Anaconda3\lib\site-packages\matplotlib\image.py in set_data(self, A)
681 or self._A.ndim == 3 and self._A.shape[-1] in [3, 4]):
682 raise TypeError("Invalid shape {} for image data"
--> 683 .format(self._A.shape))
684
685 if self._A.ndim == 3:
TypeError: Invalid shape (4, 5684, 6276) for image data
I open ASTER DEM file with such simple code:
ds = gr.from_file(input_file)
ds.to_tiff('/tmp/test')
And it makes exception:
File "store_gridfs.py", line 13, in main
ds.to_tiff('/tmp/test')
File ".../georasters.py", line 478, in to_tiff
self.raster.data[self.raster.mask] = self.nodata_value
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
I tried shielding it with an if
closure, but then it made another exception:
File ".../georasters.py", line 122, in create_geotiff
if isinstance(datatype, np.int) == False:
File "/usr/local/lib/python3.6/dist-packages/numpy/ma/core.py", line 3353, in __setitem__
_data[indx] = dval
You usually expect open and save methods to work seamlessly.
test.py is the first example in the readme with a different raster as the default.
$ cat test.py
import georasters as gr
# Load data
raster = "./ilatlon.tif"
data = gr.from_file(raster)
# Plot data
data.plot()
# Get some stats
data.mean()
data.sum()
data.std()
# Convert to Pandas DataFrame
df = data.to_pandas()
# Save transformed data to GeoTiff
data2 = data**2
data2.to_tiff('./data2')
# Algebra with rasters
data3 = np.sin(data.raster) / data2
data3.plot()
# Notice that by using the data.raster object,
# you can do any mathematical operation that handles
# Numpy Masked Arrays
# Find value at point (x,y) or at vectors (X,Y)
value = data.map_pixel(x,y)
Value = data.map_pixel(X,Y)
When run, it crashes because numpy is not imported:
$ python test.py
Traceback (most recent call last):
File "test.py", line 23, in <module>
data3 = np.sin(data.raster) / data2
NameError: name 'np' is not defined
Once numpy is imported, the test runs, but it does have some errors:
$ python test.py
Traceback (most recent call last):
File "test.py", line 21, in <module>
data2.to_tiff('./data2')
File "/home/benjamin/.pyenv/versions/georasters/lib/python3.6/site-packages/georasters/georasters.py", line 477, in to_tiff
self.raster.data[self.raster.mask] = self.nodata_value
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
If I'm doing something wrong, I'd love to know.
using python 3.5.2 under mac, extra install needed
pip install affine rasterstats
Use RasterIO for all input/output operations
this should allow additional manipulation, e.g. reprojecting data
Make install easier using conda
, but use conda-forge
instead of own channel.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.