Skip to content

encapsulated peps_download script in peps_download function#42

Closed
floriandeboissieu wants to merge 5 commits intoolivierhagolle:masterfrom
floriandeboissieu:master
Closed

encapsulated peps_download script in peps_download function#42
floriandeboissieu wants to merge 5 commits intoolivierhagolle:masterfrom
floriandeboissieu:master

Conversation

@floriandeboissieu
Copy link
Contributor

Dear Olivier,
Here is a proposition to encapsulate peps_download in a function so it can be also used in a python script.
For that I:

  • encapsulated the command line parsing in function parse_command_line separated from the rest
  • encapsulated the rest in peps_download with all options as inputs (thus removing the option. prefixes)
  • fix the functions that were using global variables defining them as inputs, e.g. parse_catalog(search_json_file) becomes parse_catalog(search_json_file, orbit, collection, clouds, sat)
  • added a SysError to return the sys.exit codes already used for command line, but avoid exit of the python session when using function peps_download
  • added options trials (max_trials in function peps_download) and wait to avoid infinite loop and control the time between trials

Tell me if these modifications suites you.
Next step could be to add a setup.py file so that it can be installed with pip and imported or executed simply.

@olivierhagolle
Copy link
Owner

Thanks Florian,
That's a good idea, but I might lack time to test it. I'll try it ASAP
Olivier

@matt6697
Copy link

HI @olivierhagolle, would you have some time to check and merge this PR as it would allow peps_download usage as a part of an automated processing python script (before calling snappy for example)

@floriandeboissieu
Copy link
Contributor Author

Hi, actually I continued to enhance the package with multipage requests, usage of geometric file (shapefile, geojson, ...), return of file status, control of verbosity, etc. See https://github.com/floriandeboissieu/peps_download/tree/shapefile
For me it simplify its usage a lot, so I'll try make another pull-request today with that branch.
Cheers

@floriandeboissieu
Copy link
Contributor Author

@matt6697 you can still install my fork with the following command for the moment:

pip install git+https://github.com/floriandeboissieu/peps_download.git@shapefile

@matt6697
Copy link

matt6697 commented Jan 18, 2021

Hi, actually I continued to enhance the package with multipage requests, usage of geometric file (shapefile, geojson, ...), return of file status, control of verbosity, etc. See https://github.com/floriandeboissieu/peps_download/tree/shapefile
For me it simplify its usage a lot, so I'll try make another pull-request today with that branch.
Cheers

Ok I noticed the following new download option :

    shape: str | geopandas.geodataframe.GeoDataFrame | geopandas.geoseries.GeoSeries | shapely.geometry.base.BaseGeometry
        Shape file or object used to define the bounding box of interest.
        If file, any format supported by geopandas.
        If file or geopandas object, it is automatically reprojected to EPSG:4326.
        Shapely geometric object of any type is also supported. For shapely geometric object, coordinates are expected to be in lon,lat (EPSG:4326).

I'm looking for such an option to avoid converting a geojson box into peps query parameters with the ability to select only Sentinel images containing the whole area of the query. It seems that peps is returning any image containing part of the query rectangle but the whole area is needed for some usages (change detection needs 2 images embedding the same area and it's a pain to check every image returned by peps)

@floriandeboissieu
Copy link
Contributor Author

I am not aware of such a 'contains' option in peps query, however it could be done with geopandas and S2 kml grid

@floriandeboissieu
Copy link
Contributor Author

Closing as the commits of this PR are incuded in PR #46.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants