3

I have a folder with numerous .asc raster files that each accompanied by a corresponding .prj file. The file basename is the same for both files. The projection however can vary between all of them (they are currently in various different UTM projection).
What I want to achieve is to standardize the projection of all those individual raster files. My current approach is this bash-script

#!/bin/bash
echo Starting Conversion to WGS84
for f in *.asc;
 do 
  echo Converting "$f";
  echo To "${f%.asc}_wgs84.tif";
  gdalwarp "$f" "${f%.asc}_wgs84.tif" -t_srs "+proj=longlat +ellps=WGS84";
  done
echo Conversion finished

However the script fails for each file returning:

"Invalid request to pj_param, fatal"

So I would like to see a bunch of reprojected .tif (or any other format) files that all have the same projection.

While typing this I am also working on a python script, which however does not seem to be as straight-forward as bash.


call: gdalinfo grid2000.asc It seems to fail even at the end?

Driver: AAIGrid/Arc/Info ASCII Grid
Files: grid2000.asc
       grid2000.prj
Size is 16, 16
Coordinate System is:
PROJCS["WGS_1984_UTM_Zone_30N",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_84",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-3],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
Origin = (565146.201264380943030,680158.854243048001081)
Pixel Size = (30.000000000000000,-30.000000000000000)
invalid request to pj_param, fatal

call: gdalsrsinfo xyz.prj # (Note that xyz.prj could be a different file)

PROJ.4 : '+proj=utm +zone=17 +south +datum=WGS84 +units=m +no_defs '

OGC WKT :
PROJCS["WGS_1984_UTM_Zone_17S",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_84",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-81],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",10000000],
    UNIT["Meter",1]]
  • try -t_srs epsg:4326 – Ian Turton Oct 26 '15 at 10:27
  • So like this? gdalwarp "$f" "${f%.asc}_wgs84.tif" -t_srs "epsg:4326"; That sadly fails too. My guess is that it has something to do with the fact that the projection information is not saved within the .asc itself but instead in a seperate .prj file. – Curlew Oct 26 '15 at 10:32
  • 1
    no quotes around epsg:4326 - can you post one of the .prj files? – Ian Turton Oct 26 '15 at 10:33
  • actually what happens if you run gdalinfo on one of the .asc files? does it pick up the projection? – Ian Turton Oct 26 '15 at 10:33
  • Edited. Very strange. The error even pops up in the gdalinfo screen – Curlew Oct 26 '15 at 10:40
2

Before running your script in my Debian system:

enter image description here

It ran perfectly without any error (and without modifications anywhere):

enter image description here

Each image was adequately projected to WGS84.

What is the result of one individual projection with the command at the bash console (without script)? Is it successfully?

  • Thanks for testing! This gives me confidence that this issue might be related to sth. happening on my system. I am running this on an external server where I don't have any admin-rights and I am smelling some faulty configuration here.... – Curlew Oct 26 '15 at 16:34
  • OK. I thought in a GDAL problem because your script works perfectly. – xunilk Oct 26 '15 at 16:39

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.