dieghernan / leaflet-providersESP

An extension to Leaflet that contains configurations for various free WMS (Web Map Service) and WMTS (Web Map Tile Service) providers of Spain (IDErioja, PNOA, IGN base, Catastro, etc), from Spanish mapping agencies.
https://dieghernan.github.io/leaflet-providersESP/
MIT License
6 stars 0 forks source link

More WMS? #4

Closed ajpelu closed 1 year ago

ajpelu commented 1 year ago

Hi @dieghernan Thanks for this plugin. I've used this extension to add base maps directly in leaflet, but also I would like to use as base maps in R, using the amazing mapSpain pkg. I read the documentation and I see how to do it, but I didn't find any way to include custom WMS, for instance from other institutions (e.g. from Junta de Andalucía).

Any suggestions?

Thanks and sorry for this mixed questions.

dieghernan commented 1 year ago

HI @ajpelu:

For interactive (i.e. Leaflet maps) the solution is quite straightforward, while for static maps in R it is more complex.

In first place, let me tell you that I am planning a new release of mapSpain on the next weeks, so if you want to add new providers you may consider a pull request to the plugin in dev and I would happily add those providers both to this plugin and to mapSpain:

In the meantime, you can do the following:

Leaflet maps (Leaflet.js and R)

You really don't need mapSpain for this, let me show you how (although you may already know this).

Lets say we want to add https://www.ideandalucia.es/wms/ortofoto2016?request=GetCapabilities&service=WMS ("ortofotografia_2016_pancromatico") layer (search for queryable= to see the <Name> of the layers).

On Leaflet.js use L.tileLayer.wms():

Leaflet.js ```html Minimal page | leaflet-providersESP
```

In R use the leaflet package:

library(leaflet)

leaflet() %>%
  setView(
    lat = 37.17634,
    lng = -3.58821,
    zoom = 7
  ) %>%
  addProviderTiles("OpenStreetMap", group = "OpenStreetMap") %>%
  addWMSTiles("https://www.ideandalucia.es/wms/ortofoto2016?",
    layers = "ortofotografia_2016_pancromatico",
    options = WMSTileOptions(
      format = "image/png",
      transparent = TRUE,
      attribution = "IDEAndalucia"
    ),
    group = "Junta Andalucia"
  ) %>%
  addLayersControl(
    baseGroups = "OpenStreetMap",
    overlayGroups = "Junta Andalucia",
    options = layersControlOptions(collapsed = FALSE)
  )

image

With mapSpain (static tiles)

Continues on https://github.com/rOpenSpain/mapSpain/issues/86

ajpelu commented 1 year ago

Thanks @dieghernan for your detailed reply. Yes, I know how to add wms in leaflet and in R, but thanks for the examples.

About the next release of mapSpain, I'll try to add some new providers.

Thanks AntonioJ

dieghernan commented 1 year ago

Hi @ajpelu , just wanted to check if you saw https://github.com/rOpenSpain/mapSpain/issues/86

Regards

ajpelu commented 1 year ago

Hi @dieghernan Thanks a lot. This is just what I was looking for.