GIS Mẹo vặt Sói's Tutorials WebGIS

Notes về Mapbox

Table of Content

Notes về Mapbox

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

mapbox.com


Giới hạn upload file

https://studio.mapbox.com/tilesets/

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.

https://studio.mapbox.com/tilesets/soiqualang.601ynxwc

image

https://docs.mapbox.com/help/troubleshooting/uploads/

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
fname='hoenn_full_route2_modified.tif'
u.create(url, tileset, name=fname)  # starts the tiling job

image

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

image

https://www.mapbox.com/account/access-tokens

https://mapbox-mapbox.readthedocs-hosted.com/en/latest/access_tokens.html

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

https://stackoverflow.com/questions/9233027/unicodedecodeerror-charmap-codec-cant-decode-byte-x-in-position-y-character

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'))

https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in

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'))

image

Kết quả

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

https://studio.mapbox.com/tilesets/soiqualang.760e11_120227e7

image

image


https://gist.github.com/robinkraft/872b85b56f7ed8551cb08908b33a224f

https://docs.mapbox.com/api/maps/uploads/#create-an-upload

Leave a Reply

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