How to add a raster image from a web location

11-24-2015 01:34 PM
Occasional Contributor

Does anyone know how to programatically add a raster image (ungeoreferenced) from the Internet. I can add this image
(\elk_042840_apm_103_36.jpg directly to AGX by selecting Add Content, Add Raster, and then typing or pasting that web address into the box. But when I try to add it programatically, it gives me an error message. One thing I've noticed is that it tells me it can't add the image from http:/data... (notice the single backslash). No matter what I do I can't get it to use two back slashes.

The method I'm using is Raster.OpenRasterFile(webaddress) with the webaddress being exactly what I showed above for the url.

I've tried other methods too. I was successful downloading the above image programatically using webclient and webclient.downloadfile. That worked, but I ran into troubles trying to add the downloaded image as a raster. Here's what I tried.

Dim myImage As Raster = Raster.OpenRasterFile(savepath)

dim myRasterLayer As RasterLayer = rasterlayer.OpenFromRaster(myImage)


This approach also works but then I get an error message that it's got no coordinate system and the georeference option is greyed out so I can't fix it.

Any ideas/comments are appreciated.



0 Kudos
0 Replies