Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idlist and order would fail if the multi-polygons are adjacent to each other (self-intersect) #25

Closed
LLeiSong opened this issue May 27, 2019 · 3 comments

Comments

@LLeiSong
Copy link

LLeiSong commented May 27, 2019

I used a multi-polygon geojson to list the ids and order the imagery, then I realized that these two functions failed because the polygons are adjacent to each other (self-intersection happened). I queried imagery a few times before, I think I did everything following the instruction.

Here are my clues so far:

  1. For idlist, the problem happened in line 190 in file geojson2id.py, I added one line aoi_shape=aoi_shape.buffer(0) here then it works fine to query the ids. But I am not sure the result is correct or not since I failed to download the imagery.

  2. For order, it failed with a return 'Failed with response: Bad request'. The problem happened in object payload in line 266 in file order_now.py. It seems that the request doesn't follow the syntax of Planet API. I tried separated multi-polygons, it works just fine. So my guess: the problem here is still the adjacent polygons issue.

My queries are here:

porder idlist --input '/working_dir/supergrid2_test.geojson' --start '2018-01-01' --end '2018-01-10' --item 'PSScene4Band' --asset 'analytic_sr' --number 1000 --outfile '/working_dir/orderlist_supergrid2_test.csv'
porder order --name "supergrid2_4grids" --idlist "/working_dir/orderlist_supergrid2_test.csv" --item "PSScene4Band" --asset "analytic_sr" --boundary '/working_dir/supergrid2_test.geojson' --op clip

My geojson file is here:
supergrid2_test.geojson.zip

@LLeiSong
Copy link
Author

Another non-related bug in the file order_now.py: when there is no --op parameter, the object ordname cannot be assigned because of line 97-98:

if key=='op' and value!=None:
            ordname=k['name']

I arbitrarily fixed this issue by adding line ordname=k['name'] before line 266 payload=payload.replace("Explorer_{{name}}.zip",ordname+'_'+str(pendulum.now()).split("T")[0]+".zip"). But I think this must be a better way to solve this.

@samapriya
Copy link
Collaborator

Hi @LLeiSong
The limitation of the way in which shapely processes geometry is that the geometries do not intersect, in your case you are using a grid and hence cannot be handled as a multi polygon geometry in Shapely.

A valid Polygon may not possess any overlapping exterior or interior rings

I think you are right about assigning ordname outside the op iterations to make sure someone can order without using any op, I will make that edit in the next release.

@samapriya
Copy link
Collaborator

Just released v0.3.3 with the fix for the order name.

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

No branches or pull requests

2 participants