3

I'm trying to use the example in the Planet API documentation to retrieve an area (a 0.5km x 0.5km box) around an area of interest. I was able to activate the asset and get a download URL.

However I'm getting this error:

SystemError                               Traceback (most recent call last)
<ipython-input-250-d7d32f39048d> in <module>()
      4     dstSRS='EPSG:4326',
      5     cutlineDSName='myaoi.json',
----> 6     cropToCutline=True)

/usr/lib/python2.7/dist-packages/osgeo/gdal.pyc in Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs)
    547 
    548     if _is_str_or_unicode(destNameOrDestDS):
--> 549         return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
    550     else:
    551         return wrapper_GDALWarpDestDS(destNameOrDestDS, srcDSTab, opts, callback, callback_data)

SystemError: error return without exception set

My code is below:

aoi = {"coordinates": [[[-117.7070372256684, 34.08932328386836], [-117.69617937433158, 34.08932328386836], [-117.69617937433158, 34.08033071613165], [-117.7070372256684, 34.08033071613165], [-117.7070372256684, 34.08932328386836]]], "type": "Polygon"}

url = u'https://api.planet.com/data/v1/download?token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJLejhoN0NEU2ZCN08rZldwOXFnVTBEYStUN2RyM2hja1NEYUNmRVFISUlhUTczT3lydmFsUEU2WktHYzRRNFhhRVV6cGdXbXJRaVBPdURkM3Z0bzJPUT09IiwiaXRlbV90eXBlX2lkIjoiUkVPcnRob1RpbGUiLCJ0b2tlbl90eXBlIjoidHlwZWQtaXRlbSIsImV4cCI6MTQ5MzQ4ODM2MCwiaXRlbV9pZCI6IjIwMTQwMzEzXzE5Mjk1Nl8xMTU0ODEyX1JhcGlkRXllLTMiLCJhc3NldF90eXBlIjoiYW5hbHl0aWMifQ.m7N_9vIqzOgctguz00MUZqvAJos0bJNdPv7S08ms4udb5hSamMhaRODKgE05-x6QNScYkFtb7p42nRbwLiX7Nw'

vsicurl_url = '/vsicurl/' + url

dat = gdal.Warp("out.tif", vsicurl_url, 
    dstSRS='EPSG:4326', 
    cutlineDSName=aoi, 
    cropToCutline=True)

What am I doing wrong?

Edit with more info:

item ID = '20140313_192956_1154812_RapidEye-3'

item type = 'REOrthoTile'

asset type = 'analytic'

gdal version = '2.1.0'

I've tried both saving my AOI polygon to a json file and passing the filename to cutlineDSName in gdal.Warp, and still get the same error.

0

When you pass a non-existent URL to a GeoTIFF, GDAL throws the error you listed. This suggests that you run the script more than one hour after retrieving the location (the url variable in your code snippet).

Using the Planet API, it is always advised to fetch the location immediately before you intend to use it, since the token will expire after about 60 minutes.

The example in the online docs shows how to safely retrieve the location immediately before download using VSI curl.

Using GDAL 2.1.3 and a GeoJSON file, I can correctly download this subarea. Note that because most of this tile is blackfill (see the thumbnail), the output GeoTIFF is going to be 100% no data, but this is expected behaviour.

Note that for me, trying to use a dict rather than a GeoJSON file always returns the following error:

ERROR 1: Cannot open {'type': 'Polygon', 'coordinates': [[[-117.7070372256684, 34.08932328386836], [-117.69617937433158, 34.08932328386836], [-117.69617937433158, 34.08033071613165], [-117.7070372256684, 34.08033071613165], [-117.7070372256684, 34.08932328386836]]]}.

| improve this answer | |
  • Hi - thanks for replying! Here is the info: item ID = '20140313_192956_1154812_RapidEye-3'; item type = 'REOrthoTile'; asset type = 'analytic'; gdal version = '2.1.0' – Adrian Albert May 1 '17 at 11:56
  • I've actually tried saving the AOI to a json file and passing that as parameter to cutlineDSName, and still get the same error. I've successfully retrieved another cropped image by passing just the respective AOI dict to cutlineDSName instead of a filename string. – Adrian Albert May 1 '17 at 12:02
  • I'm going to update my answer based on the new info. – bosth May 1 '17 at 13:21
  • Thanks! I think that was the culprit here, the time lag between when I activated the asset and when trying to download. – Adrian Albert May 1 '17 at 19:36
  • A note: it seems that for my version of gdal, passing directly the AOI dict (as opposed to the geojson file name) actually works fine. – Adrian Albert May 1 '17 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.