7

I downloaded a geotiff from the recently published 25m-DEM of the European Union (see: http://courses.neteler.org/eu-dem-new-digital-surface-model-at-25m/). One tile has about 5GB so I would like to crop it to a smaller extend. I'm trying to use gdalwarp but I can't figure out the correct commands ...

Here's my bounding box: N48 W15 S43 E5

This is the command I tried :

gdalwarp -of gtiff -t_srs EPSG:3857 -te 5 43 15 48 input.tif output.tif

This is the error message that gdalwarp returned:

"Creating output file that is 0P x 0L. ERROR 1: Attempt to create 0x0
dataset is illegal,sizes must be larger than zero."

... could anybody give me a hint, please?

Thank you, Ralf

  • check your coordinates. Im pretty sure E must be larger than W. – nickves Dec 9 '13 at 17:13
  • yes you're right. It was a mistake while typing. – Ralf Glaser Dec 9 '13 at 19:00
8

The coordinates of the target extent have to be expressed in the target SRS:

-te xmin ymin xmax ymax:
set georeferenced extents of output file to be created (in target SRS).

Being...

>cs2cs +init=EPSG:4326 +to +init=EPSG:3857
5 43
556597.45       5311971.85 0.00
15 48
1669792.36      6106854.83 0.00

the command should be something like:

gdalwarp -t_srs EPSG:3857 -te 556597.45 5311971.85 1669792.36 6106854.83 input.tif output.tif
  • I exported the tif but as a result I'm getting strange "gridded" artefacts on the image. Is there a way to avoid nearest neighbor resampling in gdalwarp? Or could this have another reason? Thank you! – Ralf Glaser Dec 10 '13 at 9:07
  • 1
    You have to use the -r option: gdal.org/gdalwarp.html – Antonio Falciano Dec 10 '13 at 9:52
1

the -te flag expects the coordinates to be projected in the -t_srs CRS. EPSG:3857 has as a unit meters, and your inputs are most likely degrees.

to obtain the correct values gdalwarp needs you can project from one coordinate system to antoher using the cs2cs program:

cs2cs +init=epsg:4326 +to +init=epsg:3857

The default order of values are x-y or E-N

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.