1

I am very new to working with maps and was given a task to collect data on points from this website: https://mapadefosas.mjusticia.es/exovi_externo/CargarMapaFosas.htm#

So far I have managed to figure out how to load the map and one of the layers:

library("leaflet")
library("leaflet.extras")
library("shiny")

x.WGS=-3.87988
y.WGS=40.26270
leaflet() %>% setView(x.WGS, y.WGS, zoom = 5) %>%
  addTiles() %>%
  addWMSTiles(
    baseUrl = "https://mapadefosas.mjusticia.es/geoserver/wms",
    layers = "INTERVENIDA",
    options = WMSTileOptions(format = "image/png", transparent = TRUE), attribution = "") 

But I am a bit stuck on how I can get point information from this. Can someone help? As far as I understand the shiny package should be useful here but I am not sure how.

1 Answer 1

3

You can't. You're fetching images from a WMS endpoint, which contain graphical little flags, and no machine-readable data at all. Compare with e.g. WFS or vector tiles, protocol stacks which serve similar purposes but allow access to the raw(er) geographical features.

That said: there are some tricks that can be applied to this particular WMS endpoint. If you have a good look at the XML of the GetCapabilities document for that endpoint, you'll notice that you can ask the WMS endpoint to provide you the images in several formats, e.g. image/png or image/jpeg; but this particular endpoint provides non-image formats such as application/rss+xml (AKA GeoRSS).

So if you take one of the request URL in the OpenLayers viewer, change image/png with application/rss+xml, and make a manual request to the WMS endpoint, like...

https://mapadefosas.mjusticia.es/geoserver/wms?LAYERS=PROSPECTADA&SRS=EPSG:4326&FORMAT=application/rss+xml&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application/vnd.ogc.se_inimage&BBOX=-10.12451171875,34.287109375,5.12451171875,45.712890625&WIDTH=694&HEIGHT=520

...then you'll get back a well-formed, parseable XML document which looks like...

<?xml version="1.0" encoding="UTF-8"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" version="2.0"><channel>    <title>exovi:OV_VISTA_4326_PROSPECTADA</title><description>Generated from exo2</description><link><![CDATA[https://mapadefosas.mjusticia.es:443/geoserver/wms?service=wms&request=GetMap&version=1.1.1&format=application%2Frss+xml&layers=exovi%3AOV_VISTA_4326_PROSPECTADA&styles=prospectada&height=520&width=694&transparent=true&bbox=-10.12451171875%2C34.287109375%2C5.12451171875%2C45.712890625&srs=EPSG%3A4326]]>    </link><atom:link href="https://mapadefosas.mjusticia.es:443/geoserver/wms?service=wms&amp;request=GetMap&amp;version=1.1.1&amp;format=application%2Frss+xml&amp;layers=exovi%3AOV_VISTA_4326_PROSPECTADA&amp;styles=prospectada&amp;height=520&amp;width=694&amp;transparent=true&amp;bbox=-10.12451171875%2C34.287109375%2C5.12451171875%2C45.712890625&amp;srs=EPSG%3A4326" rel="self"/><item><title>OV_VISTA_4326_PROSPECTADA.fid--343d670c_171b1be4379_4def</title><link><![CDATA[https://mapadefosas.mjusticia.es:443/geoserver/wms/reflect?featureid=OV_VISTA_4326_PROSPECTADA.fid--343d670c_171b1be4379_4def&layers=exovi%3AOV_VISTA_4326_PROSPECTADA&format=application%2Fatom%2Bxml]]></link><guid><![CDATA[https://mapadefosas.mjusticia.es:443/geoserver/wms/reflect?featureid=OV_VISTA_4326_PROSPECTADA.fid--343d670c_171b1be4379_4def&layers=exovi%3AOV_VISTA_4326_PROSPECTADA&format=application%2Fatom%2Bxml]]></guid>         <description><![CDATA[<h4>OV_VISTA_4326_PROSPECTADA</h4>
<ul class="textattributes">
<li><strong><span class="atr-name">CARTOGRAFICA_UTM_ID</span>:</strong> <span class="atr-value">177</span></li>
<li><strong><span class="atr-name">FOSA_NM</span>:</strong> <span class="atr-value">186/2009 ASTU</span></li>
<li><strong><span class="atr-name">FOSA_ID</span>:</strong> <span class="atr-value">186</span></li>
<li><strong><span class="atr-name">DENOMINACION_TX</span>:</strong> <span class="atr-value">Fosa en la Avda. de Oviedo, hacia el nº 28</span></li>

<li><strong><span class="atr-name">LOCALIDAD_TX</span>:</strong> <span class="atr-value">Noreña</span></li>
<li><strong><span class="atr-name">PROVINCIA_TX</span>:</strong> <span class="atr-value">Asturias</span></li>
<li><strong><span class="atr-name">LOCALIDAD_ALTERNATIVA_TX</span>:</strong> <span class="atr-value">Noreña</span></li>
<li><strong><span class="atr-name">RAZON_TX</span>:</strong> <span class="atr-value">FUSILAMIENTO</span></li>
<li><strong><span class="atr-name">FOSA_ESTADO_TX</span>:</strong> <span class="atr-value">DESAPARECIDA</span></li>
<li><strong><span class="atr-name">ESTADO_ACTUAL_FOSA_TX</span>:</strong> <span class="atr-value">BAJO CONSTRUCCIÓN</span></li>
<li><strong><span class="atr-name">NUM</span>:</strong> <span class="atr-value">0</span></li>
</ul>
]]></description><georss:point>43.394316667 -5.706486111</georss:point></item>    <item><title>OV_VISTA_4326_PROSPECTADA.fid--343d670c_171b1be4379_4df0</title><link><![CDATA[https://mapadefosas.mjusticia.es:443/geoserver/wms/reflect?featureid=OV_VISTA_4326_PROSPECTADA.fid--343d670c_171b1be4379_4df0&layers=exovi%3AOV_VISTA_4326_PROSPECTADA&format=application%2Fatom%2Bxml]]></link><guid><![CDATA[https://mapadefosas.mjusticia.es:443/geoserver/wms/reflect?featureid=OV_VISTA_4326_PROSPECTADA.fid--343d670c_171b1be4379_4df0&layers=exovi%3AOV_VISTA_4326_PROSPECTADA&format=application%2Fatom%2Bxml]]></guid><description><![CDATA[<h4>OV_VISTA_4326_PROSPECTADA</h4>

You should then be able to pipe that through a XML or GeoRSS parser and transform your data as desired. Depending on your skillset and tools, you might want to try other non-image format. There is no need to work with Leaflet at all if you can just download the data.


(Please note that that particular endpoint offers data in GeoRSS format at the time of this writing, and that other WMS endpoints may or may not provide non-image formats, as configured by their administrators)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.