Learn R Programming

windfarmGA (version 2.3.0)

isSpatial: Transform to SpatialPolygons

Description

Helper Function, which transforms SimpleFeatures or coordinates in matrix/data.frame/data.table into a SpatialPolygon

Usage

isSpatial(shape, proj)

Arguments

shape

An area as SpatialPolygon, SimpleFeature Polygon or coordinates as matrix/data.frame

proj

Which Projection should be assigned to matrix / data.frame coordinates

Value

A SpatialPolygons object

Details

If the columns are named, it will look for common abbreviation to match x/y or long/lat columns. If the columns are not named, the first 2 numeric columns are taken.

See Also

Other Helper Functions: dup_coords(), getDEM(), getISO3(), get_grids(), grid_area(), hexa_area(), permutations(), readintegerSel(), readinteger(), splitAt(), tess2SPdf(), windata_format()

Examples

Run this code
# NOT RUN {
library(sp)
df <- rbind(c(4498482, 2668272), c(4498482, 2669343),
            c(4499991, 2669343), c(4499991, 2668272))
isSpatial(df)

Polygon1 <- Polygon(rbind(c(4498482, 2668272), c(4498482, 2669343),
                          c(4499991, 2669343), c(4499991, 2668272)))
Polygon1 <- Polygons(list(Polygon1), 1);
Polygon1 <- SpatialPolygons(list(Polygon1))
Projection <- "+init=epsg:3035"
proj4string(Polygon1) <- CRS(Projection)
df_fort <- ggplot2::fortify(Polygon1)
isSpatial(df_fort, Projection)
# }

Run the code above in your browser using DataLab