Git Product home page Git Product logo

Comments (7)

samapriya avatar samapriya commented on September 26, 2024

@rbavery it might be an intermittent issue because I was able to run it using your idlist and geojson you provided. I would suggest you retry using the same tool

porder order --name "rtest" --idlist "C:\Users\samapriya\Downloads\test_tile_eighth.txt" --item "PSScene4Band" --asset "analytic" --boundary "C:\Users\samapriya\Downloads\ryan.geojson" --op clip
Order created at https://api.planet.com/compute/ops/orders/v2/01fb6868-12b8-467b-9c58-c76905aed67b and url copied to clipboard

from porder.

rbavery avatar rbavery commented on September 26, 2024

I've tried that function call multiple times over the past few days and I keep getting the same error, so I think something else is going on. I found the portion of the code in order_now.py that is failing, this try block

    for key,value in kwargs.items():
        if key=='boundary' and value!=None:
                for items in k['tools']:
                    if items.get('clip'):
                        try:
                            if value.endswith('.geojson'):
                                with open(value) as aoi:
                                    aoi_resp = json.load(aoi)
                                    items['clip']['aoi']['coordinates']= aoi_resp['features'][0]['geometry']['coordinates']
                            elif value.endswith('.json'):
                                with open (value) as aoi:
                                    aoi_resp=json.load(aoi)
                                    items['clip']['aoi']['coordinates']=aoi_resp['config'][0]['config']['coordinates']
                            elif value.endswith('.kml'):
                                getcoord=kml2coord(value)
                                items['clip']['aoi']['coordinates']=getcoord
                        except Exception as e:
                            print('Could not parse geometry')

So I tried to replicate the try block in my porder env... and I can read in the geojson just fine.

>>> import json
>>> json.load(open("test_tile_eighth.geojson"))
{u'type': u'FeatureCollection', u'name': u'test_tile_eighth', u'features': [{u'geometry': {u'type': u'Polygon', u'coordinates': [[[-0.831053947078279, 5.72196597574407], [-0.831, 5.71], [-0.815323594266615, 5.709838158765161], [-0.815377541344895, 5.721804134509231], [-0.831053947078279, 5.72196597574407]]]}, u'type': u'Feature', u'properties': {u'id': 0}}]}
>>> aoi_resp = json.load(open("test_tile_eighth.geojson"))
>>> aoi_resp['features']
[{u'geometry': {u'type': u'Polygon', u'coordinates': [[[-0.831053947078279, 5.72196597574407], [-0.831, 5.71], [-0.815323594266615, 5.709838158765161], [-0.815377541344895, 5.721804134509231], [-0.831053947078279, 5.72196597574407]]]}, u'type': u'Feature', u'properties': {u'id': 0}}]
>>> aoi_resp['features'][0]
{u'geometry': {u'type': u'Polygon', u'coordinates': [[[-0.831053947078279, 5.72196597574407], [-0.831, 5.71], [-0.815323594266615, 5.709838158765161], [-0.815377541344895, 5.721804134509231], [-0.831053947078279, 5.72196597574407]]]}, u'type': u'Feature', u'properties': {u'id': 0}}
>>> aoi_resp['features'][0]['geometry']
{u'type': u'Polygon', u'coordinates': [[[-0.831053947078279, 5.72196597574407], [-0.831, 5.71], [-0.815323594266615, 5.709838158765161], [-0.815377541344895, 5.721804134509231], [-0.831053947078279, 5.72196597574407]]]}
>>> aoi_resp['features'][0]['geometry']['coordinates']
[[[-0.831053947078279, 5.72196597574407], [-0.831, 5.71], [-0.815323594266615, 5.709838158765161], [-0.815377541344895, 5.721804134509231], [-0.831053947078279, 5.72196597574407]]]

my hunch is that this is failing because the value that is associated with key boundary is not a string that ends with '.geojson' on my linux system, but something else. thus it would fail on value.endswith('.geojson'). But I'm not at all sure, that's just the only thing I can think of since my porder env can parse the geometry correctly I don't know where or how else it would fail on the try block.

I'm still digging into it trying to debug, but can't seem to get my debugger in vscode to work on the file. I keep seeing an error in the call stack that says Source code string cannot contain null bytes Have you seen this type of error before and any suggestions?

selection_018

from porder.

bosth avatar bosth commented on September 26, 2024

Seems to be resolvable by changing the line here.

Loading from a string works: aoi_resp = json.loads(aoi.read())

from porder.

rbavery avatar rbavery commented on September 26, 2024

Thanks @bosth and @samapriya , changing that line fixed the issue

from porder.

rbavery avatar rbavery commented on September 26, 2024

Just a heads up this was also a problem for a colleague still, should the suggestion from @bosth be incorporated into porder?

from porder.

samapriya avatar samapriya commented on September 26, 2024

Hi @rbavery made the change suggested by @bosth and updated it in the new version. Was traveling hence the delay in getting this fixed :)

from porder.

Ntkrell avatar Ntkrell commented on September 26, 2024

Note: if users still get the error after seeing aoi_resp = json.loads(aoi.read()) has been fixed, make sure to pip install --upgrade porder.

from porder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.