Select to view content in your preferred language

Converting an ASCII text file to a raster - distortion problem

4240
8
08-22-2018 02:18 AM
MarionFrotzbacher
Emerging Contributor

Hey,

I'm trying to convert the attached ASCII File containing climate data to a raster layer. But all I get is a distorted raster. I'm using the ASCII to Raster Tool. 

There seems to be no cellsize info in the header of the text file instead only dx dy values and a bunch of other variables.

Vienna Climate Data

Result with distortionWhat it actually should look like

0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

This is the format required for ascii to raster

ASCII to Raster—Conversion toolbox | ArcGIS Desktop 

The format isn't suitable for ascii to raster

* Kooperation ZAMG - DWD KU1
* Modellsimulation zur Anzahl der Sommertage
* auf der Grundlage der Station               
* fuer den Kontrollzeitraum 1971 - 2000
*
* Data specifications
*
subject        Anzahl der Sommertage
unit           per annum
cellpos          1 (=Cell center)
ncols          310
nrows          240
nlevels          1
ncycles          1
xllcorner   611000.00
yllcorner   417000.00
ndigits         f6.1
horizontal cell dimensions dx(1..310)     100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 1... snip
horizontal cell dimensions dy(1..240)     100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 … snip
NODATA_value     -99
*
* Weitere Erlaeuterungen zu den folgenden Datenzeilen:
* Die Zeilen sind von "Nord" nach "Sued" geordnet
* und die Werte in den Zeilen von "West" nach "Ost".
* Die Datenfolge innerhalb der Zeilen ist: Zyklus Niveau S-N-Index W-O-Index Werte ...
* mit den fuehrenden 4 Indizes im Format "i5"
* und den folgenden Werten im Format "ndigits" (siehe oben).
* Fuer die fuehrenden Indizes gelten die Konventionen:
* -99: undefiniert; 0: Laufindex
* NODATA_value: Fehlende Werte
**
    1  -99  240    0  69.8  66.9  66.6  66.3  66.9  66.6  68.1  67.4  67.5  67.2  69.4  69.3  70.3  70.5  71.9  76.2 … snip

In ArcGIS Pro it yields this error message

Parameters
Input ASCII raster file C:\Temp\W_197100_REMO_C20_Sommertage.txt
Output raster C:\GIS\testing_project\testing_project.gdb\ASCIITo_txt2
Output data type FLOAT
 
Messages
Start Time: August 22, 2018 5:48:29 AM
 ERROR 010022: Keyvalue * misses its value.
 ERROR 010067: Error in executing grid expression.
 Failed to execute (ASCIIToRaster).
Failed at August 22, 2018 5:48:29 AM (Elapsed Time: 0.23 seconds)

Where did you get it? perhaps there is some meta data that provides some extra information

0 Kudos
MarionFrotzbacher
Emerging Contributor

Thank you for your quick reply! I got it from the website of the Austrian Weather Information Association (ZAMG). Here is the link: https://www.zamg.ac.at/cms/de/klima/informationsportal-klimawandel/daten-download/stadtklima-zukunft 

But there is no additional information, I have already searched everything. To get the distorted image I got I delete parts of the header. 

That was what I finally put in the header :

ncols 310
nrows 240
xllcorner 611000.00
yllcorner 417000.00
cellsize 100
NODATA_value -99

Because with the other values it would give me errors, but obviously the cellsize is not 100, but I don't really know what to do with the dx/dy values in the original file.

0 Kudos
DanPatterson_Retired
MVP Emeritus

The data are in a projected coordinate system if the corner information is correct.

What appears to be throwing if off are the first 3 or 4 columns.  They are not floating point and they seem to be a reference to a row number, nodata value etc.. The data for the row starts with the first floating point value.  

Sorry, but I will have to defer to you to find a description of how to read the data on that site but it is not a straight ascii format

0 Kudos
MarionFrotzbacher
Emerging Contributor

Ok I see. The first columns contain the nodata value and 0 and 1 and the number of the row. 

There is some information in the file, it says:

"The rows are aranged from north to south and the values in the rows from west to east. The data sequence within the rows is: cycle standard S-N-Index W-O Index Values, with the leading 4 indices in the format "i5" and the values in the fomat "idigits"

The indices have the following rules:

-99 undefined; 0: running index

NODATA: missing values"

But I guess that doesn't really help how to read the first 4 rows. Do you think deleting the first 4 colums would help?

0 Kudos
DanPatterson_Retired
MVP Emeritus

On a copy... I have never seen an ascii file like that before... but the short header you are using is what is needed, but the data in those columns except for the floating point values are strange  ie     1  -99  240    0 

MarionFrotzbacher
Emerging Contributor

ok I finally deleted the first 4 digits in each row and it works now. I don't know what's the purpose of those. Thank you very much for your help, I wouldn't have figured it out on my own.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Glad it worked out Marion... I would be interested as to why it was in that form, but my spoken language skills are limited

0 Kudos
DanPatterson_Retired
MVP Emeritus

and as an afterthought... the extra 'columns' would definitely throw things off since the number of rows and columns specified wouldn't be correct

0 Kudos