GitHubRGI / geopackage-python

Achived - See GitLab repository for current development
https://gitlab.com/GitLabRGI/erdc/geopackage-python
GNU General Public License v3.0
65 stars 42 forks source link

Major Newbie Help! #37

Closed MarkDFink closed 7 years ago

MarkDFink commented 7 years ago

I'm running Windows 10 64 bit with GDAL 2.2.1 (release-1600-x64-gdal-2-2-1-mapserver-7-0-6.zip). I'm running this script in order to create my tiles:

F:\Adobe\GDAL\gdal2tiles_parallel.py "c:\KML\Hurds Farm - Tonys Orchard - 20171018 - NDVI_0_0.tif" c:\KML\output

Nothing happens. The F path is where the GDAL is folder is located, and the C path, (in quotes because it has spaces), is where my TIF is. C:\KML\Output is where I want the KML files created.

I went through all the prerequisites to make sure I installed the necessary support files, and in the proper order as per https://github.com/GitHubRGI/geopackage-python/wiki/Installing-dependencies-on-Windows. I'm pretty sure I'm missing something either in where the files are located or how I'm calling the files. Any suggestions would be very welcome.

Thanks!

Mark

MarkDFink commented 7 years ago

I realized I left some information out. Here is what happens when I run the command:

Traceback (most recent call last): File "F:\Adobe\GDAL\bin\gdal2tiles_parallel.py", line 61, in import gdal ImportError: No module named gdal

Is this an issue with placing the .py script in an incorrect folder or maybe a path issue?

davidintelinair commented 7 years ago

Make sure your environment is set up correctly. Here is a decent guide: https://sandbox.idre.ucla.edu/sandbox/tutorials/installing-gdal-for-windows Look at step 3: Environment variables

You also need to install the gdal python bindings: pip install gdal (use pip3 for python3: pip3 install gdal)

Here are some sample python scripts to test if you have things configured correctly: https://pcjericks.github.io/py-gdalogr-cookbook/gdal_general.html#is-gdal-ogr-installed

MarkDFink commented 7 years ago

Thanks for the replies! I'll tackle them and let you know my progress.

MarkDFink commented 7 years ago

