Closed NanfengLiu closed 7 years ago
@NanfengLiu the problem seems related to executable function returning nothing.
Can you check in a Python shell and return the output?
mrtpathbin='C:\Modis\'
import sys
sys.platform.count('win32')
import os
os.path.exists(os.path.join(mrtpathbin, 'resample.exe'))
@NanfengLiu should be fixed in 7dd048f, could you try?
@lucadelu Hi, Thank you so much for this quick response. I did try. But it seems to not work. Here is what I did.
First, I uninstalled pyModis by using:
pip uninstall pyModis
Second, I downloaded the latest version pyModis package from https://github.com/lucadelu/pyModis/commit/7dd048f854c8726e3faba94bb2f7cd2464f02378 I checked the convertmodis.py. It already made changes as shown in Github.
Third, I did the compilation from source as you instructed in http://www.pymodis.org/info.html#how-to-install-pymodis there is no error message. Also, I tested the modis_download.py. It worked. So I guess the installation is successful.
Finally, I tested the modis_convert.py as follows:
modis_convert.py -s '( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 )' -o 'e:\test\test.hdf' -f 'hdf' -g 500 -e 32616 -m 'C:\Modis\' -u 16 'e:\test\MCD43A4.A2016001.h11v04.006.2016174075735.hdf'
The error message I got was:
WxPython missing, no GUI enabled
Traceback (most recent call last):
File "C:/Users/nliu58/AppData/Local/Continuum/Anaconda2/Scripts/modis_convert.py", line 4, in
File "C:\Users\nliu58\AppData\Local\Continuum\Anaconda2\lib\site-packages\pymodis-2.0.4-py2.7.egg\EGG-INFO\scripts\modis_convert.py", line 160, in main
File "build\bdist.win-amd64\egg\pymodis\convertmodis.py", line 106, in run File "build\bdist.win-amd64\egg\pymodis\convertmodis.py", line 101, in executable Exception: No possible to find MRT resample executable
@lucadelu
Hi Lucadelu,
I guess I have figured out what the problem is.
I think the original version is right:
if sys.platform.count('linux') or sys.platform.count('darwin'):
But the new version is wrong:
if sys.platform.count('linux') != -1 or sys.platform.count('darwin') != -1:
since sys.platform.count('linux')
returns either 0 and 1.
I suggest to make some changes to 91-101 (164 - 174 and 222-227, also):
Original:
def executable(self): """Return the executable of resample MRT software""" if sys.platform.count('linux') != -1 or sys.platform.count('darwin') != -1: if os.path.exists(os.path.join(self.mrtpathbin, 'resample')): return os.path.join(self.mrtpathbin, 'resample') elif sys.platform.count('win32') != -1: if os.path.exists(os.path.join(self.mrtpathbin, 'resample.exe')): return os.path.join(self.mrtpathbin, 'resample.exe') elif os.path.exists(os.path.join(self.mrtpathbin, 'resample')): return os.path.join(self.mrtpathbin, 'resample') raise Exception("No possible to find MRT resample executable")
New:
if os.path.exists(os.path.join(self.mrtpathbin, 'resample.exe')): return os.path.join(self.mrtpathbin, 'resample.exe') elif os.path.exists(os.path.join(self.mrtpathbin, 'resample')): return os.path.join(self.mrtpathbin, 'resample') else: raise Exception("No possible to find MRT resample executable")
I mean, since we know that the executable file is either resample.exe or resample, maybe it just needs to determine whether these two files exist. It is unnecessary to determine what the OS is.
Anyway, thank you very much for your help.
@NanfengLiu Thanks a lot for your support... please try 13ccf0a
As reported here 33611f7 it is now working, so I'm going to close this ticket and release new version of pyModis.
Please reopen if needed
Hi, I am stuck in modis_covert.py. Tried many methods but failed.
I installed pyModis and MRT. I have tested the modis_download.py in Git Bash. It works well. Also, the MRT works (it is installed under c:\Modis).
Now I am trying to reproject these downloaded hdf files to UTM by using the modis_convet.py. However, it keeps giving me an error message like this:
WxPython missing, no GUI enabled Traceback (most recent call last): File "C:/Users/nliu58/AppData/Local/Continuum/Anaconda2/Scripts/modis_convert.py", line 166, in
main()
File "C:/Users/nliu58/AppData/Local/Continuum/Anaconda2/Scripts/modis_convert.py", line 160, in main
modisConver.run()
File "C:\Users\nliu58\AppData\Local\Continuum\Anaconda2\lib\site-packages\pymodis\convertmodis.py", line 104, in run
if not os.path.exists(execut):
File "C:\Users\nliu58\AppData\Local\Continuum\Anaconda2\lib\genericpath.py", line 26, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found
The command line I tried is as follows:
modis_convert.py -s '( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 )' -o 'e:\test\test.hdf' -g 500 -e 32616 -m 'C:\Modis\' -u 16 'e:\test\MCD43A4.A2016001.h11v04.006.2016174075735.hdf'
I checked the conf file. It seems fine.INPUT_FILENAME = e:\test\MCD43A4.A2016001.h11v04.006.2016174075735.hdf SPECTRAL_SUBSET = ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ) SPATIAL_SUBSET_TYPE = INPUT_LAT_LONG SPATIAL_SUBSET_UL_CORNER = ( 50.0921136439 -109.085507895 ) SPATIAL_SUBSET_LR_CORNER = ( 39.7728386044 -78.1496566591 ) OUTPUT_FILENAME = e:\test\test.hdf RESAMPLING_TYPE = NEAREST_NEIGHBOR OUTPUT_PROJECTION_TYPE = GEO OUTPUT_PROJECTION_PARAMETERS = ( 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ) DATUM = WGS84 UTM_ZONE = 16 OUTPUT_PIXEL_SIZE = 500.0