[R-sig-Geo] saga grid format TOPTOBOTTOM
Robert J. Hijmans
r.hijmans at gmail.com
Tue May 28 02:16:28 CEST 2013
Chuck,
raster can read both TOPTOBOTTOM=FALSE and TOPTOBOTTOM=TRUE SAGA
files. However, it only writes TOPTOBOTTOM=TRUE.
GDAL can read and write TOPTOBOTTOM=TRUE only. Apparently QGIS has a
native driver for SAGA that can only do TOPTOBOTTOM=FALSE, which is
odd (as it not the common approach). Can't you force QGIS to use GDAL
to read SAGA files? Another approach would be to use e.g. GTiff.
If you are desperate you could also write a function to create the
type QGIS needs using flip(r, 'y') and that then changes the SAGA
header file to TOPTOBOTTOM=FALSE.
Robert
On Mon, May 20, 2013 at 9:46 AM, Chuck Bulmer <cebulmer at telus.net> wrote:
> Hi all.
>
> I am using package raster to crop some saga grids with a shapefile.
>
> The original inut sgrd file looks like this:
>
> NAME = ELEV_1HA
> DESCRIPTION =
> UNIT =
> DATAFILE_OFFSET = 0
> DATAFORMAT = FLOAT
> BYTEORDER_BIG = FALSE
> POSITION_XMIN = 321888.3470000000
> POSITION_YMIN = 376291.6470000000
> CELLCOUNT_X = 15358
> CELLCOUNT_Y = 13473
> CELLSIZE = 100.0000000000
> Z_FACTOR = 1.000000
> NODATA_VALUE = -9999.000000
> TOPTOBOTTOM = FALSE
>
> After using the (below) code, the output sgrd file looks like this:
>
> NAME = ELEV_1HA
> DESCRIPTION =
> UNIT =
> DATAFORMAT = FLOAT
> DATAFILE_OFFSET = 0
> BYTEORDER_BIG = FALSE
> POSITION_XMIN = 1427688.347
> POSITION_YMIN = 486091.647
> CELLCOUNT_Y = 1685
> CELLCOUNT_X = 784
> CELLSIZE = 100
> Z_FACTOR = 1.000000
> NODATA_VALUE = -3.4e+38
> TOPTOBOTTOM = TRUE
>
> The resulting files are read by SAGA-GIS with no problem and they look good,
> but I want to use Quantum GIS as my map viewer and when I try to load the
> result file into QGIS it provides me with the following error:
> "..ELEV_1HA is not a supported data source. Currently the Saga Binary Grid
> driver does not support Saga Grids written TOPTOBOTTOM"
>
> If I load and resave the grid with SAGA, TOPTOBOTTOM reverts back to FALSE,
> and the grid can be read by QGIS, but I'd like to avoid this extra step.
>
> Is there a way to add a setting to the crop function? raster? gdal? to write
> as TOPTOBOTTOM=FALSE, which would save me the extra step of loading and
> resaving each grod.
>
> Thanks for any help you can provide
>
> Chuck
>
> Here's the code ... (Windows 7x64)
>
> s <- raster("D:\\BC_DSM\\ELEV_1HA.sdat")
> t<- shapefile("D:\\BC_DSM\\ecodistrict_bdy_b10k.shp")
> crop(s,t,filename="D:\\BC_DSM\\Results\\ELEV_1HA.sdat")
>
>
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/saga-grid-format-TOPTOBOTTOM-tp7583610.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list