[gdal-dev] using gdal_viewshed

Eli Adam eadam at co.lincoln.or.us
Tue Nov 12 13:26:20 PST 2019


Hi Ben,

On Sun, Nov 10, 2019 at 3:57 AM Ben Avrahami <avrahami.ben at gmail.com> wrote:
>
> Hello all, I've been trying trying to use the newest gdal_viewshed in gdal-dev release, and I've run into an error I can't quite understand.
>
> The input I've been using is:
>
>     gdal_viewshed -md 1000 -ox "691868.511" -oy "3492031.487" <input tiff> <output tiff>

It might be helpful to copy and paste your command so if there are
typos or otherwise, they can be spotted.

A gdalinfo report on your input file could also be helpful.  That
would show coordinates of the image and allow looking at things like
are those coordinates within the image?  Is it in the coordinate
system of the image?  A gdalinfo report details that nicely.

>
> And I get the response:
>
>     ERROR 5: C:\temp\files\out.tif, band 1: Access window out of range in RasterIO().  Requested
>     (0,-1) of size 67x1 on raster of 67x67.
>     ERROR 1: RasterIO error when writing target raster

This makes it seem like something isn't lining up correctly.  With the
absence of information some random guess include: that the coordinate
is not within the image, or perhaps the coordinate is less than -md
1000 units from the edge (although testing that on other data here
worked fine), that there are pixel alignment/resolution issues and
using coordinates not to three decimal places would work better.

I see that gdal_viewshed -md 900 -ox 985710 -oy 658590
http://download.osgeo.org/gdal/data/aaigrid/095b_dem_90m.asc
output2.tif works

and

gdal_viewshed -md 800 -ox 985710 -oy 658590
http://download.osgeo.org/gdal/data/aaigrid/095b_dem_90m.asc
output3.tif fails with the error:

0ERROR 5: output3.tif, band 1: Access window out of range in
RasterIO().  Requested
(0,-1) of size 19x1 on raster of 19x19.
ERROR 1: RasterIO error when writing target raster

it seems that -md must be a multiple of the resolution.

Best regards, Eli

>
> I get a similar error if I try to use the GDALViewshedGenerate C-API function. The input us a valid WGS84-UTM tiff file, and the output is a valid path, but the file does not actually exist until I run the command. After I run the command, the output file is created but only filled halfway. Any help at wall would be appreciated.
>
> regards, Ben
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list