Notes về Mapbox

Table of Contents

Notes về Mapbox

Một chút vọc vạch về mapbox

Giới hạn upload file

Studio upload limits 20 uploads / month

300 MB / upload

Uploading data via our APIs allows you to bypass these limits. Use Mapbox Tiling Service for vector data or Uploads API for raster data.


Upload by API

pip install mapbox

from mapbox import Uploader

u = Uploader(access_token="pk.YOUR_ACCESS_TOKEN")  # handles authentication

tileset = 'soiqualang.760e11_120227e7'  # name your tileset
# url = u.stage(open('hoenn_full_route2_modified.tif', 'rb', encoding='cp437', errors='ignore'))  # upload happens here
url = u.stage(open('hoenn_full_route2_modified.tif', 'rb'))  # upload happens here
u.create(url, tileset, name=fname)  # starts the tiling job


Lỗi mapbox.errors.TokenError: session does not have a valid access_token param

Thêm tham số token access_token="pk.YOUR_ACCESS_TOKEN"

Phải vô tạo token mới có quyền upload

u = Uploader(access_token="pk.YOUR_ACCESS_TOKEN")  # handles authentication


Lỗi UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 18: invalid start byte

Bổ sung param encoding='cp437'

url = u.stage(open('hoenn_full_route2_modified.tif', encoding='cp437'))  # upload happens here

Lỗi TypeError: a bytes-like object is required, not 'str'

Thêm mode 'rb'

url = u.stage(open('hoenn_full_route2_modified.tif', 'rb', encoding='cp437', errors='ignore'))

Lỗi ValueError: binary mode doesn't take an encoding argument

Bỏ các param `encoding='cp437', errors='ignore'

url = u.stage(open('hoenn_full_route2_modified.tif', 'rb'))


Kết quả

Upload thành công file 450Mb (Vượt quá giới hạn upload qua web của mapbox)



Leave a Reply

Your email address will not be published. Required fields are marked *