Acolite_mr source code PlanetScope
-
- Posts: 45
- Joined: Wed Apr 19, 2017 9:37 am
Acolite_mr source code PlanetScope
Dear Quinten,
I was running the acolite_mr source code and I found that my data does not end as _AnalyticMS.tif and AnalyticMS_metadata.xml; instead they are given to me as 20170412_130025_0c82 (.tif) and 20170412_130025_0c82 (.xml) and I realized that after many attempts . Also, while running the code the following comment: “Failed to write attribute: TIME” showed up.
I am sending my output and the .xml file saved as .txt attached and I would kindly like to ask if you could guide me on these problems.
Kind regards,
Isabel
I was running the acolite_mr source code and I found that my data does not end as _AnalyticMS.tif and AnalyticMS_metadata.xml; instead they are given to me as 20170412_130025_0c82 (.tif) and 20170412_130025_0c82 (.xml) and I realized that after many attempts . Also, while running the code the following comment: “Failed to write attribute: TIME” showed up.
I am sending my output and the .xml file saved as .txt attached and I would kindly like to ask if you could guide me on these problems.
Kind regards,
Isabel
- Attachments
-
- 20170412_130025_0c82_AnalyticMS_metadata.txt
- (10.17 KiB) Downloaded 424 times
-
- test1_MR.png (162.62 KiB) Viewed 9376 times
Re: Acolite_mr source code PlanetScope
Hi Isabel
Thanks for the info! It seems renaming the files has worked? Did it generate a NetCDF file and png outputs?
The TIME attribute error can be ignored - this is the result of me trying to write a Python datetime object as NetCDF attribute.
Quinten
Thanks for the info! It seems renaming the files has worked? Did it generate a NetCDF file and png outputs?
The TIME attribute error can be ignored - this is the result of me trying to write a Python datetime object as NetCDF attribute.
Quinten
-
- Posts: 45
- Joined: Wed Apr 19, 2017 9:37 am
Re: Acolite_mr source code PlanetScope
Hi Quinten,
Thank you for your reply. Yes, it worked and generated NetCDF files and png outputs. My only concern is that I will have to find a way to change these tons of images that I am working with .
Isabel
Thank you for your reply. Yes, it worked and generated NetCDF files and png outputs. My only concern is that I will have to find a way to change these tons of images that I am working with .
Isabel
Re: Acolite_mr source code PlanetScope
Hi Isabel
You can either batch rename/link the files to include the required keywords in the filename, or modify the acolite/planetscope/bundle_test.py file. I'll include an example here, but am away on field work and have not been able to test it.
Let me know how it goes!
Quinten
You can either batch rename/link the files to include the required keywords in the filename, or modify the acolite/planetscope/bundle_test.py file. I'll include an example here, but am away on field work and have not been able to test it.
Code: Select all
## def bundle_test
## simplified replacement function for Isabel
def bundle_test(bundle):
import os
if os.path.isdir(bundle):
files = os.listdir(bundle)
datafiles = {}
for i, fname in enumerate(files):
fn,ext = os.path.splitext(fname)
if ext not in ['.tif', '.xml']: continue
if '.xml' in fname:
band = 'metadata'
if '.tif' in fname:
band = 'analytic'
if band is None: continue
file = '{}/{}'.format(bundle,fname)
datafiles[band] = {"path":file, "fname":fname}
return(datafiles)
Quinten
-
- Posts: 45
- Joined: Wed Apr 19, 2017 9:37 am
Re: Acolite_mr source code PlanetScope
Hi Quinten,
It works! Thank you very much.
Isabel
It works! Thank you very much.
Isabel
-
- Posts: 45
- Joined: Wed Apr 19, 2017 9:37 am
Re: Acolite_mr source code PlanetScope
Hi Quinten,
I have more than 100 Planet images in a directory. I want to run your script for each one of them. My question is how could I do this automatically?
Kind regards,
Isabel
I have more than 100 Planet images in a directory. I want to run your script for each one of them. My question is how could I do this automatically?
Kind regards,
Isabel
Re: Acolite_mr source code PlanetScope
Hi Isabel
I think you are using Windows, so for this you can make a batch script, or run a loop directly at the command line. The following is untested but may give you some ideas. This runs the python code for all directories in the given directory (assuming each of your PlanetScope images is in its own directory in idir):
Hope this helps!
Quinten
I think you are using Windows, so for this you can make a batch script, or run a loop directly at the command line. The following is untested but may give you some ideas. This runs the python code for all directories in the given directory (assuming each of your PlanetScope images is in its own directory in idir):
Code: Select all
set idir=\path\to\files
set odir=\path\to\output
for /D %s in (%idir%\*) do python acolite_mr.py --input %s --output %odir%
Quinten
-
- Posts: 45
- Joined: Wed Apr 19, 2017 9:37 am
Re: Acolite_mr source code PlanetScope
Dear Quinten,
Thank you for your ideas. Indeed, I am using Windows and running the acolite_mr.py from anaconda prompt.
I am glad that your suggestions worked for me and I've used this loop directly from the command line because my batch script did not work properly
kind regards,
Isabel
Thank you for your ideas. Indeed, I am using Windows and running the acolite_mr.py from anaconda prompt.
I am glad that your suggestions worked for me and I've used this loop directly from the command line because my batch script did not work properly
kind regards,
Isabel
-
- Posts: 45
- Joined: Wed Apr 19, 2017 9:37 am
Re: Acolite_mr source code PlanetScope
Dear Quinten,
I was trying acolite_mr.py again and I found that my loop is working but it is reading only the last file of every folder (Please refer to attached image). As I am a beginner in programming with python and batch scripting, I could not find out why my loop is reading only these last files (.tif, .xml).
I used the following loop on the command line:
for /D %G in (%inputdir%\Planet_*") do python acolite_mr.py --input %G --output %outdir%
Hope to hear from you soon,
kind regards
Isabel
I was trying acolite_mr.py again and I found that my loop is working but it is reading only the last file of every folder (Please refer to attached image). As I am a beginner in programming with python and batch scripting, I could not find out why my loop is reading only these last files (.tif, .xml).
I used the following loop on the command line:
for /D %G in (%inputdir%\Planet_*") do python acolite_mr.py --input %G --output %outdir%
Hope to hear from you soon,
kind regards
Isabel
quinten wrote: ↑Fri Jan 24, 2020 7:55 am Hi Isabel
I think you are using Windows, so for this you can make a batch script, or run a loop directly at the command line. The following is untested but may give you some ideas. This runs the python code for all directories in the given directory (assuming each of your PlanetScope images is in its own directory in idir):
Hope this helps!Code: Select all
set idir=\path\to\files set odir=\path\to\output for /D %s in (%idir%\*) do python acolite_mr.py --input %s --output %odir%
Quinten
- Attachments
-
- testing_acolite_mr.png (118.43 KiB) Viewed 9228 times
Re: Acolite_mr source code PlanetScope
Hi Isabel
It is easier for me to code in Python, and since you need Python to run acolite_mr, you can test the following code:
Hope this helps!
Quinten
It is easier for me to code in Python, and since you need Python to run acolite_mr, you can test the following code:
Code: Select all
indir = '' # full path to your directory with a bunch of files
output = '' # path to put output files
path_to_acolite_mr = '' # path to cloned github acolite_mr code
import sys, os, glob
sys.path.append(path_to_acolite_mr)
import acolite as ac
files = glob.glob('{}/*AnalyticMS.tif'.format(indir))
files.sort()
for file in files:
ac.acolite.acolite_mr_ac(file, output=output, ancillary_data=False)
Hope this helps!
Quinten