5

I have soil data and BioClim data from Australia

soil data:

rows 2200
columns 1400
pixel size 0.0025, -0.0025 255

BioClim data:

rows 660 
columsn 420 
pixel size 0.00833333, -0.00833333

I am using QGIS but happy to use commandline or Python. How can I resample the soil data to match the pixel size of the BioClim data? I would like to add this to my Maxent model and I am sure it needs to be the same resolution.

I have looked for duplicate questions but could not see anything that specifically did this.

Jochen Schwarze
  • 14,605
  • 7
  • 49
  • 117
SteveResearch
  • 291
  • 2
  • 14

2 Answers2

4

gdalwarp -tr should deliver what you want.

gdal_translate -outsize does basically the same thing, if both datasets share the same extent.

In QGIS, Raster -> Projections -> Warpand Raster -> Conversions -> Translate call the same functions. For the first one, you have to edit the command line to get the -tr option.

You might have to do additional steps if the cell extent must match exactly.

AndreJ
  • 76,698
  • 5
  • 86
  • 162
  • I used:

    'gdalwarp -of VRT -r average -tr 0.00833333,0.00833333 soils1.asc interim.vrt' then 'gdal_translate -of AAIGrid interim.vrt soils.asc'

    However Maxent still won't run on these files as it gives an error "Bio1_49_new.asc and soils.asc have different dimensions"

    – SteveResearch Jan 16 '16 at 15:06
  • FILE Bio1_49_new.asc

    #DRIVER# GDAL provider AAIGrid Arc/Info ASCII Grid #DATASET DESCRIPTION# Bio1_49_new.asc #DIMENSIONS# X: 660 Y: 420 Bands: 1 #ORIGIN# 114.5,-32 #PIXEL SIZE# 0.00833333,-0.00833333 #NO DATA VALUE# -9999 #DATA TYPE# Float64 - Sixty four bit floating point #LAYER SPATIAL REFERENCE SYSTEM# +proj=longlat +datum=WGS84 +no_defs #LAYER EXTENT (layer original source protection)# 114.5000000000029985,-35.5000000000029985 : 119.9999999997830002,-32.0000000001429967

    – SteveResearch Jan 16 '16 at 15:07
  • FILE Soils

    #DRIVER# GDAL provider AAIGrid Arc/Info ASCII Grid #DATASET DESCRIPTION# soils.asc #DIMENSIONS# X: 660 Y: 420 Bands: 1 #ORIGIN# 114.5,-32 #PIXEL SIZE# 0.00833333,-0.00833333 #NO DATA VALUE# -9999 #DATA TYPE# Float64 - Sixty four bit floating point #LAYER SPATIAL REFERENCE SYSTEM# +proj=longlat +datum=WGS84 +no_defs #LAYER EXTENT (layer original source protection)# 114.4999990000000025,-35.4999893999999969 : 119.9999968000000052,-31.9999907999999955

    – SteveResearch Jan 16 '16 at 15:07
  • Do these files need to be EXACTLY the same dimensions for MaxEnt to run? I have used: gdal_translate -projwin 114.5 -30.0 120.0 -35.5 -of AAIGrid file1 file2 to clip the file down after the rescaling. – SteveResearch Jan 16 '16 at 15:08
  • You could use gdal_translate -a_ullr 114.5 -30 120 -35.5 on both files as well. I have no experience with MaxEnt. – AndreJ Jan 16 '16 at 17:50
2

I used gdalwarp for exactly same purpose. From QGIS version 2.12 there is also built-in Raster alignment tool (Raster -> Raster alignment tool) - it can clip, resample and reproject rasters to match other raster. For more info see changelog here: http://qgis.org/en/site/forusers/visualchangelog212/#feature-raster-alignment-tool

edit: To run MaxEnt all environmental data must have the exactly same extent, cell size and coordinate system. So when using gdalwarp you have to specify extent -te and resolution -tr (or -ts for size in pixels).

For example I was using:

gdalwarp -t_srs EPSG:4326 -te 64.9916666666670011 35.0083333333329989 84.9916666658670010 45.0083333329329989 -ts 2400 1200 -r cubic -dstnodata -9999 LC_asia.tif LC_asia2.tif
Oto Kaláb
  • 6,895
  • 3
  • 29
  • 50
  • The Raster Alignment Tool sounds perfect for what I need to do. However I can't see in in Qgis 2.4 Chigiak. Any ideas why - do I need to install it? – SteveResearch Jan 17 '16 at 07:55
  • It's new feature for QGIS 2.12 Lyon. To get this feature you have to install this version. – Oto Kaláb Jan 17 '16 at 16:19
  • Ah... I was reading that as 2.1.2 thinking "I've got 2.four which is a later version". You are referring to '2.twelve'! I will get that installed tomorrow. Thanks for your help. – SteveResearch Jan 17 '16 at 21:20