## General Polygon Clipper Library for R (version 1.5-5)
## Type 'class ? gpc.poly' for help
## Loading required package: sp
##
## Attaching package: 'rgl'
##
## Das folgende Objekt ist maskiert 'package:gpclib':
##
## triangulate
##
## rgdal: version: 1.1-1, (SVN revision 572)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 1.7.3, released 2010/11/10
## Path to GDAL shared files: /usr/share/gdal/1.7
## GDAL does not use iconv for recoding strings.
## Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
## Path to PROJ.4 shared files: (autodetected)
## Linking to sp version: 1.2-1
setwd("/media/Samsung M2/gisday/")
source("geo3d.R")
# load data
dem <- raster("data/pdm_dem.tif")
dem
## class : RasterLayer
## dimensions : 53, 56, 2968 (nrow, ncol, ncell)
## resolution : 0.0002777778, 0.0002777778 (x, y)
## extent : 13.05819, 13.07375, 52.37847, 52.39319 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
## data source : /media/Samsung M2/gisday/data/pdm_dem.tif
## names : pdm_dem
## values : -32768, 32767 (min, max)
# 2d plot
plot(dem)
# 3d plot with texture
dem3d(dem, sf=5, texture = T, tmp_texture = "textures/pdm_tele_16.png")
# Decoration
light3d()
bg3d(col="lightgrey")
decorate3d(xlab = "long", ylab="lat", zlab="Höhe")
# creat a matrix with some coordinates
xy <- matrix(c(13.066667,52.391667,13.0648208,52.3822418),
ncol = 2, byrow = T)
xy
## [,1] [,2]
## [1,] 13.06667 52.39167
## [2,] 13.06482 52.38224
# adding text
text3d(xy[,1], xy[,2],
dem[cellFromXY(dem, xy)]+20,
c("Hauptbahnhof","GISday"),
cex=3, col=c("darkred","steelblue"), useFreeType=T)
text3d(xy[,1], xy[,2],
dem[cellFromXY(dem, xy)]+5,
"*",
cex=3, col=c("darkred","steelblue"), useFreeType=T)
# adding a line from a shape-file
weg <- readOGR("data/weg.shp","weg")
## OGR data source with driver: ESRI Shapefile
## Source: "data/weg.shp", layer: "weg"
## with 1 features
## It has 1 fields
xy <- weg@lines[[1]]@Lines[[1]]@coords
lines3d(xy[,1],xy[,2],dem[cellFromXY(dem, xy)]+1, col="lightgrey",lwd=5)
You must enable Javascript to view this page properly.