I got to the core installation step, (#4), but get an error that "IIS must be installed of at least IIS 7 or higher". I downloaded IIS from https://www.microsoft.com/en-us/download/confirmation.aspx?id=48264 and installed it, but am still getting that error message. Is there a different version I should get?

davidintelinair commented 7 years ago

I don't understand why gdalinfo would require iis. You are just running "gdalinfo --version" right?

Try moving on to installing the python binding.

The run the check install script

import sys
try:
    from osgeo import ogr, osr, gdal
except:
    sys.exit('ERROR: cannot find GDAL/OGR modules')
MarkDFink commented 7 years ago

Some days, I'm just plain dangerous... The directions said to download the ...core.msi file. There were two, and I of course chose the wrong one for mapserver instead of gdal. My shoe budget gets completely overspent when I shoot myself in the foot like this. :o)

davidintelinair commented 7 years ago

I responded to you because I completely feel your pain. Being new to both gdal and python, I downloaded the wrong things a few times as well. I eventually got it working following the pages I linked above. The thing that I liked was the confirmation that it was installed correctly before I proceeded to gdal2tiles_parallel and its quirks.

MarkDFink commented 7 years ago

Thanks, I appreciate the empathy. I got to the last section where I test the setup and put the following in a command prompt:

[crayon-59fb6b8be054e265666298 lang="default" decode="true" inline="1" ]gdalinfo --version[/crayon]

I get an error that "...is not recognized as an internal or external command, operable program or batch file".

I caught that I had downloaded the 32 bit Python version, but the rest of the GDAL files were 64bit, so I uninstalled 32 bit Python and installed the 64 bit version. I also double checked the environment variables, so like a tree, I'm stumped.

davidintelinair commented 7 years ago

Yeah, its an error on the website. Just open the command prompt and run gdalinfo --version

Did you get to the pip install gdal bit yet?

MarkDFink commented 7 years ago

OK, thanks for that head's up on the website. I ran the command and got: GDAL 1.11.4, released 2016/01/25 Success!

I'm trying to figure out the command to send to it. I have a file called test.tif in the folder c:\kml. I want to output to the folder c:\kml\output, so I am using the following command:

gdal2tiles_parallel.py c:\kml\test.tif c:\KML\output

I get an error: No input file specified. In order to match the samples on the site, I tried using the following, which uses Unix folder conventions:

gdal2tiles_parallel.py /kml/test.tif /KML/output as well as: gdal2tiles_parallel.py ../kml/test.tif ../KML/output but I continue to get the no input error message.

Finally, thinking it might want the input file to be in the same location as the .py file, I copied the tif to the same folder and ran:

gdal2tiles_parallel.py /test.tif /output

Same error message. I'm tantalizingly close...

MarkDFink commented 7 years ago

Any suggestions on what I'm doing wrong with the path to the input file?

davidintelinair commented 7 years ago

Looks ok to me. Maybe you need to include python... Since I dont map .py to python.exe I have to include it. This was my test example: python d:\source\geopackage-python\gdal2tiles_parallel.py -f PNG e:\temp\test.tiff e:\temp\tiles3

what happens when you try to get help?
python gdal2tiles_parallel.py --help

Are you using a case sensitive filesystem? I see both c:\kml and c:\KML try matching the case with the filesystem.

If this does not work, post the actual error message.

MarkDFink commented 7 years ago

Hi David, thanks for the suggestions. Still no success with the various options. I'm posting a screen shot of the results. screenshot107

davidintelinair commented 7 years ago

It looks to me like whatever is starting python is not passing all the parameters. You should add the python folder to your path or use the full path to python to start it:

c:\python34\python.exe gdal2tiles_parallel.py inputfile outputfolder

MarkDFink commented 7 years ago

Success! That put me on the right path, so to speak. I ran your suggestion and got an error that it couldn't find the directory for gdal2tiles_parallel.py, so I added that to the command as well. This is what ended up working:

c:\Python27\python.exe "c:\Program Files\GDAL\gdal2tiles_parallel.py" c:\KML\test.tif c:\KML\output

I think it is still running, although I haven't seen any changes to the folder count (103) in the output directory. I see an xml file and a folder called 21, (which has the 103 sub-folders). I do see nine instances of python.exe in my Task Manager with activity next to them, so once those all go away, I'll know it's done. Also, the command window hasn't returned to the c:> prompt either.

I'll post a final update once all the steps are done and I can view the result in Google Earth.

Thanks again for hanging in there with me!

MarkDFink commented 7 years ago

That worked, but it didn't produce a KML file. I ran it again with the -k command and it created all the tiles, but I was expecting a doc.kml file that I could open in Google Earth, along the lines of what is mentioned here: https://developers.google.com/kml/articles/raster#tile.

The XML file contains the following:

<?xml version="1.0" encoding="utf-8"?>

test.tif EPSG:900913

Is there a step to convert this to KML, or should a KML have been created by the gdal2tiles_parallel.py script?

davidintelinair commented 7 years ago

Looks like KML generation is commented out in the parallel version.
# Do not create KML, we dont use it and it takes up valuable processing time

We also do not use KML, so it was not a problem for us.

You can try to figure out how to uncomment (and it may still not work because the tilesets are being generated in parallel among many processes all trying to write to the same file). Or you can use the more supported gdal2tiles.py version which takes longer but is better supported.

Good luck!

MarkDFink commented 7 years ago

That was it! I did a test on a small tiff, and the KML file was created and lined up perfectly in Google Earth. I'm OK with longer processing time as long as it generates the KML. For my larger parcels, I'll just let it run overnight. I think it's safe to close this thread out now, thanks to your excellent help and patience. Thanks again!