2

Have been using the usual code in python console to use the world imagery layer as a base map and have been pretty happy with this, from IEQGIS page

qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty+true","raster")

However, just stopped working...error msg below

It has been superseded by a plugin but can't find a way of getting this to work either. Any ideas why this does not work or which URL to put in the REST API?

Error message: Invalid Layer    GDAL provider: Cannot open GDAL dataset http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty+true: Invalid dataset dimensions : -2147483648 x -2147483648
Raster layer: Provider is not valid (provider: gdal, URI: http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty+true

Another more recent error:

GDAL provider: Cannot open GDAL dataset server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json: `server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json' does not exist in the file system, and is not recognised as a supported dataset name. 
Raster layer: Provider is not valid (provider: gdal, URI: server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json
GeoSharp
  • 3,256
  • 17
  • 28
  • 1
    Please post error messages as text, not as a screenshot. If you had, you might have noticed the extra characters between "ser" and "vices" – Vince Nov 04 '15 at 16:22
  • That was not the issue but will do as suggested in future – SNA user1969 Nov 04 '15 at 16:59
  • 1
    Please do as @Vince has suggested for this question by using the [edit] button beneath your question. – PolyGeo Nov 04 '15 at 19:36
  • I have the exact same experience as SNAuser1969, namely that for the past several months I have been successfully adding high resolution (up to 1:1300 scale) arcgis world imagery as my base map using the exact same URL as published here https://ieqgis.wordpress.com/2014/08/09/adding-esris-online-world-imagery-dataset-to-qgis/ but quite suddenly this has stopped working and I’m getting the exact same error message as SNA ser1969. Since nothing has changed my end clearly something has changed at the server end. I’ve tried all the URLs in this thread to no avail. I’m on QGIS 2.12 win 7 64 bit. I – goatwillow Nov 05 '15 at 13:29
  • From http://downloads2.esri.com/ArcGISOnline/docs/tou_summary.pdf. "Use with Esri software, and comply with its terms of use. If you do not have Esri software, you must purchase an ArcGIS Online subscription". Is it possible that ESRI have added some server side code to validate client connection? It would be a shame if they enforce this clause. – Mac Maclean Nov 06 '15 at 01:46

5 Answers5

2

I found a solution to our problem guys... SNA user1969 - I'm also based in Ireland :)

Everybody who needs high quality maps in qgis should install OpenLayers Plugin. To do this navigate to Main Menu >> Plugins >> Manage and Install Plugins

Click ALL, search for : OpenLayers, select it, install it...

Now click :

Main Menu >> Web >> Open Layers Plugin >> Bing Maps >> Bing Aerial/Bing Aerial with labels

Now you will see BETTER quality aerial images!

c4rt0
  • 21
  • 5
  • I do use the web plugins as back ups for the background layer but they have a major issue when you want to export to PDF via Print Composer. Also with the ESRI Raster layer, it has editable properties, whereas there is no properties dialog for Bing/Google OpenLayers plugins. Good to share though. – SNA user1969 Nov 06 '15 at 17:07
1

I don't know anything about QGIS but you are getting the map service back as pretty JSON as per your url. Try removing everything starting at the question mark:

qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/ser‌​vices/World_Imagery/MapServer","raster")

I cannot test this, but I would think that removing the query string would do the trick.

crmackey
  • 8,484
  • 18
  • 33
  • Ok. Tried that now and previously and get the same resulting Invalid Layer error as above – SNA user1969 Nov 04 '15 at 14:52
  • I just tried to open the link and that url wasn't valid. This is what you should be using http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer. I would try it like that first and if that doesn't work add your query string that was in the original post ("?f=json&pretty=true"). And I think you can actually just use f=pjson to get pretty json. – crmackey Nov 04 '15 at 14:56
  • Your suggestion produces the same result - I tried MapServer/1?f=json but just crashes QGIS – SNA user1969 Nov 04 '15 at 15:17
  • This raster is crucial as a basemap for me - wonder if anyone can suggest how the REST API works instead? – SNA user1969 Nov 04 '15 at 15:47
  • @SNA_user1969 The service is working fine. You have extraneous characters in your URL. – Vince Nov 04 '15 at 16:58
  • Can't seem to make this work - tried qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true","raster") and qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json","raster") and qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer","raster") none of which work. – SNA user1969 Nov 04 '15 at 18:50
  • @Vince - which extraneous characters in URL please? – SNA user1969 Nov 04 '15 at 20:03
  • You've removed graphics and have not replaced both with text, but it was obvious from the first image (which hasn't been replaced) that there were hidden characters in the URL. As discussed by @crmackey, "pretty=true" doesn't mean anything, even from a browser, and the API you are using likely appends the options to what you provide, so you should only provide the URL to the service itself. – Vince Nov 04 '15 at 20:14
  • So started again by typing in rather than copy/paste any part - the URL works without the pretty=true if placed in browser yet put in python console gives new invalid layer (see edit above). I'm using a mac, on El Capitan any issue there? problem began after upgrade. – SNA user1969 Nov 05 '15 at 10:39
  • Tried new install of QGIS to 2.12, reinstalled GDAL framework, tried also running code in terminal as well from here - http://hub.qgis.org/wiki/17/Arcgis_rest So pretty exhausted this unless someone can answer this. – SNA user1969 Nov 05 '15 at 12:47
1

I was using the "World Imagery" and I'm having the same problem. For now I'm using this:

qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer?f=json&pretty=true","raster"). 

Does this help you?

GeoSharp
  • 3,256
  • 17
  • 28
  • Thanks Hugo - whilst this works the imagery is really poor for UK and Ireland... good to work out that it is the URL that is giving problems though. – SNA user1969 Nov 04 '15 at 16:59
  • This was the raster I was linking to - http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer?f=jsapi – SNA user1969 Nov 04 '15 at 17:14
  • 1
    As said Hugo - your link works fine but the resolution is poor - if I adapt the line to direct to World_Imagery instead I get this Invalid Layer: GDAL provider: Cannot open GDAL dataset http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer?f=json&pretty=true: Invalid dataset dimensions : -2147483648 x -2147483648 Raster layer: Provider is not valid (provider: gdal, URI: http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer?f=json&pretty=true – SNA user1969 Nov 05 '15 at 11:07
1

Putting this here for ease as it took me a while to figure out the exact xlm file since I don't do this that often. Just open your favorite text/xml editor and paste this. Then drag to your layers and you are set! Let me know if it doesn't work.

<GDAL_WMS>
  <Service name="TMS">
    <ServerUrl>http://server.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer/tile/${z}/${y}/${x}</ServerUrl>
  </Service>
  <DataWindow>
    <UpperLeftX>-180.00000000</UpperLeftX>
    <UpperLeftY>90.00000000</UpperLeftY>
    <LowerRightX>180.00000000</LowerRightX>
    <LowerRightY>-90.00000000</LowerRightY>
    <TileLevel>15</TileLevel>
    <TileCountX>2</TileCountX>
    <YOrigin>top</YOrigin>
  </DataWindow>
  <Projection>EPSG:4326</Projection>
  <BlockSizeX>512</BlockSizeX>
  <BlockSizeY>512</BlockSizeY>
  <Cache />
</GDAL_WMS>
patterse
  • 11
  • 1
0

Ironically my neighbour has come up with a fix - seems there is a bit of a bug. A way round this is as he describes:

"Here is how I managed to get the ArcGIS REST service to work:

gdal_translate --debug on http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer?f=json out.xml -of WMS

This produces the same error you see in QGIS: "ERROR 1: Invalid dataset dimensions : -2147483648 x -2147483648"

The error is being triggered because the layer is so large, there is a bug filed for this in the gdal_translate project. Even though it is erroring, gdal_translate does actually generate the required metadata that QGIS needs to add a Raster layer and allows you to tweak the tile level to a lower value to allow QGIS to display the layer. You need to use a working layer metadata file and, add this via the main menu: Layer -> Add Layer -> Add Raster Layer (Shift + CMD + R)"

So create an .xml file with: http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/${z}/${y}/${x} -20037508.34278700 20037508.34278700 20037508.34278103 -20037508.34278103 22 1 top EPSG:3857 256 256

End point is an editable aerial raster layer - happy times