error to extract soil grids data

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

error to extract soil grids data

Mª Eliza Turek
Dear all,

 I need to extract texture and bulk density data for Brazil, in order to
convert it to soil hydraulic parameters using PTF functions. I read in soil
grids website that for this kind of evaluation is better to use "tile"
data. How can I perform that? I Couldn't find a manual for that. (I can't
access http://gsif.isric.org/doku.php?id=wiki:tutorial_soilgrid).
Also, I am starting to use soil grids and found an error that seems to be
very easy but it stopped my work. It seems to be something referent to the
tiff image. I am trying to use the following code, but after the last
command I get the error: Error in .local(.Object, ...) :
 MissingRequired:TIFF directory is missing required "StripByteCounts" field

Can anyone help me? Thank you!

> # SoilGrids tutorial
> # Reference: [http://gsif.isric.org/doku.php?id=wiki:tutorial_soilgrids]
> # [hidden email]
> rm(list=ls())
> library(RCurl)
Loading required package: bitops
> library(rgdal)
Loading required package: sp
rgdal: version: 1.4-3, (SVN revision 828)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
 Path to GDAL shared files:
C:/Users/User/Documents/R/win-library/3.5/rgdal/gdal
 GDAL binary built with GEOS: TRUE
 Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
 Path to PROJ.4 shared files:
C:/Users/User/Documents/R/win-library/3.5/rgdal/proj
 Linking to sp version: 1.3-1
> library(GSIF)
GSIF version 0.5-5 (2019-01-04)
URL: http://gsif.r-forge.r-project.org/
> library(raster)
> library(plotKML)
plotKML version 0.5-9 (2019-01-04)
URL: http://plotkml.r-forge.r-project.org/
> library(XML)
> library(lattice)
> library(aqp)
This is aqp 1.17

Attaching package: ‘aqp’

The following objects are masked from ‘package:raster’:

    metadata, metadata<-, union

The following object is masked from ‘package:base’:

    union

> library(soiltexture)
soiltexture 1.5.1 (git revision: 4b25ba2). For help type:
help(pack='soiltexture')
> ## GDAL paths:
> if(.Platform$OS.type == "windows"){
+   gdal.dir <- shortPathName("C:/Program files/GDAL")
+   gdal_translate <- paste0(gdal.dir, "/gdal_translate.exe")
+   gdalwarp <- paste0(gdal.dir, "/gdalwarp.exe")
+   gdalinfo <- paste0(gdal.dir, "/gdalinfo.exe")
+ } else {
+   gdal_translate = "gdal_translate"
+   gdalwarp = "gdalwarp"
+   gdalinfo = "gdalinfo"
+ }
> ## (a) FTP download:
> ## location of soilgrids:
> sg.ftp <- "ftp://ftp.soilgrids.org/data/recent/"
> filenames = getURL(sg.ftp, ftp.use.epsv = FALSE, dirlistonly = TRUE)
> filenames = strsplit(filenames, "\r*\n")[[1]]
> filenames[1:5]
[1] "ACDWRB_M_ss_250m.tif" "ACDWRB_M_ss_250m.xml" "AWCh1_M_sl1_250m.tif"
"AWCh1_M_sl1_250m.xml" "AWCh1_M_sl2_250m.tif"
> ## download to a local directory:
> ORC.name <- filenames[grep(filenames,
pattern=glob2rx("AWCh2_M_sl2_250m.tif$"))]
> ORC.name
[1] "AWCh2_M_sl2_250m.tif"
> try(download.file(paste(sg.ftp, ORC.name, sep=""), ORC.name))
trying URL 'ftp://ftp.soilgrids.org/data/recent/AWCh2_M_sl2_250m.tif'
downloaded 919.3 MB

> ## check that everything is OK:
> GDALinfo(ORC.name)
Error in .local(.Object, ...) :
  MissingRequired:TIFF directory is missing required "StripByteCounts" field
---------------------------------------------------------------------



--
Maria Eliza Turek
PhD Student - Graduate Program of Environmental Engineering  - PPGEA
Federal University of Paraná - UFPR

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: error to extract soil grids data

Tomislav Hengl-5

Hi Eliza,

The gsif.isric.org tutorials have been migrated to:
https://envirometrix.github.io/PredictiveSoilMapping/

Soil texture fractions and bulk density you can now download directly
from e.g.:

https://landgis.opengeohub.org/#/?base=Stamen%20(OpenStreetMap)&center=-12.8118,-54.3164&zoom=5&opacity=80&layer=sol_bulkdens.fineearth_usda.4a1h_m&depth=30

