Movatterモバイル変換


[0]ホーム

URL:


Title:Simple Geographical Operations (with OSGB36)
Version:0.9.2
URL:https://github.com/clozanoruiz/sgo
BugReports:https://github.com/clozanoruiz/sgo/issues
Language:en-GB
Description:Methods focused in performing the OSGB36/ETRS89 transformation (Great Britain and the Isle of Man only) by using the Ordnance Survey's OSTN15/OSGM15 transformation model. Calculation of distances and areas from sets of points defined in any of the supported Coordinated Systems is also available.
Depends:R (≥ 3.5.0)
Suggests:maps, tinytest
License:BSD_2_clause + file LICENSE
Copyright:OSTN transformation data included in this module remainsCrown Copyright (C) 2016 under the terms of the BSD licence:(c) Copyright and database rights Ordnance Survey Limited 2016,(c) Crown copyright and database rights Land & PropertyServices 2016 and/or (c) Ordnance Survey Ireland, 2016. Allrights reserved.
Encoding:UTF-8
ByteCompile:yes
RoxygenNote:7.2.1
Collate:'sgo.R' 'sgo_area.R' 'sgo_bng.R' 'sgo_distance.R' 'sgo_laea.R''sgo_ngr.R' 'sgo_points.R' 'sgo_set_gcs.R' 'sgo_wgs84.R''sgo_transform.R'
NeedsCompilation:no
Packaged:2022-09-23 15:55:32 UTC; Carlos
Author:Carlos Lozano Ruiz [aut, cre]
Maintainer:Carlos Lozano Ruiz <carloslozanoruiz@outlook.com>
Repository:CRAN
Date/Publication:2022-09-23 16:20:02 UTC

sgo: Simple Geographical Operations (with OSGB36).

Description

The sgo package aims to help with spatial or geographic analysis in OpenSource R and derivatives. Its main purpose is to perform OSGB36/ETRS89transformations using the Ordnance Survey's OSTN15 transformation model forGreat Britain and the Isle of Man. It also transforms GPS ellipsoid heightsto orthometric (mean sea level) heights on the relevant Ordnance Surveymapping datum, using the National Geoid Model OSGM15.

Details

Most of the functions available in this package will become much lessaccurate if used outside the coverage of OSTN, therefore it is advised toapply these functions on coordinates within Great Britain, the Isle of Manand any areas of sea less than a few miles off shore.

This package assumes that the Coordinate Reference Systems (CRS) ETRS89 andWGS84 are practically the same within the UK, but this shouldn't be aproblem for most civilian use of GPS satellites. If a high-precisiontransformation between WGS84 and ETRS89 is required then it is recommendedto use a different package to do the conversion.

Object constructors

Transformation and Conversion functions

Functions to provide coordinate transformations:

Geometric measurements

Disclaimer

