Importing Images from remote location (WMS-Service)

Hey, is it possible to import an image into grasshopper that comes from a remote server? E.g.

https://www.wms.nrw.de/geobasis/wms_nw_dop?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=nw_dop_rgb&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A25832&BBOX=356144.93476667244%2C5643522.405939989%2C357144.93476667244%2C5644522.405939989&WIDTH=560&HEIGHT=560

(It´s a image that is created “on-the-fly”)

Thanks in advance!


c# TextureMaterial from URL.gh (8.1 KB)

Maybe it helps…

Hey Riccardo, thanks for the fast response. Unfortunatelly the image does not appear. I´m on mac.

I don’t own a single Apple hardware… I am not able to assist you :frowning:

Isn’t the component giving any sort of error?

Try to change the path string with a path you know can be freely used (so remove that “GetTempPath” …)

1 Like

I know much of Heron does not work on a Mac, but I am curious if the GdalWarp tool works. Can you give it a try?

20210318_WMSquery.gh (12.0 KB)

1 Like

Hey Brian, the GdalWarp component throws an exception :frowning:

…the component does not give me any error. In fact it seems that it indeed output a “display material” but this one seems to be completly white.

…checked your advice to change the path string. ohmy god it works! :slight_smile:

So for all mac users: change c# component to:

 System.Net.WebRequest request = System.Net.WebRequest.Create(URL);
    System.Net.WebResponse response = request.GetResponse();
    System.IO.Stream responseStream = response.GetResponseStream();
    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(responseStream);
    string path = "/Users/your_name/Desktop/wms_nw_dop.png";
    bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Png);

    Rhino.DocObjects.Texture texture = new Rhino.DocObjects.Texture();
    texture.FileName = path;

    Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
    mat.SetBitmapTexture(texture, true);

Grasshopper.Kernel.Types.GH_Material GHmat = new Grasshopper.Kernel.Types.GH_Material();
GHmat.Value = mat;

TextureMaterial = GHmat;

Thank you Riccardo!

1 Like