How to convert a png heightmap to drapeable vector lines

I got a png with a heightmap in the form of pixelated lines. I’m wondering if there’s any way to convert my png to vector lines which I can then import to my Sketchup model. I want to drape the lines on top of an image, so that I can later adjust the heights of the faces created.

Unfortunately, the heightmap data from the integrated geo-location isn’t good enough, and neither is the satellite photo, so some manual work is required - but doing all the tracing by hand will just take forever.

How was the image of the lines created? Is it possible to go back to the source and get a vector file? There are applications out there that can trace edges in an image and create a vector output. My experience with them has shown minimal success but it greatly depends on the image.

If the image is really a heightmap (just various shades of gray representing different elevations) there is an extension that will generate geometry from a bitmap image.

1 Like

I got the png from a communal map service, where you can toggle different layers on or off (adresses, heightlines, sewage lines, etc… It’s a good service, but the answer is no: it’s not really a heightmap (sorry for the confusion), it’s just lines… And the only extractable formats (at least from the version that’s available to the public) are pixelated pdf and png.

I guess I could possibly get another better version from somewhere. thinking…

If you can’t get a vector format file, do a search for ‘raster to vector’ and see if you can find something that will give you an adequate DXF or other file. There are some online tools for this that will turn up in the search.

That’s a pretty rough image, though, so I wouldn’t have a lot of confidence you’ll get a decent vector file from it.

1 Like

Communal map services generally can sell you a dwg or dxf map for a modest fee. Their websites usually give you only raster data. If, as your name indicates, you are from a Nordic country, most of the area has been laserscanned from the air, and the data can be had for free from the national survey, but you have to figure out yourself how to process it.

1 Like

@DaveR: Yupp, you were right about the rough image. For most parts it works “ok”, but areas with lines closer together become a total mess.

@Anssi: Nordic indeed. I’ve looked at kartverket.no, norgeskart.no and hoydedata.no. It seems the sky’s the limit: all sorts of downloads are provided. However … as you said “you have to figure out yourself how to process it”. Any Dunning–Kruger effect I initially might have had is vanishing by an alarming rate as I read about the various heightmap formats :rofl:

1 Like

Where is the area/scope of work in the real world you are working on for these lines? As @DaveR mentioned, you can use a heightmap to get really high quality terrain in SketchUp. Then use an extension to create contour lines. There’s no way to guarantee that they’d be exactly the same as what you’re showing in your raster image so it all depends on your level of accuracy needed. If it needs to be exactly as your image shows then tracing CAD (not fun I know!) may be your best route.

1 Like

This is the place: Google Maps
It’s just a personal project, so the accuracy isn’t really that important, but it just looked a bit weird using the built-in “get geolocation” feature. Just need to give the viewer a general gist of the terrain.

In the end, I went ahead and drew/traced each line manually. Thanks for all the help and advice! :slight_smile:

1 Like

in illustrator (if you have it) you can run a trace using the “technical drawing” mode which creates a single line through the traced lines. I got this and saved it as a DWG:

Once in sketchup I ran “edge tools” close all gaps with a 4" tolerance ( for scale I had) and it filled the small gaps.

there was some cleanup of stray edges, so not sure if the cleanup part is harder than the retracing? but its an option.

1 Like

I think some plugins from Thomthom can help with this process…

1 Like

To followup from yesterday’s post. The method I recommended is not worth it for smaller areas. Just big sites. So probably not useful in this case but here it is anyway:

Import height map using Bitmap to Mesh extension. I get my heightmaps from a photoshop plugin I bought called Terrain Generator. There may be other free sources out there but this one is easy so worth some expense.

Here it is without height map image texture.

Google maps image so I know where things are on the terrain mesh.

Used geo-locate function to get existing terrain from Digital Globe to match terrain height. When you import from Bitmap to Mesh it doesn’t know what the Z Value should be so you set it manually upon import…then adjust to match Location Terrain.

Ran Tig’s Contour Maker extensions. Took a long time to process on such a big site. I should have used something smaller for this demo. Live and learn.

Contours without the mesh.

Lastly, here is detailed view. A bit choppy so again, works better from a distance.

Dropbox - File Deleted here’s the file if you want to play around with it.

2 Likes

A lot of interesting topics and alternatives here! Thanks again everyone :slight_smile:

As I mentioned yesterday, I ended up drawing a simplified layout of 1m contours, as I thought this would be the easiest way after all.

Initially I created stepped layout (which is “ok”, but does of course look a bit rough and clearly shows everyone that I’m an amateur :laughing:):

Today I thought I could take it one step further and use “Draw>Sandbox>From contours” to get a more even layout. I cleaned up my lines. All lines are placed at 0, 1, 2, 3 meters etc.

However… when I try to create a sandbox … for some strange reason SketchUp chooses to randomly skip certain steps. I would think SketchUp would look for the next and closest line, but some places it skips several levels/meters, and just creates a big mess.

Did I miss something obvious here, or is this normal?

Pretty sure there must be an easier way, but here’s the final result. Ended up drawing the polygons in manually, then softening edges and projecting the satellite photo on top. Learned a lot in the process though, and quickly realised that getting SketchUp to automatically “just connect the dots” isn’t as easy as it sounds.

2 Likes

Looks good. Sometimes doing it the ‘hard’ way is the best way to learn.

looks good. Maybe you can share the full contour file you have to see if there’s any better ways to realize it?

@whiterabbitdesigncompany: sorry for the late response. I didn’t really have a contour file, just a png image. Anyways, I’ve added the png below, and here’s a link to download the full model file if you want to: https://hmstjenesten-my.sharepoint.com/:u:/g/personal/tormod_hms-tjenesten_no/EeQsJ_olYX1BgSb4_H6goLsBzgLS1vCOPR56JvtC9Sts5Q?e=XhKKW2

A new question popped up here: I made a few changes to my satellite photo texture, to showcase proposed changes. However, when I try to update (import again) the new image file, it doesn’t transfer correctly to my modelled terrain. I’m presuming this is caused by running smooth edges or something, but fail to understand why. For 95 % of the model it works just fine.

See pic below. Anyone know why this is happening?

The png with heigh curves:

The new texture should transfer, I’m not sure why this happens, may be a UV mapping issue, however, as you can see from my gif, if i sample the main texture and try to apply it to the wrongly mapped sections it doesn’t paint? but if you sample the texture in an adjacent section it will paste/paint. As you can see, moving to another area, the same issue, but by sampling from an adjacent section again it will work. Luckily this isn’t in too many places so your cleanup will be easy. If it were more wide spread it might be easier to re-project the whole texture. It might be easier to do this operation by unsmoothing or you will have to have hidden geometry turned on to sample the individual faces.

1 Like

Nice, thanks for the tip! Something’s really wrong with the terrain though. I 'm no longer able to toggle receive shadows on.