Using QGIS V 2.2.0 (OS-Windows 8), I need to prepare raster files (ESRI ArcInfo Grids) to be later used in a species distribucion model using MaxEnt. Each of the original raster files (environmental variables for Guadalquivir, Spain) has a different spatial extension (but all share the same pixel size of 200, -200). However, to be able to use these layers in MaxEnt, all of them need to have the exact same spatial extent. Therefore, I clipped every raster using a polygon of Guadalquivir. After clipping, the new rasters have their original pixel size (200,-200) slightly altered (200.001,-199.942), which means trouble when running the maximum entropy algorithm.

The Layer Spatial Reference System for Guadalquivir is:

+proj=utm +zone=30 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs      

The Layer Spatial Reference System for the raster layers is:

+proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs

I'm using the function raster >> Extraction >> Clipper followed by the options...

  • No data value = 0
  • Mask layer: Guadalquivir

Following, I save the new raster as GeoTIFF.


  1. Should the clipping be done using a polygon with the exact same projection? I am not sure to what extent projections differ in the layers above.

  2. In case response to question 1 was "Yes" (same projections required), I did the clipping using both options: first by saving Guadalquivir as .shp with the raster's projection, and later the other way around, that is saving raster files with Guadalquivir's projection. Regardless of the option described in point 2), pixel size remains altered.

  3. How can I keep the original pixel size of 200,-200?

I wouldn't bother too much about this seemingly slight difference if it weren't for the warning message that I get (see below) when trying to convert the GeoTIFF rasters to ASCII (a requirement for MaxEnt to work):

Warning 1: Producing a Golden Surfer style file with DX and DY instead 
of CELLSIZE since the input pixels are non-square. Use the 
FORCE_CELLSIZE=TRUE creation option to force use of DX for 
even though this will be distorted. Most ASCII Grid readers 
(ArcGIS included) do not support the DX and DY parameters. 

Images can only contain full pixels. Keeping both the the pixel size and exact clipping area is only possible if the clipping area is multiple of the pixel size. You can keep 200 by 200 pixels with 2000x2000 meters sized output but not if the output area is 2001x2101 meters. By default the area is kept accurate and pixel size is adjusted. You can alter the behavior by defining the pixel size of the output but in this case the clipping area will be adjusted.

I would perhaps do clipping with gdalwarp http://www.gdal.org/gdalwarp.html by using parameters -te, -tr, and -tap.


I have used the GDAL tools to rasterize a vector and providing the extension of my desired raster worked but if the data was very specific(i.e. lots of decimal points) I still didn't obtain the extension I needed. So I tried different things that worked in different ways:

a) I modified my rasters to the desired pixel size. If I created a raster from vector I followed this tutorial: http://www.mikemeredith.net/blog/1212_GIS_layer_for_Distance_from_in_QGIS.htm This indicates in the editable box where to provide the pixel size. It also indicates how to provide extension but because my extension was very "long" that didn't work for extension only for pixel size.

b) If you are using QGIS and are preparing your environmental layers for Maxent I suggest using the QSDM plugin and unify all your layers. All layers need to be in the same format (.tiff),same CRS and it helps if they have the same resolution. They will be given an equal extension as new layers that have been "unified". Even if they don't seem like they are the same, checking the metadata will confirm that they have been modified to have the same extension and resolution. Ready to be used in Maxent.

c) Additionally there is a nice tutorial here for Maxent AND QGIS, check out the: "Creating new rasters with GDAL tools" section. Where they cover re-sampling and this is great if you want to change pixel size for your environmental layers. http://clp-foss4g-workshop.readthedocs.org/en/latest/qgis_raster_resample.html

Hope it works and if there are other ways that worked for you I would be happy to know as sometimes for us beginners it is a lot of trial and error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.