How to add a raster image from a web location

3771
0
11-24-2015 01:34 PM
EllenBryson2
Occasional Contributor

Does anyone know how to programatically add a raster image (ungeoreferenced) from the Internet. I can add this image
(http://data.cei.psu.edu/pennpilot/era1940/elk_1941/elk_1941_photos_jpg_200\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)

mapdisp.childItems.add(myRasterLayer)

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.

Thanks

Ellen

0 Kudos
0 Replies