Bug report #19855

Error using QGIS 3.2.2 Warp (Reproject) tool with custom coordinate system

Added by Mario Reyes over 6 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Processing/GDAL
Affected QGIS version:3.2.2 Regression?:No
Operating System:Windows 10 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27679

Description

I'm using the QGIS Warp (Reproject) tool to reproject a raster from WGS84 to a Lambert Conformal Conic custom projection in QGIS 3.2.2. The call to the GDAL/OGR console is the following:

gdalwarp -t_srs "+proj=lcc  +lat_1=13.31666666666667  +lat_2=14.25  +lat_0=13.783333  +lon_0=-89 +x_0=500000 +y_0=295809.184 +ellps=clrk66 +units=m +no_defs +towgs84=0,125,194,0,0,0,0 +wktext" -r near -ot Int16 -of GTiff C:/n13_w090_1arc_v3.tif "C:/Users/HP COREi5/Documents/n13_w090_1arc_v3_nad27.tif" 

When I run the tool this is the result:

Processing algorithm…
Algorithm 'Warp (reproject)' starting…
Input parameters:
{ 'DATA_TYPE' : 1, 'INPUT' : 'C:/n13_w090_1arc_v3.tif', 'MULTITHREADING' : 
False, 'NODATA' : None, 'OPTIONS' : '', 'OUTPUT' : 'C:/Users/HP 
COREi5/Documents/n13_w090_1arc_v3_nad27.tif', 'RESAMPLING' : 0, 'SOURCE_CRS' 
: None, 'TARGET_CRS' : 'USER:100057', 'TARGET_EXTENT' : None, 
'TARGET_EXTENT_CRS' : None, 'TARGET_RESOLUTION' : None }

GDAL command:
gdalwarp -t_srs "+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 
+lat_0=13.783333 +lon_0=-89 
+x_0=500000 +y_0=295809.184 +ellps=clrk66 +units=m +no_defs 
+towgs84=0,125,194,0,0,0,0 
+wktext" -r near -ot Int16 -of GTiff C:/n13_w090_1arc_v3.tif "C:/Users/HP 
COREi5/Documents/n13_w090_1arc_v3_nad27.tif" 
GDAL command output:

FAILURE: No target filename specified.

Usage: gdalwarp [--help-general] [--formats]

[-s_srs srs_def] [-t_srs srs_def] [-to "NAME=VALUE"] [-novshiftgrid]

[-order n | -tps | -rpc | -geoloc] [-et err_threshold]

[-refine_gcps tolerance [minimum_gcps]]

[-te xmin ymin xmax ymax] [-tr xres yres] [-tap] [-ts width height]

[-ovr level|AUTO|AUTO-n|NONE] [-wo "NAME=VALUE"] [-ot Byte/Int16/...] [-wt 
Byte/Int16]

[-srcnodata "value [value...]"] [-dstnodata "value [value...]"] -dstalpha

[-r resampling_method] [-wm memory_in_mb] [-multi] [-q]

[-cutline datasource] [-cl layer] [-cwhere expression]

[-csql statement] [-cblend dist_in_pixels] [-crop_to_cutline]

[-of format] [-co "NAME=VALUE"]* [-overwrite]

[-nomd] [-cvmd meta_conflict_value] [-setci] [-oo NAME=VALUE]*

[-doo NAME=VALUE]*

srcfile* dstfile

Available resampling methods:

near (default), bilinear, cubic, cubicspline, lanczos, average, mode, max, 
min, med, Q1, Q3.

Execution completed in 0.18 seconds
Results:
{'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':C:/Users/HP 
COREi5/Documents/n13_w090_1arc_v3_nad27.tif, 'createOptions': 
{'fileEncoding': 'System'}}>}

Loading resulting layers
The following layers were not correctly generated.<ul><li>C:/Users/HP 
COREi5/Documents/n13_w090_1arc_v3_nad27.tif</li></ul>You can check the 'Log 
Messages Panel' in QGIS main window to find more information about the 
execution of the algorithm.

If I copy and paste the command in the OSGeo4W console, editing spaces, runs without problems. It seems the problem is the custom coordinate system. If is too long, like in this case, the command is split in several lines and only the first line is passed to the gdalwarp command. It doesn't matter if the path has spaces. If I use a predefined CRS, like UTM I have no problems.

