stactools-packages / sentinel2

stactools package for Sentinel-2
Other
16 stars 5 forks source link

stac sentinel2 create-item on SAFE dir not working #154

Open MathewNWSH opened 9 months ago

MathewNWSH commented 9 months ago

Hello, I tried to start generating json items based on my SAFE products dirs. On each the error is raised:

TypeError: Type is not JSON serializable: numpy.float64

Command I'm using:

**stac sentinel2 create-item /home/eouser/Downloads**/S2A_MSIL2A_20231229T001021_N0510_R016_T58UFG_20231229T020450.SAFE /home/eouser/Desktop/output/

stactools was installed by pip install stactools-sentinel2

Full log:

(python3.11) eouser@ubuntu-wms:~$ stac sentinel2 create-item /home/eouser/Downloads/S2A_MSIL2A_20231229T001021_N0510_R016_T58UFG_20231229T020450.SAFE /home/eouser/Desktop/output/
/opt/venv/python3.11/lib/python3.11/site-packages/antimeridian/_implementation.py:391: FixWindingWarning: The exterior ring of this shape is wound clockwise. Since this is a common error in real-world geometries, this package is reversing the exterior coordinates of the input shape before running its algorithm. If you know that your input shape is correct (i.e. if your data encompasses both poles), pass `fix_winding=False`.
  FixWindingWarning.warn()
Traceback (most recent call last):
  File "/opt/venv/python3.11/bin/stac", line 8, in <module>
    sys.exit(run_cli())
             ^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/stactools/cli/cli.py", line 37, in run_cli
    cli(prog_name="stac")
  File "/opt/venv/python3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/stactools/sentinel2/commands.py", line 67, in create_item_command
    item.save_object()
  File "/opt/venv/python3.11/lib/python3.11/site-packages/pystac/stac_object.py", line 469, in save_object
    stac_io.save_json(dest_href, self.to_dict(include_self_link=include_self_link))
  File "/opt/venv/python3.11/lib/python3.11/site-packages/pystac/stac_io.py", line 259, in save_json
    txt = self.json_dumps(json_dict, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/python3.11/lib/python3.11/site-packages/pystac/stac_io.py", line 127, in json_dumps
    return orjson.dumps(json_dict, option=orjson.OPT_INDENT_2, **kwargs).decode(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Type is not JSON serializable: numpy.float64

Sample data: https://s3.waw3-2.cloudferro.com/swift/v1/demo_data/