GIScience / ohsome2label

Historical OpenStreetMap Objects to Machine Learning Training Samples
https://github.com/GIScience/ohsome2label
MIT License
48 stars 5 forks source link

Error in `ohsome2label image` command with Sentinel image from SentineHub #10

Open LorenzoStucchi opened 2 years ago

LorenzoStucchi commented 2 years ago

During the execution of the comand ohsome2label --config config\config.yaml image with the following file config.ymal:

project:
  name: TestSentinel
  workspace: ./Sentinel_result
  project_time: 2020-05-18
  task: segmentation

osm:
  api: ohsome
  url: https://api.ohsome.org/v1/elements/geometry
  bboxes: [8.625,49.3711,8.7334,49.4397]
  tags:
    - {'label': 'urban', 'key': 'landuse', 'value': 'residential'}
    - {'label': 'urban', 'key': 'landuse', 'value': 'garages'}
    - {'label': 'industry', 'key': 'landuse', 'value': 'railway'}
    - {'label': 'industry', 'key': 'landuse', 'value': 'industrial'}

  timestamp: 2019-10-20
  types: polygon

image:
  img_api: sentinel
  img_url: https://services.sentinel-hub.com/ogc/wms/{token}?showLogo=false&service=WMS&request=GetMap&layers=ALL-BAND&styles=&format=image%2Ftiff&transparent=1&version=1.1.1&maxcc=20&time=2015-01-01%2F2020-01-01&priority=mostRecent&height=256&width=256&srs=EPSG%3A3857&bbox={bbox}
  api_token : 'TOKEN'
  zoom: 14

It provided the error below. I never use the operator <<, so I'm not confident in fixing it. From the guide seems that n = 1 << int(tile.z) could fix it, but this will produce other errors.

  File "c:\users\stucchi\documents\github\ohsome2label\ohsome2label\tile.py", line 148, in top_left
    n = 1 << tile.z
TypeError: unsupported operand type(s) for <<: 'int' and 'str'

I used python 3.6.8 and shapely 1.7.1, the suggested version of shapely (1.6.4) is not working and provides multiple errors. The 1.7.1 works in the command vector and label.

bobleegogogo commented 2 years ago

Hi @LorenzoStucchi, thanks for reporting this issue.

LorenzoStucchi commented 2 years ago

Hi @bobleegogogo

First, regarding the options, I think you should put it as ohsome2lable --config xx/xx.yaml image, this works for me, not fully sure about the context of your issue?

I used it in the indicated way, but before didn't work, then I reinstalled and now it works.

Second, just to get it a bit clear and try to focus on issue, are you getting this error when conducting image command?

I have improved the above description, with more info

bobleegogogo commented 2 years ago

Hi @LorenzoStucchi

Nice, so the first point is solved. I think it is probably due to one of the latest update in pip, while not sure if this is the reason.

For the second point, I saw that you are using img_api: sentinel, did you also try other image source? such as the Bing image (then you need to apply for a token here: https://www.bingmapsportal.com/) in the default example? I think we have tested ohsome2label with Sentinle-hub API quite some time ago... while certainly this is not up-to-date.

Maybe It would be also great if you could sort this out and contribute to the project in this aspect?

LorenzoStucchi commented 2 years ago

For the second point, I saw that you are using img_api: sentinel, did you also try other image source? such as the Bing image (then you need to apply for a token here: https://www.bingmapsportal.com/) in the default example? I think we have tested ohsome2label with Sentinle-hub API quite some time ago... while certainly this is not up-to-date.

I test bing and the error is not present, so it is only related to the download from SentinelHub

Maybe It would be also great if you could sort this out and contribute to the project in this aspect?

I'll try in the next weeks, but I can not ensure that I will be able to have time to study it 😄

bobleegogogo commented 2 years ago

Hi @LorenzoStucchi, nice to know that at least bing works out!

I might need to update the part related to SentinelHub in future, just not sure when would I get some time for this ...