GDAL_system_call.PNG (6.07 KB) Mario Reyes, 2018-09-18 01:43 AM

Associated revisions

Revision e005d6e2
Added by Nyall Dawson over 6 years ago

[processing][gdal] Strip newlines from custom proj CRS definitions
before passing to GDAL commands

Fixes #19855

History

#1 Updated by Nyall Dawson over 6 years ago

  • Status changed from Open to Feedback

Can you confirm that the issue here is the newline characters in the definition of the custom projection? I.e. if you remove these, does everything work as expected?

#2 Updated by Mario Reyes over 6 years ago

Nyall Dawson wrote:

Can you confirm that the issue here is the newline characters in the definition of the custom projection? I.e. if you remove these, does everything work as expected?

Yes, it seems that is the problem. When I run gdalwarp in the OSGeo4W console everything is fine if I slightly edit the command to get rid of those newline characters. This problem is not present in QGIS 2.18.x with GDAL Tools nor with the Warp tool for that version.

#3 Updated by Andre Joost over 6 years ago

I just tried this in QGIS 3.2.2 form OSGEO4W on Windows 7 and it works for me. The output is:

Processing algorithm…
Algorithm 'Warp (reproject)' starting…
Input parameters:
{ 'DATA_TYPE' : 5, 'INPUT' : 'D:/Download/NEU/Elsalvador.tif', 'MULTITHREADING' : False, 'NODATA' : None, 'OPTIONS' : '', 'OUTPUT' : 'D:/Download/NEU/ElSalvador-lcc.tif', 'RESAMPLING' : 0, 'SOURCE_CRS' : None, 'TARGET_CRS' : 'USER:100001', 'TARGET_EXTENT' : None, 'TARGET_EXTENT_CRS' : None, 'TARGET_RESOLUTION' : None }

GDAL command:
gdalwarp -t_srs "+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +ellps=clrk66 +units=m +no_defs +towgs84=0,125,194,0,0,0,0 +wktext" -r near -ot Float32 -of GTiff D:\Download\NEU\Elsalvador.tif D:/Download/NEU/ElSalvador-lcc.tif
GDAL command output:
0...10...20...30...40...50...60...70...80...90...100 - done.

Execution completed in 0.66 seconds
Results:
{'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':D:/Download/NEU/ElSalvador-lcc.tif, 'createOptions': {'fileEncoding': 'System'}}>}

Loading resulting layers
Algorithm 'Warp (reproject)' finished

So no line breaks are inserted. I had defined the projection as Custom CRS before, and used the Raster menu.

#4 Updated by Mario Reyes over 6 years ago

Andre Joost wrote:

I just tried this in QGIS 3.2.2 form OSGEO4W on Windows 7 and it works for me. The output is:

[...]

So no line breaks are inserted. I had defined the projection as Custom CRS before, and used the Raster menu.

I don't know if it's something specific in my computer. I installed QGIS using the stand alone installer. I attach a screenshot of my GDAL system call. In my case it works if I usea predefined CRS. Thanks.

#5 Updated by Mario Reyes over 6 years ago

Mario Reyes wrote:

Andre Joost wrote:

I just tried this in QGIS 3.2.2 form OSGEO4W on Windows 7 and it works for me. The output is:

[...]

So no line breaks are inserted. I had defined the projection as Custom CRS before, and used the Raster menu.

I don't know if it's something specific in my computer. I installed QGIS using the stand alone installer. I attach a screenshot of my GDAL system call. In my case it works if I usea predefined CRS. Thanks.

Sorry, it seems that in the definition of my CRS there was a newline character. It didn't cause problems reprojecting vector files, but it seems when using a GDAL tool there are problems. Thanks for your help. This bug can be closed.

#6 Updated by Nyall Dawson over 6 years ago

It's still a valid bug -- we just need to strip out newline characters from the def when running gdal commands

#7 Updated by Nyall Dawson over 6 years ago

  • Status changed from Feedback to In Progress

#8 Updated by Nyall Dawson over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Closed

Also available in: Atom PDF