0

I'm following this tutorial: https://grasswiki.osgeo.org/wiki/Extrude_2D_polygons_to_3D.

This is what I've done so far (inside GRASS):

- Import a DEM HGT file:

> r.in.srtm input=S23W043.hgt --overwrite

- Edit osm_config.ini to include `height` as column. 
- export OSM_CONFIG_FILE=/path/to/osm_config.ini
- Took an OSM file of a small region from https://www.openstreetmap.org/export
- Import the OSM data: 

 > v.in.ogr input=map.osm layer=multipolygons output=riodejaneiro2D where="building is not null and height is not null" --overwrite

- Adjust the region:

 > g.region vect=riodejaneiro2D

- Create a new column and copy data using cast because the height column is type=string:

 > v.db.addcolumn riodejaneiro2D col="altura integer"
 > v.db.update riodejaneiro2D col=altura qcol="CAST(height AS double precision)"

 - Extrude using the new column "altura" as parameter and the DEM raster as elevation:

 > v.extrude riodejaneiro2D out=riodejaneiro3D height_column=altura --overwrite elevation=S23W043 layer=multipolygons

 - Export as KML:

 > v.out.ogr input=riodejaneiro3D type=face output=riodejaneiro3D.kml format=KML --overwrite

In Google Earth I can see the KML features but all of them are flat. The same if I export as SHP file. This is what I have:

v.info riodejaneiro3D
 +----------------------------------------------------------------------------+
 | Name:            riodejaneiro3D                                            |
 | Mapset:          PERMANENT                                                 |
 | Location:        magno01                                                   |
 | Database:        /home/magno/grass                                         |
 | Title:                                                                     |
 | Map scale:       1:1                                                       |
 | Name of creator: root                                                      |
 | Organization:                                                              |
 | Source date:     Thu Jun 13 23:30:26 2019                                  |
 | Timestamp (first layer): none                                              |
 |----------------------------------------------------------------------------|
 | Map format:      native                                                    |
 |----------------------------------------------------------------------------|
 |   Type of map: vector (level: 2)                                           |
 |                                                                            |
 |   Number of points:       0               Number of centroids:  0          |
 |   Number of lines:        0               Number of boundaries: 0          |
 |   Number of areas:        0               Number of islands:    0          |
 |   Number of faces:        813248          Number of kernels:    93192      |
 |   Number of volumes:      0               Number of holes:      0          |
 |                                                                            |
 |   Map is 3D:              Yes                                              |
 |   Number of dblinks:      1                                                |
 |                                                                            |
 |   Projection: Latitude-Longitude                                           |
 |                                                                            |
 |               N:   22:34:48.89316S    S:   23:03:11.51244S                 |
 |               E:   42:55:12.02052W    W:   43:34:47.97084W                 |
 |               B:                 0    T:                 0                 |
 |                                                                            |
 |   Digitization threshold: 0                                                |
 |   Comment:                                                                 |
 |     Generated by v.extrude from vector map <riodejaneiro2DCT@PERMANENT>    |
 +----------------------------------------------------------------------------+

But... when I force a height using

v.extrude riodejaneiro2DCT out=riodejaneiro3D height=20 --overwrite

I can see the 3D features in Google Earth and the info changes to :

 |   Map is 3D:              Yes                                              |
 |   Number of dblinks:      1                                                |
 |                                                                            |
 |   Projection: Latitude-Longitude                                           |
 |                                                                            |
 |               N:   22:34:48.89316S    S:   23:03:11.51244S                 |
 |               E:   42:55:12.02052W    W:   43:34:47.97084W                 |
 |               B:                 0    T:                20                 |
 |                                                                            |

Attention to the T: 20.

What I doing wrong to use one of the vector attributes as height to extrude it?

2

Got it!

My mistake was in the new attribute field conversion. Must change

v.db.addcolumn riodejaneiro2D col="altura integer"

to

v.db.addcolumn riodejaneiro2D col="altura double precision"

Now I have

 |   Map is 3D:              Yes                                              |
 |   Number of dblinks:      1                                                |
 |                                                                            |
 |   Projection: Latitude-Longitude                                           |
 |                                                                            |
 |               N:    22:53:35.3346S    S:   22:54:35.98344S                 |
 |               E:   43:10:29.50788W    W:   43:11:57.81624W                 |
 |               B:                 0    T:               143                 |
 |                                                                            |
 |   Digitization threshold: 0                                                |
 |   Comment:                                                                 |

enter image description here

and if you want to use my question/answer as a tutorial, you can fix the Skipping area XXX without centroid using:

v.centroids input=riodejaneiro2D output=riodejaneiro2DCT

and use riodejaneiro2DCT as the vector to extrude.

  • 1
    Looks cool! Please consider to accept your answer :) – markusN Jun 17 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.