Jump to content
rossoe

Transform road Shapefiles in QGIS

Recommended Posts

I wonder if someone could help me figure out how to get a Shapefile converted - as I'd love to start working on roads on my terrain.

 

I've been following:

http://pmc.editing.wiki/doku.php?id=arma3:terrain:road-shapefiles-real-world-data

and also:

http://pmc.editing.wiki/doku.php?id=arma3:terrain:qgis-reproject-transform-tutorial

 

and I'm constantly getting stumped at the v.transform stage in QGIS.

 

I know the shapefile produced during the Global Mapper stage of the tutorial works ok as I tested throwing it in TB:

Capture1.JPG

 

But of course I have to carry out the transform step so that it matches up with the mapframe. (I'm using v18 of GM so following the QGIS steps)

 

I load into QGIS my heightmap asc exported from TB which has mapframe properties:

xllcorner     200000.000000
yllcorner     0.000000

 

Capture2.JPG

 

Then load my Shapefile

 

Capture3.JPG

 

I apply WGS 84 / UTM Zone 31N to both layers

 

I know the coordinates from an asc header exported from Global mapper  with user created features grid are:

xllcorner     174068.079

yllcorner     15603007.959

 

which near enough matches up with above image (pointer was not in exact spot)

 

So I assume the goal is to bring above figures back to - 'easting 200000 and northing 0'

 

So I calculated to return the coordinates to those of arma3 terrain builder I need -

X:  +25931.921

Y:  -15603007.959

 

Using v.transform I input above figures:

Capture4.JPG

 

I don't do any scale changes as I assume I don' t need it.

 

I click Run & then zoom to new Transformed layer - and this is where I get confused - as I think it's supposed to then line up with my heightmap layer in the view but's it's not -see below

 

Capture5.JPG

 

The coordinates don't seem to have changed at all? In fact even though I am zooming to the new Transformed layer the view is still actually sitting on iowroad3. it's like the new layer has nothing in it.

 

If I save off the new Transformed layer - it's just 1kb shp file - so does not look like it holds anything?

 

Am I doing something stupid with my transform calculations? or using the wrong asc?

 

it's not clear from tutorials which heightmap asc you should be loading into QGIS, one mentions the asc exported from TB, the other notes grabbing the one from Global Mapper. they both have completely different header coordinates!

Share this post


Link to post
Share on other sites

Hey rossoe, I hope I can help you with this:

 

For this same operation, I use a different plugin available within QGIS's plugins called 'Affine transformation'

 

I know this plugin works from my own experience for this type of objective.

 

First, make sure your line shapefile is editable, then you open up the Affine transformation tool and select that layer.  Using the matrix (with explanation here: https://gis.stackexchange.com/questions/136817/qgis-moving-the-layer-all-features-using-vector-affine-transformation) you will only need to edit the to x' = 0 + 25931.921 and y' = 0 + -15603007.959 parameters to get your desired transformation.  Seems like the v.transform should work this same way, but I have not used it.

Share this post


Link to post
Share on other sites

Genius thank you - i love these forums!

 

All working in TB perfectly now:

Capture6.JPG

 

i actually had to put my figures in the following spots:

Capture7.JPG

 

The page you mentioned shows the mappings for these:

https://gis.stackexchange.com/questions/136817/qgis-moving-the-layer-all-features-using-vector-affine-transformation

 

I'm not sure why the v.transform did not work - but this Affine one is great! 

  • Like 1

Share this post


Link to post
Share on other sites

Hey Rossoe,

Were you able to import the resulting shapefile into Terrain Builder? I'm successful in doing everything in QGIS but on import, things get seriously broken (like, roads become a star).

 

Can you expand on "I apply WGS 84 / UTM Zone 31N to both layers"? It'd be of serious help...

Share this post


Link to post
Share on other sites

Better late than never!  sorry SCAR didn't spot your query.

 

Re the CRS - see below steps I only changed the road shapefile CRS, as my heightmap was already on UTM zone 31N (coming from Terrain Builder).

 

Also in this instance both my road shapefile and heightmap were originally exported from a Global Mapper project to the exact size required for a terrain in Terrain Builder. This made it easier to check original easting & northing coords before they are switched to 200 000, 0  which Terrain Builder requires.

 

 

Steps I took using Affine Transformation tool in QGIS 2.18 -

 

Load in currently used heightmap (asc) from your Terrain Builder project:

 

hm.png

 

When skirting the mouse near the bottom left corner, figures should be close to - 200 000 easting and 0 northing coords.

 

And if it's from Terrain Builder it should be CRS - 'UTM zone 31N'

 

CRS1.png

 

Now add in road your road shapefile

 

Depending on the source of shapefile, It'll possibly be on different CRS to your heightmap:

 

Right click the road layer - 'Set Layer CRS'

 

CRS2.png

 

Switch it to match Heightmap - 'UTM zone 31N'

 

roads.png

 

The shapefiles original easting & northing coords (exported from Global Mapper) would have been:

xllcorner     174068.079

yllcorner     15603007.959

 

Which lines up with a rough check above on the bottom left of the road shapefile

 

We still need to get it to 200000, 0  so that the roads line up over the heightmap.

 

So if I do the calculation for xllcorner - “200000 - 174068.079” equals  25931.921 value.

And for yllcorner we need to get it to 0 so  will simply use  -15603007.959

 

Enter the above figures into Affine Transformation tool -

 

Affine.png

 

Which brings the road shapefile back in line with the figures you want  200 000, 0  ready to use in Terrain Builder

 

mhandroad.png

 

I'll soon detail the steps to do everything in QGIS rather than jumping between Global Mapper and QGIS like above.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×