Monday 25 March 2019

qgis - Maxent error 'java.lang.NumberFormatException: For input string:"Z^,,,"'


I converted a shp file into asc file in QGIS. Then I tried running the Maxent with that enviromental layer and came across that error message:


java.lang.NumberFormatException: For input string:“Z^,,,”

Can anyone help me?



Answer



This error is caused because your raster is actually GeoTIFF file with .asc extension, which is unsupported by MaxEnt.


You can check this in raster metadata (or by running gdalinfo from comamnd line, or in QGIS Information... from processing toolbox). Check the Driver: value.



enter image description here


Cause:


You converted your .shp with Raster -> Conversion -> Rasterize (Vector to Raster)... which runs gdal_rasterize and create GeoTIFF (default output) even if you choose other format. In this case a warrning message should appear:


enter image description here


Solution:


You can fix your raster file with Raster -> Conversion -> Translate (Convert Format)... (which runs gdal_translate). As output format choose Arc/Info ASCII Grid.


Notice the -of AAIGrid argument in the gdal_translate command preview:


gdal_translate -of AAIGrid /source/path/source.asc /output/path/fixedascraster.asc

Note:



I think (according to GDAL documentation gdal_rasterize), editing gdal_rasterize command with addition -of AAIGrid argument should also work , but this gives me unsupported format error for some reason, but you can give it try.




edit: clarification of note:


According to GDAL documentation gdal_rasterize, you can edit gdal_rasterize command with addition -of argument, and define output type. But in this case it doesn't work for AIIGrid.


Running gdal_rasterize -of AIIGrid.. from command line leads to error which tells you that AAIGrid does not support direct output creation


ERROR 6: Output driver `AAIGrid' not recognised or does not support direct output file creation.

Checking this with gdalinfo --formats gives you:


AAIGrid -raster- (rwv): Arc/Info ASCII Grid


Acording to this message from gdal-dev mailing list the capabilities are:



r: rear


w: write "Create dataset by copying another"


v: supports virtual IO - eg. /vsimem/



Which means that is still supported for translating with gdal_translate


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...