samapriya / Planet-GEE-Pipeline-CLI

Planet and Google Earth Engine Pipeline Command Line Interface Tool
https://pypi.org/project/ppipe/
Apache License 2.0
42 stars 12 forks source link

selupload does not function with PSOrthotiles and metadata #13

Closed amberthomas closed 5 years ago

amberthomas commented 5 years ago

I think it's similar to the last issue "metadata file produced from files downloaded with the clip option of the old planet API aren't correct to use"

When I batch download PSOrthotiles the id names in the metadata file will be something like "1539866_0466621_2018-07-02_1105_BGRN_Analytic_metadata" which means that it won't upload properly when using selupload. I fixed my problem by just clipping the "_metadata" off in cli_metadata.py near line 88.

writer.writerow([filename.split('.')[0].replace('_metadata',''),epoch,productType,orbit,provider,instrument,satellite_id,tile_id,bands,epsg_code,resampling_kernel.....

This is super specific to my case though. I know Planet uses annoyingly different naming conventions across the board, so this would be tedious to find all these cases.

Would it worth doing something like: metadata_sfx = filename.split('.')[0].split('_')[-1] and checking against a list of common suffixes, then replacing with the empty string if it is in the list?

I could also see queries being done against the metadata dictionary (near line 15 of metadata_ingest.py ) to accommodate the fact that filename is likely just a substring of a metadata key. But you read from the metadata csv a few times in that file so that might not be enough.

samapriya commented 5 years ago

Thanks for making a note, I am going to tag this as an enhancement to look for clip keyword and then match from the metadata. Should have a resolution in the next release

samapriya commented 5 years ago

Hi @amberthomas Seems the fix was easy by simple stripping out _metadata. Now, this tool should be able to handle both clipped and unclipped files from the metadata. Upgrade to ppipe v0.4.5 for applying the fix