🔒 Locked
Height maps
Advertisement
Original Post
If anyone knows how to create a height map from the following data, please let me know. I've been trying to do this for months and don't seem to be getting anywhere. The data has been extracted from Ordinance Survey height data.
"xvalue","yvalue","zvalue
,336020.85,390863.55,53.00
,336030.55,390448.55,48.20
,336079.50,390543.75,49.10
,336086.60,390364.35,49.10
,336114.75,390875.10,58.20
,336129.55,390805.10,59.06
,336131.10,390766.35,58.20
,336132.10,390287.60,48.50
,336136.25,390701.45,57.30
,336142.05,390012.40,46.60
,336147.15,390603.20,54.30
,336173.40,390869.95,61.00
,336179.95,390505.00,52.40
,336180.35,390186.45,47.00
,336200.95,390873.85,61.60
,336203.65,390367.90,51.80
,336208.20,390009.20,47.20
,336210.30,390373.05,53.03
,336230.45,390291.05,51.20
,336274.00,390012.70,48.50
,336280.20,390472.90,58.20
,336283.85,390905.05,62.80
,336303.90,390456.35,58.50
,336339.30,390625.05,66.40
,336368.70,390032.50,51.50
,336377.65,390571.50,68.00
,336384.50,390728.20,66.32
,336388.95,390653.40,66.80
,336392.15,390736.40,65.50
,336395.10,390840.30,63.70
,336398.20,390463.00,65.20
,336400.70,390935.90,62.50
,336410.00,390402.30,64.30
,336410.70,390361.95,62.20
,336415.50,390170.75,60.78
,336428.30,390132.15,51.90
,336440.65,390069.65,57.60
,336480.60,390369.20,65.80
,336497.95,390959.30,62.80
,336506.40,390372.90,66.85
,336523.75,390470.80,68.30
,336539.45,390455.00,68.73
,336543.00,390069.25,62.20
,336544.55,390989.35,63.65
,336549.90,390418.50,68.30
,336566.40,390342.60,67.10
,336567.80,390080.15,63.34
,336570.25,390471.30,68.00
,336572.75,390371.15,67.79
,336584.00,390977.45,63.10
,336599.85,390285.75,65.50
,336600.75,390366.35,66.80
,336637.85,390280.40,64.78
,336638.20,390467.00,66.57
,336649.40,390263.50,64.00
,336649.80,390567.50,65.80
,336652.55,390636.90,65.50
,336654.65,390369.85,64.90
,336656.80,390749.50,64.90
,336657.15,390070.15,62.50
,336658.25,390595.90,66.34
,336661.05,390864.85,64.30
,336661.35,390476.55,65.50
,336664.70,390981.35,64.00
,336673.65,390963.15,64.54
,336711.20,390370.35,63.40
,336741.30,390655.25,64.47
,336741.45,390216.00,61.30
,336749.15,390980.80,64.90
,336761.30,390074.00,59.70
,336763.55,390971.10,65.55
,336778.40,390650.90,63.70
,336785.65,390465.50,62.50
,336818.30,390371.60,61.60
,336823.40,390651.15,63.84
,336845.20,390182.50,58.50
,336847.95,390647.60,63.10
,336859.95,390063.50,57.60
,336860.90,390991.35,65.20
,336865.40,390010.00,57.30
,336871.65,390104.15,57.60
,336873.75,390013.15,58.08
,336884.25,390372.15,60.70
,336902.65,390491.30,62.20
,336914.15,390989.60,64.60
,336919.85,390917.60,64.00
,336928.50,390813.95,63.10
,336930.15,390742.90,62.72
,336931.35,390160.20,56.40
,336935.65,390170.10,56.96
,336938.20,390698.30,61.90
,336938.50,390372.35,59.70
,336940.20,390624.60,62.05
,336941.90,390654.00,61.60
,336948.10,390527.00,61.30
,336950.00,390562.10,61.00
,336955.90,390518.75,60.70
Any help would be greatly appreciated as I have hit a wall with it.
Cheers
Shaun
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
[edited by - The_eskimo on May 3, 2004 9:20:34 AM]
It's very easy:
--
You're Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..
[edited by - Pipo DeClown on May 3, 2004 7:45:33 AM]
"xvalue", "yvalue", "zvalue" // Coordinates
| | |
V V V
, 336415.50, 390170.75, 60.78 // First vertex
, 336210.30, 390373.05, 53.03 // Second vertex
, 336280.20, 390472.90, 58.20 // Third vertex
--
You're Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..
[edited by - Pipo DeClown on May 3, 2004 7:45:33 AM]
No. It''s not that easy, you will have to sort all data in rows and maybe columns as this data is not stored in the correct order to create a heightmap out of it (for a heightmap you will need rows/columns or any other logical order and i don''t see one in this data).
WWW.TREEPENGUIN.TK
WWW.TREEPENGUIN.TK
I just had a go at parsing it and plotting the data in maple, and got the following result: http://www.ch1pz.net/pics/blah.jpg
It appears that there is no actual grid pattern to use. I guess there are some algorithms that might be able to join the nearest vertices together in some meaningful way, or perhaps you could write something to make a bitmap heightfield out of it?
[edited by - ch1pz on May 3, 2004 8:36:25 AM]
It appears that there is no actual grid pattern to use. I guess there are some algorithms that might be able to join the nearest vertices together in some meaningful way, or perhaps you could write something to make a bitmap heightfield out of it?
[edited by - ch1pz on May 3, 2004 8:36:25 AM]
I've just edited the data in the original post and put it into some order.
does this help any?
Also - What's maple?
[edited by - The_eskimo on May 3, 2004 9:23:06 AM]
does this help any?
Also - What's maple?
[edited by - The_eskimo on May 3, 2004 9:23:06 AM]
Maple is just a general mathematics program, I used it to quickly plot the data without having to make a program to draw it.
I dont think you can reorder the data to get anything better. If you look at the image I posted up there, you can see gaps of varying size between the vertices, meaning they arent defined on a grid in columns or rows. As I said before, you may be able to get something useful out of this by some method, such as connecting nearby vertices together into individual triangles, but I dont know any specific algorithms that might help, perhaps someone else knows?
I dont think you can reorder the data to get anything better. If you look at the image I posted up there, you can see gaps of varying size between the vertices, meaning they arent defined on a grid in columns or rows. As I said before, you may be able to get something useful out of this by some method, such as connecting nearby vertices together into individual triangles, but I dont know any specific algorithms that might help, perhaps someone else knows?
Cool that sounds cool. Any ideas how to create the mesh. I''m assuming that will look like a TIN?
Try parsing through the data to find the max x, z and min x,z.
Determine the difference between xmax and xmin (xdiff) and zmax and zmin (zdiff). Offset the entire set by the min x,z to create an x,z of 0,0 to xdiff,zdiff. Create a regular grid from 0,0 to xdiff,zdiff. Plot your points. Note, in order for this to work you will have to round all of the x,z values to ints to correspond to a point in the heightmap. If you cannot do that then this solution will not work for you.
Determine the difference between xmax and xmin (xdiff) and zmax and zmin (zdiff). Offset the entire set by the min x,z to create an x,z of 0,0 to xdiff,zdiff. Create a regular grid from 0,0 to xdiff,zdiff. Plot your points. Note, in order for this to work you will have to round all of the x,z values to ints to correspond to a point in the heightmap. If you cannot do that then this solution will not work for you.
Your right - i need to maintain some form of accuracy, so I can''t round up the values. Someone mentioned to me about interpolating them to a grid, but I have no idea how to do that.
Any ideas?
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
Any ideas?
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
grid position: 200, 200, y
data positions: (closest points to the grid position)
D1: 150, 100, 100
D2: 300, 120, 130
D3: 120, 250, 80
D4: 270, 290, 200
'
dX dZ Y
DeltaD1: -50, -100, 100 (150-200, 100-200, 100)
DeltaD2: 100, -80, 130 (300-200, 120-200, 130)
DeltaD3: -80, 50, 80 (120-200, 250-200, 80)
DeltaD4: 70, 90, 200 (270-290, 290-200, 200)
'
// weighted linear interpolation along first x axis
X1y = (100*100 + 130*50) / (50+100) // 110
X1z = (100*100 + 120*50) / (50+100) // 106.667
'
// weighted linear interpolation along second x axis
X2y = (80*70 + 200*80) / (80+70) // 144
X2z = (250*70 + 290*80) / (80+70) // 271.333
'
// weighted linear interpolation along first z axis
Z1y = (100*50 + 80*100) / (100+50) // 86.667
Z1x = (150*50 + 120*100) / (100+50) // 130
'
// weighted linear interpolation along second z axis
Z2y = (130*90 + 200*80) / (80+90) // 162.941
Z2x = (300*90 + 270*80) / (80+90) // 285.882
'
DX1z = 200-X1z // 93,333
DX2z = X2z-200 // 71.333 -- Delta must be positive!
DZ1x = 200-Z1x // 70
DZ2x = Z2x-200 // 85.882
'
PX = (DX1z*X2y + DX2z*X1y) / (DX1z+DX2z) // 129.271
PZ = (DZ1x*Z2y + DZ2z*Z1y) / (DZ1x+DZ2x) // 120.918
y = PX + PZ / 2 // 125.095
'
Grid: 200, 200, 125.095
'
'
' *(150,100)
' *(300,120)
'
'
' +(200,200)
'
' *(120,250)
' *(270,290)
'--------------------------
' *
' ^(200,106*
' |
'(130,200)|
' ^----+-------^(286,200)
' |
' * ^(200,271)
' *
note: the positions are mockups, not from the listing.
EDIT: Noticed some errors + improved the pseudocode
EDIT2: Hmm the CODE tag appearantly don't like blank lines...
EDIT3: did the math + tested it. It works
[edited by - frostburn on May 3, 2004 3:14:21 PM]
[edited by - frostburn on May 3, 2004 3:33:29 PM]
Wow - thankyou for your help it is very much apppreciated. Forgive my ignorance, I just want to get it clear in my head. The psuedocode describes how to interpolate a point onto a grid.
How is the interpolation done? using what method? I am really sorry if i sound stupid - its just that i''m very knew at this.
Cheers
How is the interpolation done? using what method? I am really sorry if i sound stupid - its just that i''m very knew at this.
Cheers
I simply interpolated each "line" in the original square:
You basically take n% of the first value and 100-n% of the second value..
I do this with each of the lines to get the new coordinates for the correct point between the points.
In my previous post I wanted to find Y in (200,200).
I find (200, Z, Y) on each of the horizonal lines and (X, 200, Y) on the vertical lines.
I then do the same to find (200,200, Y) for *both* the horizontal and vertical axes (a vertical line for the horizontal line and a horizontal line for the vertical line).
These two lines crosses at (200,200) but the Y is probably different for them, so I also need to find the mean between them (Y1 + Y2)/2
I don''t know what it''s called.. I haven''t studied math very much and for all I know I may be the first to do it this way (though that is highly unlikely). I haven''t seen or read it anywhere but I put it together myself from bits and pieces I''ve seen around. It can probably be optimized some, and I don''t know exactly how to autmatically get the deltas to be positive...
Sorry I can''t explain it better.. Perhaps someone else can try..
x: 0 75 100
*----------------+-----*
y: 50 H 130
H = (50*25 + 130*75) / (25+75)
H = 25% of 50 + 75% of 130
H(50) = (50 + 130) / 2
This works for any values of x and y..
X could start 523.233 and end at 781.64 and solve H at 600.
H(600) = ((600-523.233)*50 + (781.64-600)*130) / (781.64-523.233)
You basically take n% of the first value and 100-n% of the second value..
I do this with each of the lines to get the new coordinates for the correct point between the points.
In my previous post I wanted to find Y in (200,200).
I find (200, Z, Y) on each of the horizonal lines and (X, 200, Y) on the vertical lines.
I then do the same to find (200,200, Y) for *both* the horizontal and vertical axes (a vertical line for the horizontal line and a horizontal line for the vertical line).
These two lines crosses at (200,200) but the Y is probably different for them, so I also need to find the mean between them (Y1 + Y2)/2
To make it more logic in 2d drawing is X horizontal, Y vertical and Z height..
Point: (XYZ)
Points: A , B, C, D, E, F, G, H, I <- A, B, C, D are known at start.
Lines: AB, CD, AC, BD, EF, GH
(0,0) (500,0) Z is not listed
A------E----------------B
| | |
| | |
G------I----------------H
| |(200,200) |
| | |
| | |
| | |
| | |
C------F----------------D
(0,500) (500,500)
E = AB(X=200) <- Find the (XYZ) point at position X=200 in the line.
F = CD(X=200)
G = AC(Y=200)
H = BD(Y=200)
I = ( GH(X=200) + EF(Y=200) ) / 2 <- GH(200) and EF(200) doesn''t neccesarrily have the same value for Y)
I don''t know what it''s called.. I haven''t studied math very much and for all I know I may be the first to do it this way (though that is highly unlikely). I haven''t seen or read it anywhere but I put it together myself from bits and pieces I''ve seen around. It can probably be optimized some, and I don''t know exactly how to autmatically get the deltas to be positive...
Sorry I can''t explain it better.. Perhaps someone else can try..
I think I understand what you mean. I have absoloutley no idea how to go about programming it though.
Any Ideas anyone?
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
Any Ideas anyone?
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
Hey!
The thing you need is called "scattered data interpolation".
There are some methods around, one is for example:
1) Compute the "Delaunay triangulation" of (X,Y). The result is a triangulation of the convex hull of all points (X(i),Y(i)). Then interpolate inside the triangles.
2) Interpolation using basis functions.
Anyway, there is a software tool called MATLAB (similar to MAPLE) which can do this for you. I've written a program doing this. It is as short as:
Then xh,yh contains a uniformly spaced vector of the x and y values and ZH are the corresponding height values, i.e.
(x(i), y(j), ZH(i,j)) is a point on the surface.
If you plot it, it looks like this.
You can download a 128x128 grid of this heightmap here.
Just tell me if you need another resolution. (The result won't be better or finer though).
Lutz
EDIT: Some formatting
[edited by - Lutz on May 4, 2004 6:52:33 AM]
The thing you need is called "scattered data interpolation".
There are some methods around, one is for example:
1) Compute the "Delaunay triangulation" of (X,Y). The result is a triangulation of the convex hull of all points (X(i),Y(i)). Then interpolate inside the triangles.
2) Interpolation using basis functions.
Anyway, there is a software tool called MATLAB (similar to MAPLE) which can do this for you. I've written a program doing this. It is as short as:
p=[336020.85,390863.55,53.00,336030.55,390448.55,48.20,... all the points];
X=p(1:3:end); Y=p(2:3:end); Z=p(3:3:end);
N = 128;
xh = linspace(min(X),max(X),N);
yh = linspace(min(Y),max(Y),N);
[XH,YH] = meshgrid(xh,yh);
ZH = griddata(X,Y,Z,XH,YH,'v4');
Then xh,yh contains a uniformly spaced vector of the x and y values and ZH are the corresponding height values, i.e.
(x(i), y(j), ZH(i,j)) is a point on the surface.
If you plot it, it looks like this.
You can download a 128x128 grid of this heightmap here.
Just tell me if you need another resolution. (The result won't be better or finer though).
Lutz
EDIT: Some formatting
[edited by - Lutz on May 4, 2004 6:52:33 AM]
That is awesome, i am proper impressed! Thankyou.
Again, forgive my ignorance as this is a somewhat of a learning curve for me.
The program written, how does it work? Is it written in C++?
Also does anyone know a program I plug that data into to create the height map and then layer a jpeg over it?
Cheers
Everyones help is very much appreciated. If any of you are ever in Liverpool I will buy you a pint. :D
By the way my email is fanduchi@hotmail.com
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
[edited by - The_eskimo on May 4, 2004 7:20:43 AM]
Again, forgive my ignorance as this is a somewhat of a learning curve for me.
The program written, how does it work? Is it written in C++?
Also does anyone know a program I plug that data into to create the height map and then layer a jpeg over it?
Cheers
Everyones help is very much appreciated. If any of you are ever in Liverpool I will buy you a pint. :D
By the way my email is fanduchi@hotmail.com
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
[edited by - The_eskimo on May 4, 2004 7:20:43 AM]
The program above is written in MATLAB - an interpreted programming language. In order to run it, you need the MATLAB package (see the MathWorks homepage). There are student licenses available for I guess around 80 Dollars (the maximum size of vectors and matrices and the availability of toolboxes is limited).
MATLAB itself is quite slow, but it makes vector maths very easy, e.g. solving the linear system of equations Ax=b just reads x=A\b in MATLAB. Also, there are very useful routines like the griddata function I used above to interpolate the unstructured data on a uniform grid.
Btw. I don''t work for MathWorks...
> If any of you are ever in Liverpool I will buy you a pint. :D
I''ll come back to that!
MATLAB itself is quite slow, but it makes vector maths very easy, e.g. solving the linear system of equations Ax=b just reads x=A\b in MATLAB. Also, there are very useful routines like the griddata function I used above to interpolate the unstructured data on a uniform grid.
Btw. I don''t work for MathWorks...
> If any of you are ever in Liverpool I will buy you a pint. :D
I''ll come back to that!
Cheers geezer - your help is greatly appreciated.
Ok - I''m afraid there is another question. Is there a way of altering the height map in lesson 34 to read in the data contained in the grid format as opposed to reading in a .RAW file?
I have no idea if this is possible hopefully somebody can help. At a risk of repeating myself - all your help has been and is very much appreciated.
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
Ok - I''m afraid there is another question. Is there a way of altering the height map in lesson 34 to read in the data contained in the grid format as opposed to reading in a .RAW file?
I have no idea if this is possible hopefully somebody can help. At a risk of repeating myself - all your help has been and is very much appreciated.
"Although not everone can be my colleague, all of you are now my friend!" (Shooter McGavin, Happy Gilmore)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement