PDA

View Full Version : [SOLVED:] Service Géoplateforme d'images WMS-Raster



aj3309
12-10-2023, 06:01 AM
Bonjour,
Mon besoin est le suivant , pour l'utiliser sous Excel vba je cherche a obtenir un morceau de carte géoréférencé,
j'ai trouvé plein de solutions pour obtenir de telles cartes mais à chaque fois je n'ai que les coordonnées du centre de la carte,
insuffisant pour afficher d'autres points sur la carte.
Je suis en train de creuser la piste du Service Géoplateforme d'images WMS-Raster
.en utilisant les 3 méthodes proposées , en particulier Getmap pour obtenir la carte.
Voici l'url que j'utilise
https://data.geopf.fr/wms-r?LAYERS= OI.OrthoimageCoverage &FORMAT= image/jpeg &SERVICE=WMS&VERSION=1.3.0&
REQUEST=GetMap&STYLES=&CRS= EPSG:4326&
BBOX=47.34956960,3.25167353,47.38545104,3.30486151
&WIDTH=256&HEIGHT=256
Je n'arrive pas à faire fonctionner cet url
j'obtiens toujours ServiceExceptionReport></ServiceExceptionReport>
Si quelqu'un pouvait m'envoyer une url de ce type qui fonctionne
je pourrais finaliser mon application de covoiturage pour les membres de mon club rando

jdelano
12-10-2023, 08:29 AM
This worked for me to download the image returned by the URL, you can then load the image wherever you need it.




Private Sub CommandButton1_Click()

Dim http As New XMLHTTP60
Dim mapImage() As Byte
Dim mapImageFileName As String

' get the image from the website
With http
.Open "GET", "https://data.geopf.fr/wms-r?LAYERS=OI.OrthoimageCoverage&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=&CRS=EPSG:4326&BBOX=47.34956960,3.25167353,47.38545104,3.30486151&WIDTH=256&HEIGHT=256", False
.send
mapImage = .responseBody
End With

' convert the byte array to an image file
mapImageFileName = WriteArrayToDisk("F:\Temp\mapimage.jpg", mapImage())

End Sub


Private Function WriteArrayToDisk(ByRef fileName As String, ba() As Byte) As String


Dim intFF As Long

intFF = FreeFile()
Open fileName For Binary As #intFF
Put #intFF, 1, ba
Close #intFF

WriteArrayToDisk = fileName

End Function

aj3309
12-10-2023, 08:58 AM
Merci beaucoup à Jdelano , son code marche très bien. Cela ne marchait pas bien chez moi car j'avais laissé des espaces dans l'url.

jdelano
12-10-2023, 09:03 AM
You are very welcome!