The OSTN15 transformation model is used in this package, and it is licensedunder the BSD Licence (http://opensource.org/licenses/bsd-license.php):
© Copyright and database rights Ordnance Survey Limited 2016, © Crowncopyright and database rights Land & Property Services 2016 and/or ©Ordnance Survey Ireland, 2016. All rights reserved.


Calculate area from an ordered set of points

Description

Calculates the planar area for a set of points defined in the OS BNG orETRS89-LAEA. An accurate approximation of the geodetic area is calculatedwhen points are expressed in angular coordinates.

Usage

sgo_area(x, interpolate = NULL, ...)

Arguments

x

Asgo_points object describing an ordered set of points.

interpolate

Numeric variable. If notNULL, defines the maximumdistance in metres between adjacent coordinates. It is only used withangular coordinates.

...

Currently ignored

Details

Calculate areas using the Gauss's area formula(https://en.wikipedia.org/wiki/Shoelace_formula).

When using angular coordinates the function performs an approximation of thegeodetic area following the methodology discussed in Berk & Ferlan (2018)where the area on the ellipsoid is determined by using a region-adaptedequal-area projection (Albers Equal-Area Conic) with one standard parallel.The standard parallel and the projection origin are tied to the momentcentroid of the polygon.

Boundary segments can be divided by interpolating vertices on the projectedgeodesic to reduce the error introduced by boundary simplification and toprovide an even more accurate area computation for angular coordinates.For instance, ifinterpolate = 500 then any segment between adjacentcoordinates whose length is greater thaninterpolate will be split inparts no greater than500 m and new vertices will be added.

The area calculation in this package is best suited for features that wouldbe represented in a large or medium scale (like plots or council boundaries).It will provide much less accurate results for features usually representedat smalle scale (countries, continents, etc.).

Value

Value of the area in squared metres rounded up to the first decimal.

References

Sandi Berk & Miran Ferlan, 2018.Accurate area determination in thecadaster: case study of Slovenia. Cartography and Geographic InformationScience, 45:1, 1-17. DOI: 10.1080/15230406.2016.1217789

Snyder, J.P. 1987.Map Projections — A Working Manual. US GeologicalSurvey Professional Paper, no. 1395. Washington, DC: US Government PrintingOffice. DOI: 10.3133/pp1395

Examples

lon <- c(-6.43698696, -6.43166843, -6.42706831, -6.42102546,-6.42248238, -6.42639092, -6.42998435, -6.43321409)lat <- c(58.21740316, 58.21930597, 58.22014035, 58.22034112,58.21849188, 58.21853606, 58.21824033, 58.21748949)A <- sgo_area(sgo_points(list(lon, lat), epsg=4326))

British National Grid (BNG) Easting/Northing to Geodetic CoordinateSystem (GCS)

Description

Converts Ordnance Survey grid reference easting/northing coordinates to GCSlongitude/latitude (SW corner of grid square).

Usage

sgo_bng_lonlat(x, to = 4258, OSTN = TRUE, OD = FALSE)

Arguments

x

Asgo_points object with coordinates defined in the projectedcoordinate system BNG (EPSGs 27700 or 7405).

to

Numeric. Sets theepsg code of the destination GeodeticCoordinate System. 4258 (ETRS89) by default.

OSTN

Logical variable indicating whether use OSTN15 transformationwhen TRUE or a less accurate but slightly faster single Helmerttransformation when FALSE.

OD

Logical variable. When TRUE, and the output contains acolumn with heights, then a new column is added to the result indicating theordnance datum (OD) used on each point. It is ignored whenOSTN=FALSE.

Details

The UK Ordnance Survey defined 'OSGB36' as the datum for the UK, based on the'Airy 1830' ellipsoid. However, in 2014, they deprecated OSGB36 in favour ofETRS89 for longitude/latitude coordinates. Thus, when converting tolongitude/latitude the OSGB36 datum should be always converted to ETRS89(or WGS84).

According to the Transformations and OSGM15 User Guide, p. 8:"...ETRS89 is a precise version of the better known WGS84 referencesystem optimised for use in Europe; however, for most purposes it can beconsidered equivalent to WGS84." and"For all navigation, mapping,GIS, and engineering applications within the tectonically stable parts ofEurope (including UK and Ireland), the term ETRS89 should be taken assynonymous with WGS84." This means that ETRS89 and WGS84 datums will beconsidered equivalent by this routine.

If, for historical reasons, longitude/latitude coordinates must have the oldOSGB36 datum, then the parameterto must be set to 4277.

Note: Grid references rounded to whole metres will givelatitude/longitude that are accurate to about 5 decimal places: in GreatBritain, 1/100000 of a degree of latitude is about 70cm and 1/100000 of adegree of longitude is about 1m.All those coordinates outside the rectangle covered by OSTN15will be automatically computed using the small Helmert transformation. Suchcoordinates will be accurate up to about +/-5 metres.Converting from BNG to lon/lat coordinates is slower than the other wayaround, due to the iterative nature of the algorithm that is built intoOSTN15.

Value

An object of classsgo_points whose coordinates are defined asLongitude/Latitude.IfOD=TRUE a column namedheight.datum isadded to the resulting object.

References

Ordnance Survey Limited, 2018.Transformations and OSGM15 user guide

See Also

sgo_points,sgo_lonlat_bng,sgo_coordinates,sgo_transform.

Examples

p <- sgo_points(list(651409.903, 313177.270), epsg=27700)p.89 <- sgo_bng_lonlat(p) #ETRS89 lon/latp.36 <- sgo_bng_lonlat(p, to=4277) #OSGB36 lon/lat

BNG Easting/Northing to National Grid References (NGR)

Description

Converts BNG Easting/Northing coordinates to National Grid References

Usage

sgo_bng_ngr(x, digits = 10)

Arguments

x

Asgo_points object with coordinates defined asepsg=27700 orepsg=7405.

digits

Numeric. It defines the precision of the resulting gridreferences.

Details

All resulting grid references will have 10 digits (1m × 1m square) bydefault. In order to reduce the output precision change the digits parameteraccordingly. Whendigits=0, it returns the numeric format of the gridreferences.

Note that National Grid references are truncated instead of being roundedwhen converting to less precise references (as the OS system demands). Bydoing so, the grid reference refers to the lower left corner of the relevantsquare - to ensure the more precise polygon will remain within the boundariesof the less precise polygon.

Value

A list with at least one column named 'ngr'.

See Also

sgo_points,sgo_ngr_bng.

Examples

sgo <- sgo_points(list(x=247455, y=706338, name="Ben Venue"),coords=c("x", "y"), epsg=27700)grid10 <- sgo_bng_ngr(sgo)grid8 <- sgo_bng_ngr(sgo, digits=8)#and notice the truncating, not rounding, of grid8 regarding grid10.

Geodetic Coordinate System (GCS) in cartesian coordinates to polarcoordinates

Description

Converts a GCS expressed Earth-centered Earth-fixed (ECEF) cartesiancoordinate to Longitude and Latitude and Ellipsoid Height.

Usage

sgo_cart_lonlat(x)

Arguments

x

Asgo_points object with coordinates expressed in cartesiancoordinates

Details

Currently converts from EPSGs4936 and4978 to4937 and4979

Value

An object of classsgo_points with polar coordinates (Longitude,Latitude and Ellipsoid Height).

See Also

sgo_points,sgo_bng_lonlat.

Examples

p <- sgo_points(list(3487823.234, -305433.201, 5313739.634), epsg=4936)p.xyz <- sgo_cart_lonlat(p) #Cartesian coordinates

Extracts coordinates from ansgo_points object

Description

Extract the coordinates of ansgo_points object expressed as a matrix.

Usage

sgo_coordinates(x, names.xyz = NULL, as.latlon = FALSE,ll.format=NULL)

Arguments

x

An instance ofsgo_points.

names.xyz

Character vector. New names for the columns x, y andpossibly z of the objectx.

as.latlon

Logical variable. Whenx is defined in a geodeticcoordinate system as lon/lat and this parameter is set toTRUE thenit returns the coordinates ordered as lat/lon.

ll.format

Character variable. Applies a format to the returnedcoordinates whenx is defined in a geodetic coordinate system. As ofnow it only acceptsDMS, which will return strings ofcoordinates formatted as degrees, minutes and seconds (certain accuracy willbe lost because seconds are rounded to the second decimal).

Value

A matrix with 2 or 3 named columns.

Examples

p <- sgo_points(list(57.47777, -4.22472), epsg=4326)coords <- sgo_coordinates(p)

Calculate distance(s) between points

Description

Calculates the distance between OS National Grid Reference points. Pointswith angular coordinates will use the Harvesine or Vicenty formulae.

Usage

sgo_distance(x, y, by.element = FALSE,  which = ifelse(isTRUE(x$epsg==27700 || x$epsg==7405), "BNG", "Vicenty"),  grid.true.distance = ifelse(isTRUE(x$epsg==27700 || x$epsg==7405),  TRUE, FALSE), iterations = 100L)

Arguments

x

Asgo_points object describing a set of points in a geodeticcoordinate system.

y

Asgo_points object, defaults tox.

by.element

Logical variable. IfTRUE, return a vector withdistance between the first elements ofx andy, the second,etc. IfFALSE, return the dense matrix with all pairwise distances.

which

Character vector. For geodetic coordinates one ofHarvesine orVicenty. It defaults toBNG for points in'OS British National Grid' coordinates.

grid.true.distance

Logical variable. Currently only used for BNGcoordinates. IfTRUE it returns the true (geodesic) distance.

iterations

Numeric variable. Maximum number of iterations used in theVicenty method.

Details

This function can use two different methods when working with geodeticcoordinates: Whenwhich = "Vicenty" the Vincenty's formula is used tocalculate the geodesics (distance) on an ellipsoid to an accuracy of up toa millimetre. If such accuracy is not needed,which can alsoaccept the string "Harvesine" which calculates the great-circle distancebetween two points on a sphere. Harvesines are faster to compute than theVicenty distances but can result in an error of up to 0.5%.

When working with (BNG) planar coordinates the Local Scale Factor is thescale distortion inherent in the map projection at a point. Whengrid.true.distance isTRUE the function computes a linescale factor using Simpson's Rule to achieve greater accuracy andapproximate the distance to the true geodesic distance. When it isFALSE the Euclidean distance in the plane is calculated.

Note: Considering F as the scale factor, we have thatS (True distance) = s (grid distance) / F
For most purposes the scale factor can be taken as constant for distances upto 20km (errors not exceeding 1 or 2 parts er million) and equal to the midpoint of the line. For longer lines, this routine computes a scale factor forboth ends (F1 and F2) and the mid point (Fm) and then uses the Simpson'sRule:
F = 1/6(F1 + 4Fm + F2)

Value

Ifby.element isFALSEsgo_distance returns a densenumeric matrix of dimension length(x) by length(y). Otherwise it returns anumeric vector of lengthx ory, the shorter one beingrecycled. Distances involving empty geometries areNA.All distances are returned in metres.

References

Thaddeus Vincenty, 1975.Direct and Inverse Solutions of Geodesics onthe Ellipsoid with application of nested equations. Survey Review, 23:176,88-93, DOI: 10.1179/sre.1975.23.176.88

Examples

p1 <- sgo_points(list(-3.9369, 56.1165), epsg=4326)lon <- c(-4.25181,-3.18827)lat <- c(55.86424, 55.95325)pts <- sgo_points(list(longitude=lon, latitude=lat), epsg=4326)p1.to.pts <- sgo_distance(p1, pts, by.element = TRUE)## Perimeter of a polygon defined as a series of ordered points:lon <- c(-6.43698696, -6.43166843, -6.42706831, -6.42102546,-6.42248238, -6.42639092, -6.42998435, -6.43321409)lat <- c(58.21740316, 58.21930597, 58.22014035, 58.22034112,58.21849188, 58.21853606, 58.21824033, 58.21748949)pol <- sgo_points(list(lon, lat), epsg=4326)# Create a copy of the polygon with its coordinates shifted one position# so that we can calculate easily the distance between verticescoords <- sgo_coordinates(pol)pol.shift.one <- sgo_points(rbind(coords[-1, ], coords[1, ]), epsg=pol$epsg)perimeter <- sum(sgo_distance(pol, pol.shift.one, by.element=TRUE))

Pseudo - Mercator to WGS84 Longitude/Latitude

Description

Converts Pseudo - Mercator coordinates to WGS84 (EPSG=4326)

Usage

sgo_en_wgs84(x, to = 4326)

Arguments

x

Asgo_points object describing a set of points in thegeodetic coordinate system EPSG=3857.

to

Numeric. Sets theepsg code of the destination GeodeticCoordinate System. 4326 (WGS84) by default. And currently doesn't support anyother.

Details

Currently converts ONLY from EPSG 3857 to 4326 (Longitude/Latitude).

Value

An object of classsgo_points whose coordinates are defined asLongitude/Latitude.

References

IOGP Publication 373-7-2 - Geomatics Guidance Note number 7,part 2 (October 2020). https://epsg.org/guidance-notes.html

See Also

sgo_points,sgo_wgs84_en.

Examples

p <- sgo_points(list(-11169055.58, 2810000.00), epsg=3857)res <- sgo_en_wgs84(p)

ETRS89 to ETRS89-LAEA Easting/Northing

Description

Converts ETRS89 geodetic coordinates to ETRS89-LAEA Easting/Northing(EPSG:3035)

Usage

sgo_etrs_laea(x)

Arguments

x

Asgo_points object describing a set of points in thegeodetic coordinate system EPSG=4258, 4937 or 4936.

Details

ETRS89-LAEA (EPSG:3035) is a CRS for pan-European statistical mapping at allscales or other purposes where true area representation is required.

Value

An object of classsgo_points whose coordinates are defined asEasting/Northing in the EPSG:3035 Projected Coordinate System.

References

IOGP Publication 373-7-2 - Geomatics Guidance Note number 7,part 2 (October 2020). https://epsg.org/guidance-notes.html)

See Also

sgo_points,sgo_area.

Examples

p <- sgo_points(list(-3.9369, 56.1165), epsg=4258)prj <- sgo_etrs_laea(p)

ETRS89-LAEA Easting/Northing to ETRS89 geodetic coordinates

Description

Converts ETRS89-LAEA Easting/Northing to ETRS89 geodetic coordinates(EPSG:4258)

Usage

sgo_laea_etrs(x)

Arguments

x

Asgo_points object describing a set of points in theprojected coordinate system EPSG=3035.

Details

ETRS89-LAEA (EPSG:3035) is a CRS for pan-European statistical mapping at allscales or other purposes where true area representation is required.

Value

An object of classsgo_points whose coordinates are defined asLongitude/Latitude in the ETRS89 Coordinate Reference System.

References

IOGP Publication 373-7-2 - Geomatics Guidance Note number 7,part 2 (October 2020). https://epsg.org/guidance-notes.html

See Also

sgo_points,sgo_area.

Examples

prj <- sgo_points(list(3962799.45, 2999718.85), epsg=3035)p <- sgo_laea_etrs(prj)

GCS to BNG Easting/Northing

Description

Converts a geodetic coordinate system to BNG (projected) Easting/Northingcoordinates. It also transforms GPS ellipsoid heights to orthometric(mean sea level) heights on the relevant Ordnance Survey mapping datum, usingthe National Geoid Model OSGM15.

Usage

sgo_lonlat_bng(x, to=27700, OSTN=TRUE, OD=FALSE)

Arguments

x

Asgo_points object with coordinates defined in a GeodeticCoordinate System expressed as Longitude and Latitude (e.g. epsg=4258, 4937,4326, 4979 or 4277).

to

Specifies the EPSG code to convert the coordinates to. It can onlytake the following values:27700 or7405.

OSTN

Logical variable indicating whether use OSTN15 transformationwhen TRUE or a less accurate but slightly faster single Helmerttransformation when FALSE.

OD

Logical variable. When TRUE, and the output contains acolumn with heights, then a new column is added to the result indicating theordnance datum (OD) used on each point. It is ignored whenOSTN=FALSE.

Details

The UK Ordnance Survey defined 'OSGB36' as the datum for the UK, based on the'Airy 1830' ellipsoid. However, in 2014, they deprecated OSGB36 in favour ofETRS89 for longitude/latitude coordinates. Thus,x should be definedas ETRS89 (or WGS84) most of the times.

Note: When transforming from EPSG=4277 any height included in the inputwill be simply discarded (seesgo_points).

According to the Transformations and OSGM15 User Guide, p. 8:"...ETRS89 is a precise version of the better known WGS84 referencesystem optimised for use in Europe; however, for most purposes it can beconsidered equivalent to WGS84." and"For all navigation, mapping,GIS, and engineering applications within the tectonically stable parts ofEurope (including UK and Ireland), the term ETRS89 should be taken assynonymous with WGS84." This means that EPSGs with the ETRS89 datum orWGS84 will be considered equivalent by this routine.

Note: All those coordinates outside the rectangle covered by OSTN15will be automatically computed using the small Helmert transformation. Suchcoordinates will be accurate up to about +/-5 metres, therefore the resultingeasting and northing coordinates will be rounded to the metre. Since thosecoordinates are outside of the OSTN15 domain the resulting coordinates willhave the resulting height defined asNA.Similarly, when usingOSTN=FALSE on 3D coordinates, the result willhave all the heights defined asNA.Converting from lon/lat to BNG coordinates is faster than the other wayaround, due to the iterative nature of the algorithm that is built intoOSTN15.

Value

An object of classsgo_points whose coordinates are defined asEasting/Northing (epsg=27700 or 7405). They are adjusted to the SW corner of1m grid square. IfOD=TRUE a column namedheight.datum isadded to the resulting object.

References

Ordnance Survey Limited, 2018.Transformations and OSGM15 user guide

See Also

sgo_points,sgo_bng_lonlat,sgo_coordinates,sgo_transform.

Examples

lon <- c(-4.25181,-3.18827)lat <- c(55.86424, 55.95325)pts <- sgo_points(list(longitude=lon, latitude=lat), epsg=4326)bng.pts <- sgo_lonlat_bng(pts)

Geodetic Coordinate System (GCS) in polar coordinates to cartesiancoordinates

Description

Converts a GCS expressed in Longitude and Latitude(and Ellipsoid Height) to an Earth-centered Earth-fixed (ECEF) cartesiancoordinate system.

Usage

sgo_lonlat_cart(x)

Arguments

x

Asgo_points object with coordinates expressed as Longitudeand Latitude (and Ellipsoid Height if they are 3D points).

Details

Currently converts from EPSGs4258 and4937 to4936 orfrom EPSGs4326,4979 to4978

Value

An object of classsgo_points whose coordinates are defined as ax, y and z cartesian vector.

See Also

sgo_points,sgo_lonlat_bng.

Examples

p <- sgo_points(list(-5.00355049, 56.7968571), epsg=4326)p.xyz <- sgo_lonlat_cart(p) #Cartesian coordinates

NGR to BNG Easting/Northing

Description

Converts OS National Grid References to Easting/Northing coordinates

Usage

sgo_ngr_bng(x, col = NULL, check.only = FALSE)

Arguments

x

A data.frame, list or vector containing strings describing OSNational Grid References, with or without whitespace separators.(e.g. 'SU 387 148').

col

Character string with the name of the 'column' containing thevector of NGR values, it is required whenx is a list or data.framewith more than one column.

check.only

Logical parameter. If it is set to TRUE then the routinereturns a logical vector indicating which references are correct.

Details

All entered standard grid references can range from two-digit references upto 10-digit references (1m × 1m square).Ifx is a list with 2 or more vector elements,col can be usedto inform the function which of the elements contains the NGR strings. Therest of the elements will be appended to the resulting object. See examples.

Value

An object of classsgo_points whose coordinates are defined asEasting/Northing whencheck.only is kept as FALSE. Otherwise, itreturns a logical vector indicating which grid references are correct andwhich ones are not.

See Also

sgo_points,sgo_bng_ngr.

Examples

vec <- c("NN 166 712", "HU38637653")lst <- list(vec)v <- sgo_ngr_bng(vec)l <- sgo_ngr_bng(lst)# any additional column (here 'attr') will be added to the resultextra <- list(p=c("NN 166712", "HU38637653"),              attr=c("name1","name2"))res <- sgo_ngr_bng(extra, col="p")res# grid references returned by sgo_bng_ngr are within an# element (column) named 'ngr'grid <- sgo_bng_ngr(sgo_points(list(x=247455, y=706338, name="Ben Venue"),                               coords=c("x","y"),                               epsg=27700))bng <- sgo_ngr_bng(grid, col="ngr")# testbad <- c("NN 166 712", "AA 3863 7653")check <- sgo_ngr_bng(bad, check.only=TRUE) #returns a logical vector

Object containing 2D or 3D point coordinates

Description

2D or 3D coordinates (and other attributes) of a point or collection ofpoints

Usage

sgo_points(x, coords = NULL, epsg = NULL)## S3 method for class 'sgo_points'print(x, ..., n = 6L)## S3 method for class 'sgo_points'as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'sgo_points'as.list(x, ...)

Arguments

x

A matrix, list or dataframe with at least 2 columns of eithereasting/northing or longitude/latitude coordinates per row. A column withheight values is optional.Please note that the order is important whenx has only 2 or3 columns andcoords is not informed: lat/lon or northing/easting(and height) will produce wrong results.

coords

A vector with the names of the two or three columns containingthe X (easting or longitude), Y (northing or latitude) and optionally Z(ellipsoid or orthometric height) coordinates.

epsg

Specifies the EPSG code of coordinates to store. It can take anyof the following values:

  • when working with (2D/3D) ETRS89 Datum:4258,4937,4936,3035

  • when working with (2D/3D) WGS84 Datum:4326,4979,4978

  • when working with (2D/3D) OSGB36 Datum:4277,27700,7405

  • WGS84/Pseudo-Mercator (Google Maps, OpenStreetMap, etc.):3857

...

Further arguments passed to or from other methods,seeprint,as.data.frame oras.list .

n

Maximum number of features to print.

row.names

NULL or a character vector giving the row names for thedata frame. Missing values are not allowed.

optional

Logical. Seeas.data.frame

Details

This object stores 2D or 3D point coordinates and any other column-list ofattributes related to each point. Note that additional column-lists will beexpanded withNA values if they contain less elements thancoordinates.Currently it only supports the followingepsgs:

Value

An object of classsgo_points. This object is a actually a list withclasssgo_points and at least 5 elements (or 6 elements if it is 3D):

See Also

sgo_coordinates,sgo_transform.

Examples

# lists:p1 <- sgo_points(list(-3.9369, 56.1165), epsg=4326)lon <- c(-4.25181,-3.18827)lat <- c(55.86424, 55.95325)p2 <- sgo_points(list(longitude=lon, latitude=lat), epsg=4326)#p3 will fill up the list 'desc' with NA's to have the same number of#elements as coordinates in the list:p3 <- sgo_points(list(longitude=lon, latitude=lat, desc="c1"),                 coords=c("longitude", "latitude"), epsg=4326)# dataframe:ln <- c(-4.22472, -2.09908)lt <- c(57.47777, 57.14965)n <- c("Inverness", "Aberdeen")df <- data.frame(n, ln, lt, stringsAsFactors = FALSE)p4 <- sgo_points(df, coords=c("ln", "lt"), epsg=4326)# plotting on a map:if (require(maps)) {  map('world', regions=('uk'), xlim=c(-9, 0), ylim=c(54.5, 60.9))  points(x=p1$x, y=p1$y, pch=0, col="green") #Stirling  points(p4, pch=0, col="red")  text(p4, labels=p4$n, pos=1, cex=0.9)}

Set GCS of a set of points

Description

Changes the geodetic coordinate system of a set of points using a singleHelmert transformation.

Usage

sgo_set_gcs(x, to = NULL)

Arguments

x

Asgo_points object describing a set of points in a geodeticcoordinate system.

to

Specifies the EPSG code to convert the coordinates to. Currently itcan take any of the following values:4258,4937,4936,4326,4979,4978 or4277.

Details

Changes the geodetic coordinate system of a set of points. Note that theprecision of various datums will vary, and the original WGS-84 is not definedto be accurate to better than ±1 metre. Most transformations shouldn't beassumed to be accurate to better than a meter; between OSGB36 and WGS84somewhat less - the lost of accuracy can be up to ±5m when using singleHelmert transformations.

Input points with a projected coordinate system (e.g. 27700, 7405, 3035 or3857) are not allowed.

WarningThis function is mainly for internal use of the program. Since it relies on asingle Helmert transformation it is not recommended to call it directly. Useany other of the transformation functions available (sgo-package).

Value

An object of class 'sgo_points'.

See Also

sgo_points,sgo_transform.

Examples

lon <- c(-4.25181,-3.18827)lat <- c(55.86424, 55.95325)p <- sgo_points(list(longitude=lon, latitude=lat), epsg=4326)# warning: a single Helmert transformation is used in the next transformationp2 <- sgo_set_gcs(p, to=4277)# if higher precision is required to transform between OSGB36 lon/lat and# ETRS89/WGS84 lon/lat then use the OSTN15 transformation (will be slower):# Transform from WGS84 lon/lat coordinates to EPSG:4277 using OSTN15p2 <- sgo_transform(p, to=4277)

Coordinate transformation of a set of points

Description

Transforms the coordinate system of a set of points to any supportedcoordinate system.

Usage

sgo_transform(x, to = NULL, ...)

Arguments

x

Asgo_points object.

to

Specifies the EPSG code to convert the coordinates to. Seesgo_points for a list of supported EPSG codes.

...

Additional parameters passed to internal functions. Currently itsupports the additional arguments seen insgo_bng_lonlat andsgo_lonlat_bng.

Details

This function is a wrapper of specific transformation functions(sgo_bng_lonlat,sgo_en_wgs84,sgo_lonlat_bng,sgo_wgs84_en,sgo_laea_etrs,sgo_etrs_laea,sgo_cart_lonlat,sgo_lonlat_cart) that transformsthe coordinate system of a set of points to any of the supported coordinatesystems.

Please note that this package assumes that the Coordinate Reference Systems(CRS) ETRS89 and WGS84 are the same within the UK, but this shouldn't be aproblem for most civilian use of GPS satellites. If a high-precisiontransformation between WGS84 and ETRS89 is required then it is recommendedto use a different package to do the conversion.

According to the Transformations and OSGM15 User Guide, p. 8:"...ETRS89 is a precise version of the better known WGS84 referencesystem optimised for use in Europe; however, for most purposes it can beconsidered equivalent to WGS84." and"For all navigation, mapping,GIS, and engineering applications within the tectonically stable parts ofEurope (including UK and Ireland), the term ETRS89 should be taken assynonymous with WGS84.".

Warning:Coordinates defined in the Geodetic Coordinate SystemEPSG:4277 (with datum OSGB 1936) should only be used to convert to or fromBNG coordinates and for historical reasons only.

Value

An object of class 'sgo_points'.

See Also

sgo_points,sgo_coordinates,sgo_set_gcs,sgo_bng_ngr

Examples

ln <- c(-4.22472, -2.09908)lt <- c(57.47777, 57.14965)n <- c("Inverness", "Aberdeen")df <- data.frame(n, ln, lt, stringsAsFactors = FALSE)locations <- sgo_points(df, coords=c("ln", "lt"), epsg=4326)locations.bng <- sgo_transform(locations, to=27700)locations.osgb36 <- sgo_transform(locations, to=4277)locations.ngr <- sgo_bng_ngr(sgo_transform(locations, to=27700))locations.wgs84EN <- sgo_transform(locations.bng, to=3857)

WGS84 to Easting Northing (Pseudo - Mercator)

Description

Converts WGS84 coordinates to Easting/Northing (Pseudo-Mercator)

Usage

sgo_wgs84_en(x, to = 3857)

Arguments

x

Asgo_points object describing a set of points in thegeodetic coordinate system EPSG=4326 or 4979.

to

Numeric. Sets theepsg code of the destination GeodeticCoordinate System. 3857 (WGS84) by default. And currently doesn't support anyother.

Details

This routine also accepts source data expressed in ETRS89 coordinates(EPSG=4258 or 4937) as it is considered the difference between those two GCSis far less than the accuracy available when working with Pseudo-Mercatorcoordinates.

The results can be used in maps where Pseudo-Mercator coordinates are needed.Usually, those include Google, Bing, OpenStreetMap and several other webmapapplications.

Value

An object of classsgo_points whose coordinates are defined asEasting/Northing.

References

IOGP Publication 373-7-2 - Geomatics Guidance Note number 7,part 2 (October 2020). https://epsg.org/guidance-notes.html

See Also

sgo_points,sgo_en_wgs84.

Examples

p <- sgo_points(list(-3.9369, 56.1165), epsg=4326)res <- sgo_wgs84_en(p)

[8]ページ先頭

©2009-2025 Movatter.jp