Subscribe to this thread
Home - General / All posts - ascii format
146 post(s)
#22-Nov-21 03:34


M9 Question:

I am guessing this is something to do with encoding/line breaks. When I export an image as .asc (or .grd) it shows up as 1 line of text.

Where as when I export from ArcGIS 10.7.1 it comes out as out as many rows (effectively matching the nrows number - so in this example 384 rows).

Is there a way to make M9 export to .asc with multiple rows? I have another program that can only handle .asc files with multiple rows.

Thanks in advance.

ascii example.png


9,886 post(s)
#22-Nov-21 05:26

You forgot to say how you are reading the ascii files produced by either source.

... it shows up as ...

... it comes out as ...

... but where? How are you reading the results?

One reason why it could matter is that both environments might be exporting with line breaks--but perhaps one uses CRLF while the other uses CR only.

For example.

It's important to know.

146 post(s)
#22-Nov-21 07:00

Fair Point.

In terms of reading the files. I have another custom built file convertor which takes the file and compresses them into a zip format for use in another program. Unfortunately, this is black box to me and there are no error messages.

The above attachments are displayed in notepad++.

In both files they show up with CR LF and are both in UTF-8 encoding (not 100% sure if this is notepad ++ default or whether it actual in this format).

I can read either of the files in Arcgis desktop 10.3.1 - through to Arcgis desktop 10.7.1 and they display correctly.

I can also read the files in Qgis 3.10.

I can convert the files to ascii in both arcgis and qgis (gdal-translate). The qgis version puts a white space at the front of each row. I have to remove this using a powershell command to make it work in the custom file converter:


$file_path =$args[0]

$file_path_out = $args[1]

$content = Get-Content $file_path

$content | Foreach {$_.trimstart(" ")} | Set-Content $file_path


My guess is that M9 exports out as .asc and .grd in a different format to arcgis/qgis. I was hoping there might be a way to adjust the formatting of the .asc in M9.

I have a work around…. It just would have been nice to not have to translate from say .tiff > .asc > .zip…. Rather just go .asc > .zip


549 post(s)
#22-Nov-21 11:49

The remainder of the file lists the raster values for each cell, starting at the upper-left corner. These real numbers (with optional decimal point, if needed) are delimited using a single space character.

From the wikipedia page... They do not mention anything about CR/LR. Only a single space is needed.


9,886 post(s)
#23-Nov-21 02:15

With the exported text in Notepad++, you could try this.

Not tested by me, might need a tweak or two.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.