gdal

How do I open geotiff images with gdal in python?

ぐ巨炮叔叔 提交于 2019-12-04 23:08:44
I am trying to run the following code: from osgeo import gdal import sys # this allows GDAL to throw Python Exceptions src_ds = gdal.Open( "fused.tif" ) src_ds.show() But I receive the following error: Traceback (most recent call last): File ".../gdalopen1.py", line 5, in module src_ds.show() AttributeError: 'Dataset' object has no attribute 'show' Why does this happen? You have already opened the dataset, as Spacedman answered. GDAL is not a visualization library (at its core). You can read the data with: data = src_ds.ReadAsArray() And then pass it on the your favourite plotting library.

Extract Point From Raster in GDAL

柔情痞子 提交于 2019-12-04 21:49:20
I have a raster file and a WGS84 lat/lon point. I would like to know what value in the raster corresponds with the point. My feeling is that I should use GetSpatialRef() on the raster object or one of its bands and then apply a ogr.osr.CoordinateTransformation() to the point to map it to the raster's space. My hope would then be that I could simply ask the rasters' bands what is at that point. However, the raster object doesn't seem to have a GetSpatialRef() or a way to access a geo-located point, so I'm somewhat at a loss for how to do this. Any thoughts? Say i have a geotiff file test.tif.

Python GDAL does not install on Mac OSX El Capitan

半腔热情 提交于 2019-12-04 17:35:57
I am having several issues when installing pygdal in my Mac OSX El capitan. The procedure is the folowing: Install GDAL Libraries from http://www.kyngchaos.com/software/frameworks#gdal_complete pip install gdal The output is the following: . . . extensions/gdal_wrap.cpp:3085:10: fatal error: 'cpl_port.h' file not found #include "cpl_port.h" ^ 2 warnings and 1 error generated. error: command 'cc' failed with exit status 1 Looks like the installer cannot find the GDAL libraries, or headers (libgdal or gdal-devel in ubuntu). Where are they placed in OSX? FYI, the following /Library/Frameworks

Having trouble installing GDAL for python

一曲冷凌霜 提交于 2019-12-04 13:19:48
问题 Let me start by saying that I have searched for help this problem and gone through the numerous threads that I have found, and none of them have worked, or I wasn't able to understand what they are saying to do. Once such thread is here: Python GDAL package missing header file when installing via pip I was able to run pip install --no-install GDAL But then I was instructed to "cd into ENV/build/GDAL". I know what cd means but I have no idea where this /ENV/build/GDAL diretory would be located

gdal ReadAsarray for vrt extremely slow

淺唱寂寞╮ 提交于 2019-12-04 12:25:34
I am trying to simply subtract two rasters and save the result in another raster. One of the input images is a tif-file, the other is a vrt-file. (Output is tif) The files are very big, so I open them, divide them into tiles and run through each of them and then subtracting. The problem is that it is extremely slow! import gdal import numpy as np rA = gdal.Open(raFileName) rB = gdal.Open(rbFileName) nodataA = rA.GetRasterBand(1).GetNoDataValue() nodataB = rB.GetRasterBand(1).GetNoDataValue() raster = gdal.GetDriverByName('GTiff').Create(outputFileName, ncols, nrows, 1 ,gdal.GDT_Float32,[

Django migration can't find GDALRaster

亡梦爱人 提交于 2019-12-04 10:18:03
I took over a project with Django, Django REST framework and Leaflet to store drawn path in a database. Installing Django in an virtualenv and trying to migrate it raises: File "D:\SHK\ElektroClean\venv\lib\site-packages\django\contrib\gis\db\backends\postgis\operations.py", line 7, in from django.contrib.gis.gdal import GDALRaster ImportError: cannot import name 'GDALRaster' In the directory D:\SHK\ElektroClean\py27\Lib\site-packages\django\contrib\gis\gdal is a folder called raster. Is renaiming this folder to GDALRaster the fix? Anyone suggestions to fix this? solved did mistakes on

Unable to install GDAL in python 3 using pip (clang failed with exit status 1)

依然范特西╮ 提交于 2019-12-04 09:21:31
After running sudo pip3.4 install gdal from terminal (Mac OS X Mavericks) I obtain an error message saying that the 'col_port.h' file was not found and displaying the following error: command '/user/bin/clang/ failed with exit status 1 (the full message is below). I have gdal 1.11 (the complete framework version downloaded from kingchaos.com) and the most recent version of the Xcode command line tools -Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Here is the error that I get after running the sudo pip3.4 install gdal command: /usr/bin/clang -fno-strict-aliasing -Werror

Issue when imoporting GDAL : ImportError, Library not loaded, Image not found

两盒软妹~` 提交于 2019-12-04 08:44:35
Since yesterday I struggle to import some libraries such as GDAL (or iris) and I allways get the same type of outputs. >>> import gdal Traceback (most recent call last): File "<stdin>", line 1, in <module> File "gdal.py", line 28, in <module> _gdal = swig_import_helper() File "gdal.py", line 24, in swig_import_helper _mod = imp.load_module('_gdal', fp, pathname, description) ImportError: dlopen(./_gdal.so, 2): Library not loaded: @rpath/libicui18n.56.dylib Referenced from: /Users/zoran/anaconda/lib/libgdal.20.dylib Reason: image not found I searched in my files and found: 1 files containing

Problems converting from shape to topojson

百般思念 提交于 2019-12-04 08:31:19
问题 I'm trying to convert a shapefile of mexican municipalities into a topojson and displaying it using d3.js using this tutorial http://bost.ocks.org/mike/map/#converting-data. I've managed to convert it but I can't manage to display it. Any help will be greatly appreciated. This is my workflow so far: 1) Download and unzip the shapefile wget http://mapserver.inegi.org.mx/MGN/mgm2010v5_0a.zip unzip mgm2010v5_0a.zip 2) Converting to JSON, reprojecting to lat-long and subsetting the shapefile

How to open a TIF (CMYK, 16-bit) image file?

醉酒当歌 提交于 2019-12-04 05:52:31
问题 I have a script that processes dozens of image files (using Pillow). Recently, I've noticed that my script fails with TIF (CMYK/16) format. So I've created a test case. images = [ "cmyk-8.tif", "cmyk-16.tif", "rgb-8.tif", "rgb-16.tif", ] for img_name in images: path = img_dir + "\\" + img_name try: img = Image.open(path) except OSError as e: print(e) else: print("success: " + img_name) This produces the following output: success: cmyk-8.tif cannot identify image file '...\\cmyk-16.tif'