hypertidy / ceramic

read image server tiles direct with GDAL, or download image server tiles to a local cache
https://hypertidy.github.io/ceramic/
92 stars 6 forks source link

custom styles #5

Closed mdsumner closed 5 years ago

mdsumner commented 5 years ago

I'm trying strings like

"https://api.mapbox.com/styles/v1/mdsumner/cjs6yn9hu0coo1fqhdqgw3o18/wmts/{zoom}/{x}/{y}.jpg90?access_token=???"

Where "mdsumner/cjs6yn9hu0coo1fqhdqgw3o18" is the custom style. It not working, checked at zoom = 2, 5.

Any clues? @shermstats

Mapbox tells me to use "https://api.mapbox.com/styles/v1/mdsumner/cjs6yn9hu0coo1fqhdqgw3o18/wmts?access_token=etc" but no more I can find about the rest of the string

shermstats commented 5 years ago

The custom style is just cjs6yn9hu0coo1fqhdqgw3o18, not mdsumner/cjs6yn9hu0coo1fqhdqgw3o18 prefixed with your username.

Also, trycjs6yn9hu0coo1fqhdqgw3o18/tiles/ instead of cjs6yn9hu0coo1fqhdqgw3o18/wmts/. And maybe try removing the .jpg90? I've never used that in my code.

mdsumner commented 5 years ago

Thanks! Still can't get it ... do you have a specific link to a tile that works so I can trace through?

mdsumner commented 5 years ago

Got it. You can't specify the format afaics, always JPEG

https://api.mapbox.com/styles/v1/mdsumner/cjs6yn9hu0coo1fqhdqgw3o18/tiles/512/0/0/0@2x?access_token=...
mdsumner commented 5 years ago

Veeery tentatively, this works in 9a8fe439:

u <- "https://api.mapbox.com/styles/v1/mdsumner/cjs6yn9hu0coo1fqhdqgw3o18/tiles/512/{zoom}/{x}/{y}"
 im <- cc_location(cbind(147, -42), base_url = u)
raster::plotRGB(im)

image

It's pretty hacky because I have to special-case the code for the file extension, presumably there's a better way to do it, but it was nice having an explicit extension because then tile source URLs mapped directly to local file names. (though the @2x thing messes that up)

mdsumner commented 5 years ago

apparently custom styles assume to be PNG, re https://twitter.com/neilcharles_uk/status/1121372303533707264 so take care