How can i import ArcGIS asc file format?

Hello everyone

I’m working on loading asc file(grid file) to Unity3D
I made a script loading asc file but I don’t know how set the value of height field
Look below please!!

float[,] fHeightValue = new float[1025, 1025];

for(int i=0; i<nRows; i++)
{
for(int j=0; j<nCols; j++)
{
// token[inCols + j] has real height of terrain from sea level
// for example
// token[i
nCols + j] = 24.5f; // means 24.5m from sea level
fHeightValue[i, j] = float.Parse(token[i*nCols+ j]);
}
}

// so, I load all height value from asc file but as you know, each height value of asc is not between 0 to 1.0
// if there is a 1024m x 1024m size terrain and a hill which height is 10m is in the middle of the terrain
// that 10m hill will be 0.009765625? (10m / 1024m)
// if i say there is 2048m x 2048m then the same height hill will be 0.0048828125? (10m / 2048m)
// i don’t think so…

// the height value wouldn’t be changed by terrain size, am i wrong?
// the height value only influenced by scale factor i think

// Could you tell me how can I change the real height value to float value which is between 0 to 1.0

I have no idea because of i’m not good at GIS data handling.

Thank You in advance :smile:

the height value is dependent on the Height of the terrain, not the width/depth. So use the height of the terrain (600 by default I think, you can set it in the “Set resolution” dialog.

// Fox
Thank you for reply

But, What I want to know is how can I transfer the real height value such as 24.5 meter to between 0.0 to 1.0 float value.
The ArcGIS’s asc file has real height values

Nobody knows?

I need your help :slight_smile:

you should check all the values in your data file to obtain the highest point. let’s say the highest point is a 150 m, then the height of your terrain should be 150 units, and you would calc the float value by dividing the height by 150, for example 75/150 = 0.5. hope that helps!

// Fox
Oh, You don’t sleep yet, thank you for your reply.

I understand what you mean ^^

And, If i solve that problem, I have another trouble …

It is terrain neighboring.

Each terrain has different height for example, One is the highest value is 100 meter, another is 200 meter then
how can i divide?

Ah!!!

Do I have to setup the resolution height value for the highest value such as first is 100 and second is 200? Is it correct?

Okay, I will try…

THANK YOU fox

Never worked with neighbouring terrains, but that seems like the way to go. Of course you need to know when you calculate the max heights which terrain it will later be present in, so that you get the heights correct. Good luck then!

// Fox

Yes, you are right.
You mean that I should check the terrain which has the most highest height. I see !!

Thanks a lot