GithubHelp home page GithubHelp logo

Comments (5)

rCarto avatar rCarto commented on June 7, 2024

Hello,
I've tried to save this tile (right-click, save):
https://geodata.nationaalgeoregister.nl/tiles/service/wmts/opentopo/EPSG:28992/5/16/12.png
and saw that the file is actually a jpeg despite its png extension.

So I tried this url for the tile server:

url <- "https://geodata.nationaalgeoregister.nl/tiles/service/wmts/opentopo/EPSG:28992/{z}/{x}/{y}.jpeg"

but maptiles does not understand jpeg extension, only jpg and png.
So I've update maptiles to allow jpeg extension and you can try this (using the dev version of the package):

remotes::install_github('riatelab/maptiles')
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.2, PROJ 7.1.0; sf_use_s2() is TRUE
library(maptiles)

p = st_point(c(328452.9,267552.5))
p = st_sfc(p)
p = st_set_crs(p, 28992)
bb = st_bbox(st_buffer(p, 300000))

url <- "https://geodata.nationaalgeoregister.nl/tiles/service/wmts/opentopo/EPSG:28992/{z}/{x}/{y}.jpeg"
mffp <- list(src="OpenTopo", q=url, sub=NA, cit='')

t <- get_tiles(bb, provider=mffp, crop= T, forceDownload = T, zoom=7)
plot_tiles(t, adjust = TRUE)

Created on 2022-02-15 by the reprex package (v2.0.1)

I have modified point coordinates and zoom level from your original example to show something not on the sea :-)

from maptiles.

gremms1 avatar gremms1 commented on June 7, 2024

Hi, I came to the same conclusion (concerning the jpeg) yesterday evening! Thanks for acting so promptly. Getting the tiles now works, the only thing I can´t figure out is what is going wrong with the projection. Using the following code

library(sf)
library(maptiles)
library(stars)
library(tmap)
p = st_point(c(328452.9,267552.5))
p = st_sfc(p)
p = st_set_crs(p, 28992)
bb = st_bbox(st_buffer(p, 300000))
url <- "https://geodata.nationaalgeoregister.nl/tiles/service/wmts/opentopo/EPSG:28992/{z}/{x}/{y}.jpeg"
mffp <- list(src="OpenTopo", q=url, sub=NA, cit='')
t <- get_tiles(bb, provider=mffp, crop= T, forceDownload = T, zoom=7)
plot_tiles(t, adjust = TRUE)
map <- stars::st_as_stars(t)
tmap_mode("plot")
tm_shape(map) +
  tm_rgb() +
tm_graticules(lines=F)

shows that the map is way bigger than it actually should be.

from maptiles.

rCarto avatar rCarto commented on June 7, 2024

I suspected something odd with the projection stuff.
I think it has something to do with this part of the url (and the way tiles are delivered): EPSG:28992
Most of tiles providers ask for lon & lat in EPSG:4326 and offer tiles in EPSG:3857 (web mercator) and this projs are actually hardcoded in maptiles.
Can you direct me to the API documentation just to be sure of what input/output proj are expected?

from maptiles.

gremms1 avatar gremms1 commented on June 7, 2024

I think you're right. this is the KVP WMTS GetCapabilities page. If you ctrl+f and search for opentopo you can see EPSG:28992. Thanks for your help!

from maptiles.

gremms1 avatar gremms1 commented on June 7, 2024

Additionally, here a working example with an interactive tmap (requires dev-version):

remotes::install_github('r-tmap/tmap')
library(tmap)
library(leaflet)
epsg28992 <- leafletCRS(
  crsClass = "L.Proj.CRS"
  ,code = "EPSG:28992"
  ,proj4def = "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs"
  ,origin=c(-285401.92,903401.92)
  ,resolutions = c(3251.206502413005,1625.6032512065026,812.8016256032513,406.40081280162565,203.20040640081282,101.60020320040641, 50.800101600203206,25.400050800101603,12.700025400050801,6.350012700025401,3.1750063500127004,1.5875031750063502,0.7937515875031751,0.39687579375158755,0.19843789687579377,0.09921894843789689,0.04960947421894844)
)

url <- "https://geodata.nationaalgeoregister.nl/tiles/service/wmts/opentopo/EPSG:28992/{z}/{x}/{y}.jpeg"


data(World)
tmap_mode("view")

tm_shape(World) +
  tm_polygons() +
  tm_basemap(NULL) +
  tm_view(projection = epsg28992, set.view = c(5.092098,52.093992,4)) +
  tm_tiles(server = url) +
  tm_mouse_coordinates() 

from maptiles.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.