If you need only Brasil, I recommend using the LandGIS Web Coverage
Service (https://github.com/Envirometrix/LandGISmaps#accessing-data) e.g.:

download.file("https://geoserver.opengeohub.org/landgisgeoserver/ows?service=WCS&version=2.0.1&request=GetCoverage&coverageId=predicted250m:sol_bulkdens.fineearth_usda.4a1h_m_250m_b30..30cm_1950..2017_v0.2&subset=Lat(-34,6)&subset=Long(-74,-28)&scalefactor=0.25",
"brazil_sol_bulkdens.fineearth_usda.4a1h_m_250m_b30..30cm_1950..2017_v0.2.tif")
#  % Total    % Received % Xferd  Average Speed   Time    Time     Time
#Current
#                                 Dload  Upload   Total   Spent    Left
#Speed
#100 25.8M    0 25.8M    0     0  1098k      0 --:--:--  0:00:24
#--:--:-- 2095k
library(raster)
#Loading required package: sp
plot(raster("brazil_sol_bulkdens.fineearth_usda.4a1h_m_1km_b30..30cm_1950..2017_v0.2.tif"))

Clay content
(https://maps.opengeohub.org/layers/predicted250m:sol_clay.wfraction_usda.3a1a1a_m_250m_b30..30cm_1950..2017_v0.2)
and bulk density
(https://maps.opengeohub.org/layers/predicted250m:sol_bulkdens.fineearth_usda.4a1h_m_250m_b30..30cm_1950..2017_v0.2)
are also available via our Geonode.

Having said all this, we have recently derived soil hydraulic parameters
(water content at various suction pressures) for whole world directly
from lab data hence without using any PTF (read more in:
https://twitter.com/opengeohub/status/1115317556343181312), including
the available water capacity (https://doi.org/10.5281/zenodo.2629148).
Which soil hydraulic parameters are you aiming at? Will be curious to
learn from you if any of these layers / instructions help you (please
send a private message).

HTH,

Tom Hengl
https://opengeohub.org/about


On 5/6/19 6:15 PM, Mª Eliza Turek wrote:

> Dear all,
>
>   I need to extract texture and bulk density data for Brazil, in order to
> convert it to soil hydraulic parameters using PTF functions. I read in soil
> grids website that for this kind of evaluation is better to use "tile"
> data. How can I perform that? I Couldn't find a manual for that. (I can't
> access http://gsif.isric.org/doku.php?id=wiki:tutorial_soilgrid).
> Also, I am starting to use soil grids and found an error that seems to be
> very easy but it stopped my work. It seems to be something referent to the
> tiff image. I am trying to use the following code, but after the last
> command I get the error: Error in .local(.Object, ...) :
>   MissingRequired:TIFF directory is missing required "StripByteCounts" field
>
> Can anyone help me? Thank you!
>
>> # SoilGrids tutorial
>> # Reference: [http://gsif.isric.org/doku.php?id=wiki:tutorial_soilgrids]
>> # [hidden email]
>> rm(list=ls())
>> library(RCurl)
> Loading required package: bitops
>> library(rgdal)
> Loading required package: sp
> rgdal: version: 1.4-3, (SVN revision 828)
>   Geospatial Data Abstraction Library extensions to R successfully loaded
>   Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
>   Path to GDAL shared files:
> C:/Users/User/Documents/R/win-library/3.5/rgdal/gdal
>   GDAL binary built with GEOS: TRUE
>   Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
>   Path to PROJ.4 shared files:
> C:/Users/User/Documents/R/win-library/3.5/rgdal/proj
>   Linking to sp version: 1.3-1
>> library(GSIF)
> GSIF version 0.5-5 (2019-01-04)
> URL: http://gsif.r-forge.r-project.org/
>> library(raster)
>> library(plotKML)
> plotKML version 0.5-9 (2019-01-04)
> URL: http://plotkml.r-forge.r-project.org/
>> library(XML)
>> library(lattice)
>> library(aqp)
> This is aqp 1.17
>
> Attaching package: ‘aqp’
>
> The following objects are masked from ‘package:raster’:
>
>      metadata, metadata<-, union
>
> The following object is masked from ‘package:base’:
>
>      union
>
>> library(soiltexture)
> soiltexture 1.5.1 (git revision: 4b25ba2). For help type:
> help(pack='soiltexture')
>> ## GDAL paths:
>> if(.Platform$OS.type == "windows"){
> +   gdal.dir <- shortPathName("C:/Program files/GDAL")
> +   gdal_translate <- paste0(gdal.dir, "/gdal_translate.exe")
> +   gdalwarp <- paste0(gdal.dir, "/gdalwarp.exe")
> +   gdalinfo <- paste0(gdal.dir, "/gdalinfo.exe")
> + } else {
> +   gdal_translate = "gdal_translate"
> +   gdalwarp = "gdalwarp"
> +   gdalinfo = "gdalinfo"
> + }
>> ## (a) FTP download:
>> ## location of soilgrids:
>> sg.ftp <- "ftp://ftp.soilgrids.org/data/recent/"
>> filenames = getURL(sg.ftp, ftp.use.epsv = FALSE, dirlistonly = TRUE)
>> filenames = strsplit(filenames, "\r*\n")[[1]]
>> filenames[1:5]
> [1] "ACDWRB_M_ss_250m.tif" "ACDWRB_M_ss_250m.xml" "AWCh1_M_sl1_250m.tif"
> "AWCh1_M_sl1_250m.xml" "AWCh1_M_sl2_250m.tif"
>> ## download to a local directory:
>> ORC.name <- filenames[grep(filenames,
> pattern=glob2rx("AWCh2_M_sl2_250m.tif$"))]
>> ORC.name
> [1] "AWCh2_M_sl2_250m.tif"
>> try(download.file(paste(sg.ftp, ORC.name, sep=""), ORC.name))
> trying URL 'ftp://ftp.soilgrids.org/data/recent/AWCh2_M_sl2_250m.tif'
> downloaded 919.3 MB
>
>> ## check that everything is OK:
>> GDALinfo(ORC.name)
> Error in .local(.Object, ...) :
>    MissingRequired:TIFF directory is missing required "StripByteCounts" field
> ---------------------------------------------------------------------
>
>
>

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo