How to Display a Geotiff image using Python - python-2.7

I am new to Python2.7 and have tried installing rasterio,using wheel file,but still the following error comes:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import rasterio
File "D:\Python\lib\site-packages\rasterio\__init__.py", line 23, in <module>
from rasterio._base import (
ImportError: DLL load failed: The specified module could not be found.

I accidentally deleted my old comment,here is the code :
from osgeo import gdal
import matplotlib.pyplot as plt
ds = gdal.Open('filename.tif').ReadAsArray()
im = plt.imshow(ds)
This will work.

I am not familiar with Rasterio, but if you are looking for some library to do image analysis or just display a geotiff image, you could probably take a look at opencv python library.
Link : OpenCV3

TuiView is an open source PyQt-based lightweight Raster GI. Its available on Windows, Mac and Linux: http://tuiview.org

Related

How To Install Pytesseract in windows 8.1(win64) (visual studio 2012+python+anaconda)

from PIL import Image
from tesseract import image_to_string
print image_to_string(Image.open('C:\Users/Uzel/Desktop/pythonfoto/denklem.png'))
print image_to_string(Image.open('C:\Users/Uzel/Desktop/pythonfoto/denklem.png'), lang='eng')
I use this code after installing tesseract orc.
Traceback (most recent call last):
File "C:\Users\Uzel\Documents\Visual Studio 2012\Projects\module3.py", line 28, in
from tesseract import image_to_string
ImportError: cannot import name image_to_string
I have this error. I tried pytesseract but I can not manage. Can we solve this problem. How? thank you.
Below is a sample code with pytesseract.
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract 4.0.0/tesseract.exe"
print(pytesseract.image_to_string(Image.open("./imagesStackoverflow/text.png"),
lang="eng",boxes=False,config="--psm 3 --eom 3"))
The pytesseract.pytesseract.tesseract_cmd is to specific the EXE path explicitly in case the path hasn't been properly set up in Windows environment.
You need to have Tesseract installed in Windows and pytesseract installed with Python.
Hope this help.

How can I import the csvsql to Python 2.7

I have successfuly installed csvkit using conda install ...
However, when I try to import the libraries in Python 2.7 Spyder, I get error messages:
import csvsql
Traceback (most recent call last):
File "<ipython-input-5-303a60a6b1ac>", line 1, in <module>
import csvsql
ImportError: No module named csvsql
import csvkit
Traceback (most recent call last):
File "<ipython-input-7-ca8a99ae9834>", line 1, in <module>
import csvkit
ImportError: No module named csvkit
I looked at the documentation -- they describe the installation process but not how the library is loaded in Python.
Moreover, I had an analogous problem with httplib2. I installed it successfuly but when I tried to import it in Spyder I received an analogous error message (No module named httplib2).
(I use Anaconda 3 and Spyder on Windows 11)
Any ideas? Thank you in advance.
I asked this question on the csvkit GitHub / issues forum.
The answer given was: You should use agate on which csvkit now relies for all its operations. See https://github.com/wireservice/agate.
I'm with you -- it would be wonderful to use csvkit as a command-line tool and a library, but it's authors don't see it that way. The full issue: https://github.com/wireservice/csvkit/issues/670

Error in Installing PyEnchant package on Windows-7 (64bit) for spelling check

I'm using Windows-7, 64 bit PC. I want to perform spelling check for a text, using python. I tried to install PyEnchant package using "pip install pyenchant" command. It gets installed. but when I try to import enchant in ipython console, it gives error as "ImportError: cannot import name utils".
Is there any other method to install and use PyEnchant?
In [43]: import enchant
Traceback (most recent call last):
File "<ipython-input-43-be94a407aebb>", line 1, in <module>
import enchant
File "C:\Anaconda2\lib\site-packages\enchant\__init__.py", line 92, in <module>
from enchant import _enchant as _e
File "C:\Anaconda2\lib\site-packages\enchant\_enchant.py", line 55, in <module>
from enchant import utils
ImportError: cannot import name utils
It looks to me like you have not got the underlying C library Enchant installed. Pyenchant is just a python wrapper for the Enchant C library. You can either build and install the C library yourself get the code from http://www.abisource.com/projects/enchant/#download or as you ask if there is another way to install it use the pyenchant-1.6.6.win32.exe link on http://pythonhosted.org/pyenchant/download.html which will install the Enchant C library for you.

Cannot import pygame into python 2.7

I have tried to import pygame 1.9 into both Python 2.7 and 3.5. I used both Windows 8.1 and 10. In every case, it does not import the file. This is the message I get:
>>> import pygame
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import pygame
File "C:\Python27\lib\site-packages\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Pygame is in the python27\include\pygame directory. Any help would be greatly appreciated.
Please follow this question here. It should be an error with missing dlls.
ImportError: DLL load failed: The specified module could not be found

dispersion_plot not working inspite of installing matplotlib

i have installed matplotlib using pip in ubuntu 14.04 LTS.. but on running dispersion_plot this is showing the following error ..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nltk/text.py", line 455, in dispersion_plot
from nltk.draw import dispersion_plot
ImportError: cannot import name dispersion_plot
I am new to python... can anyone suggest if there is a better way of installing matplotlib in nltk.
The examples of the online book are not quite right.
You may try this:
from nltk.draw.dispersion import dispersion_plot
words = ['Elinor', 'Marianne', 'Edward', 'Willoughby']
dispersion_plot(gutenberg.words('austen-sense.txt'), words)
You may also call it from a text directly:
from nltk.book import text1
from nltk.draw.dispersion import dispersion_plot
dispersion_plot(text1, ['monstrous'])
this way you import the function directly instead of calling the funcion from text object.
I realized this watching at the source code directly.
Hope this work for you
After importing it using spyder, this is how the plot would look.