Select to view content in your preferred language

arcpy AsciiToRaster cannot convert ascii files that contain a lot of 'nodata (-9999)'

3668
12
Jump to solution
03-13-2021 01:56 PM
RYokochi
Emerging Contributor

I have 570 ascii files with headers (example shown below). About 400 of them opens as ascii or I can convert to raster using arcpy 'AsciiToRaster'. But I have problem with coastal cells containing relatively large fraction of 'Nodata_value' cells.

I first thought it could be the format of nodata_values, but some files contain smaller number of nodata-values works, so this is probably not the case. The coastal cells I can open does not seem to have exact matching coastal line with the baseman. The coordinate system of the ascii data is JGD2011.  

Anyone could advise what the problem is and how I could fix? 

-----

NCOLS 225
NROWS 150
XLLCORNER 130.3
YLLCORNER 32.675
CELLSIZE 5.555555333335368e-05
NODATA_VALUE -9999

0 Kudos
12 Replies
RYokochi
Emerging Contributor

Here is a summary so people get consolidated answers from the question without following the exchanges: 

Why didn't arcpy convert my ascii file?: Because the number of data was insufficient for the given column x row

Why was the number of data insufficient?: Because a fraction of the data over the ocean was omitted. The original data in xml file did contain this information as 'start point' but I was not aware. 


The ascii file was generated from an .xml file from Japanese database at https://fgd.gsi.go.jp/download/mapGis.php?tab=dem

Rather than translating these oneself, there two programs freely available [both also informed by Luke_Pinner]:  

A software from: https://www.ecoris.co.jp/contents/demtool.html

A Python script from: https://gist.github.com/minorua/4993166.

I used the Python script to generate the map I wanted (attached). 

Thank you, Luke_Pinner!!! 

0 Kudos
Luke_Pinner
MVP Regular Contributor

One more option which works with ArcGIS Pros arcgispro-py3 python environment

Save and run the fgddem.py script from https://gist.github.com/minorua/4993166.

 

D:\Temp\jpgis> activate arcgispro-py3

(arcgispro-py3) D:\Temp\jpgis> python fgddem.py
No input files selected
=== Usage ===
python fgddem.py [-replace_nodata_by_zero] [-f format] [-out_dir output_directory] [-q] [-v] src_files*

src_files: The source file name(s). JPGIS(GML) DEM zip/xml files.

(arcgispro-py3) PS D:\Temp\jpgis> python fgddem.py -f GTIFF -out_dir . FG-GML-4930-01-20-DEM5A-20161001.xml
translating FG-GML-4930-01-20-DEM5A-20161001.xml
completed

 

Luke_Pinner_0-1616102774348.png

 

RYokochi
Emerging Contributor

This is my favorite! Thank you again for the solution #3! 

0 Kudos