Commit bb1e20f3 authored by Laura Poggio's avatar Laura Poggio

global geotiff from webdav

parent 76e9e751
......@@ -11,9 +11,11 @@ Initially you need to import the following package and select the bounding box o
```python
from osgeo import gdal,ogr,osr
bb=-337500.000,1242500.000,152500.000,527500.000 # Example bounding box (homolosine)
bb=-337500.000,1242500.000,152500.000,527500.000 # Example bounding box (homolosine) for Ghana
igh='+proj=igh +lat_0=0 +lon_0=0 +datum=WGS84 +units=m +no_defs' # proj string for Homolosine projection
res=250
sg_url="/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/"
```
#### To a geotiff in Homolosine
......@@ -23,7 +25,7 @@ This GDAL command will create a local geotiff in the Homolosine projection
kwargs = {'format': 'GTiff', 'projWin': bb, 'projWinSRS': igh, 'xRes': res, 'yRes': res, 'creationOptions': ["TILED=YES", "COMPRESS=DEFLATE", "PREDICTOR=2", "BIGTIFF=YES"]}
ds = gdal.Translate('./crop_roi_igh_py.tif',
'/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/ocs/ocs_0-30cm_mean.vrt',
sg_url + 'ocs/ocs_0-30cm_mean.vrt',
**kwargs)
del ds
......@@ -66,3 +68,15 @@ ds = gdal.Translate('./crop_roi_ll_py.tif',
del ds
```
# To download a global geotiff in Homolosine projection
``` python
kwargs = {'format': 'GTiff', 'creationOptions': ["TILED=YES", "COMPRESS=DEFLATE", "PREDICTOR=2", "BIGTIFF=YES"]}
ds = gdal.Translate('./crop_roi_igh_py.tif',
'/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/ocs/ocs_0-30cm_mean.vrt',
**kwargs)
del ds
```
......@@ -11,17 +11,17 @@ Initially you need to load the following libraries and select the bounding box o
```R
library(rgdal)
library(gdalUtils)
bb=c(-337500.000,1242500.000,152500.000,527500.000) # Example bounding box (homolosine)
bb=c(-337500.000,1242500.000,152500.000,527500.000) # Example bounding box (homolosine) for Ghana
igh='+proj=igh +lat_0=0 +lon_0=0 +datum=WGS84 +units=m +no_defs' # proj string for Homolosine projection
sgurl=
sg_url="/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/"
```
#### To a geotiff in Homolosine
This GDAL command will create a local geotiff in the Homolosine projection
```
gdal_translate('/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/ocs/ocs_0-30cm_mean.vrt',
```R
gdal_translate(paste0(sg_url,'ocs/ocs_0-30cm_mean.vrt'),
"./crop_roi_igh_r.tif",
tr=c(250,250),
projwin=bb,
......@@ -35,8 +35,8 @@ The following commands describe a workflow to obtain a VRT or a GeoTiff for an a
##### To local VRT in homolosine (directly from the webdav connection)
The first step is to obtain a VRT for the area of interest in the Homolosine projection. We suggest to use VRT for the intermediate steps to save space and computation times.
```
gdal_translate('/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/ocs/ocs_0-30cm_mean.vrt',
```R
gdal_translate(paste0(sg_url,'ocs/ocs_0-30cm_mean.vrt'),
"./crop_roi_igh_r.vrt",
of="VRT",tr=c(250,250),
projwin=bb,
......@@ -47,7 +47,7 @@ gdal_translate('/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files
##### To a VRT in, for example, LatLong
The following command will generate a VRT in the projection of your choice:
```
```R
gdalwarp("./crop_roi_igh_r.vrt",
"./crop_roi_ll_r.vrt",
s_src=igh,
......@@ -58,7 +58,7 @@ gdalwarp("./crop_roi_igh_r.vrt",
##### To a final Geotiff
The following command will generate a Geotiff in the projection of your choice for the area of interest defined above
```
```R
gdal_translate("./crop_roi_ll_r.vrt",
"./crop_roi_ll_r.tif",
co=c("TILED=YES","COMPRESS=DEFLATE","PREDICTOR=2","BIGTIFF=YES"))
......@@ -67,7 +67,14 @@ gdal_translate("./crop_roi_ll_r.vrt",
#### Read in R
Finally you can read any of the generated VRTs or GeoTiffs in R for further analysis
```
```R
r=readGDAL("./crop_roi_igh_r.vrt") # Or any other of the files produce above
```
# To download a global geotiff in Homolosine projection
```R
gdal_translate(paste0(sg_url,'ocs/ocs_0-30cm_mean.vrt'),
"./crop_roi_igh_r.tif",
verbose=TRUE)
```
......@@ -9,8 +9,12 @@
Initially you need to import the following package and select the bounding box of the area you are interested in:
```Bash
BOUNDS=-337500.000 1242500.000 152500.000 527500.000 # Example bounding box (homolosine)
CELL_SIZE=250 250
BOUNDS="-337500.000 1242500.000 152500.000 527500.000" # Example bounding box (homolosine) for Ghana
ulx uly lrx lry
CELL_SIZE="250 250"
igh="+proj=igh +lat_0=0 +lon_0=0 +datum=WGS84 +units=m +no_defs" # proj string for Homolosine projection
sg_url="/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data"
```
......@@ -18,9 +22,9 @@ CELL_SIZE=250 250
This GDAL command will create a local geotiff in the Homolosine projection
``` bash
gdal_translate -projwin $BOUNDS -tr $CELL_SIZE \
gdal_translate -projwin $BOUNDS -projwin_srs "$igh" -tr $CELL_SIZE \
-co "TILED=YES" -co "COMPRESS=DEFLATE" -co "PREDICTOR=2" -co "BIGTIFF=YES" \
"/vsicurl?max_retry=3&retry_delay=1&list_dir=no&url=https://files.isric.org/soilgrids/latest/data/ocs_0-30cm_mean.vrt" \
$sg_url"/ocs/ocs_0-30cm_mean.vrt" \
"ocs_0-5cm_mean.tif"
```
......@@ -52,3 +56,12 @@ The following command will generate a Geotiff in the projection of your choice
gdal_translate ocs_0-5cm_mean_4326.vrt ocs_0-5cm_mean_4326.tif \
-co "TILED=YES" -co "COMPRESS=DEFLATE" -co "PREDICTOR=2" -co "BIGTIFF=YES"
```
# To download a global geotiff in Homolosine projection
```bash
gdal_translate \
-co "TILED=YES" -co "COMPRESS=DEFLATE" -co "PREDICTOR=2" -co "BIGTIFF=YES" \
$sg_url"/ocs/ocs_0-30cm_mean.vrt" \
"ocs_0-5cm_mean.tif"
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment