NASA-DEVELOP / dnppy

DEVELOP National Program Python package for use with NASA data and GIS!
https://nasa-develop.github.io/dnppy/
Other
81 stars 40 forks source link

cloud_mask.py help #77

Closed arikaegan closed 8 years ago

arikaegan commented 8 years ago

In dnppy/dnppy/landsat/cloud_mask.py:

When I try to set the BQA_path in the code, I get a syntax error. I may be misunderstanding what I'm supposed to put for the BQA_path, but here's what I'm substituting for the default:

def make_cloud_mask_8(C:/Users/DEVELOP4/Desktop/landsat/trial/2015_08_17_testing/LC80150342015229LGN00_BQA.TIF, outdir = C:/Users/DEVELOP4/Desktop//landsat/trial//2015_08_17_testing/):

The syntax error highlights the colon in "C:/Users..."

Any suggestions as to what I am doing wrong?

Thank you!

stapleCamel commented 8 years ago

Is the file path surrounded by single or double quotes (like "C:/Users/DEVELOP/") in your code?

Syntaf commented 8 years ago

As @stapleCamel mentioned, it looks like your aren't using strings. Python is using a literal interpretation of your file path and thinks you're doing some wonky expression. You wan't to use strings as a path

def make_cloud_mask_8(
    "C:/Users/DEVELOP4/Desktop/landsat/trial/2015_08_17_testing/LC80150342015229LGN00_BQA.TIF", 
    outdir = "C:/Users/DEVELOP4/Desktop//landsat/trial//2015_08_17_testing/"):

If you don't encapsulate your path inside of a string, Python has no way of knowing you aren't trying to write some sort of syntax expression. e.g. writing for i in some_list: is very different from writing "for i in some_list:". One is an expression that python interprets and executes, the other is a string containing that information

arikaegan commented 8 years ago

Now it says:

"Traceback (most recent call last): File "C:\Users\DEVELOP4\Desktop\landsat\trial\cloud_mask.py", line 1, in from dnppy import core File "C:\Python27\lib\site-packages\dnppyinit.py", line 23, in from convert import File "C:\Python27\lib\site-packages\dnppy\convertinit.py", line 16, in from extract_GCMO_NetCDF import File "C:\Python27\lib\site-packages\dnppy\convert\extract_GCMO_NetCDF.py", line 9, in import arcpy ImportError: No module named arcpy"

I have already downloaded dnnpy and arcpy, but it seems to have trouble finding them. Any suggestions as to fixing this?

stapleCamel commented 8 years ago

Which Python are you using? I believe ArcGIS comes with its own Python27 which has the arcpy module whereas the regular Python distribution can't use it.

Jwely commented 8 years ago

@stapleCamel is right. I can tell from your filepaths that you are not running your script from the python installation with arcpy in it.

If it were running from the correct installation, it would say something like "C:\Python27\ArcGIS10.3\lib\site-packages\dnppy...".

The way to fix this is to ensure you are using the correct interpreter, or to simply uninstall the versions of python on your system that are NOT in the ArcGIS directory. If your simply using IDLE, you can ensure you use the correct one by opening it from "C:\Python27\ArcGIS10.3\Lib\idlelib\idle.py". Make a shortcut for that interpreter and use that to edit your scripts in.

Note that your exact filepath may be a little different if your ArcGIS version is different.