sp

R sp: unit of area of Polygon

柔情痞子 提交于 2019-12-12 18:34:45
问题 I use R to read in a shape file to analyse with the sp package polygons of oilfields (longitude-latitude with WGS84) and their respective areas. Unfortunately I do not know the unit of the area output. E.g. the area output is on average 0.85 units (max 4.34) which probably is not in square kilometers since this would be much too small for oilfields. Does anyone know the unit of the area output of Polygons in the sp package? Many thanks! 回答1: To get a correct area computation for a polygon in

r gis: identify inner borders between polygons with sf

独自空忆成欢 提交于 2019-12-12 11:23:34
问题 This is an update of my previous similar question, the same task only I need to do it within sf framework. I need to identify the inner boundaries between polygons, red lines in this map. Within sp framework I used to utilize a self written function that wrapped @Spacedman's answer. Here it is: identify_borders <- function(SPolyDF){ require(rgeos) require(sp) borders <- gDifference( as(SPolyDF,"SpatialLines"), as(gUnaryUnion(SPolyDF),"SpatialLines"), byid=TRUE) df <- data.frame(len = sapply(1

Changing the Projection of Shapefile

前提是你 提交于 2019-12-12 08:34:02
问题 I am trying to change or assign the projection of a Germany-Shapefile from NA to +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 , but somehow it doesn't work well. Reproducible Example: Shapefile and other files can be downloaded here: What I tried is the following: library(maptools) library(sp) library(rgeos) library(rgdal) projection.x <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0") mapG <- readShapePoly("vg2500_lan.shp", verbose=TRUE, proj4string

Incorrect values returned by sp::over function?

空扰寡人 提交于 2019-12-12 04:53:53
问题 I'm extracting elevation data of a route from a Digital Elevation Model using my.elev <- over(new.points, mygrid) new.points is a SpatialPoints object, with the coordinates (long/lat) of about 7000 points transformed in the CRS of mygrid mygrid is a SpatialGridDataFrame with more than 8 millions elements (more info in my previous question) Having several NA values in my.elev, I debugged my code and I found that almost all the points in new.points repeated more than one time (in my route few

Filter shapefile polygons by area

牧云@^-^@ 提交于 2019-12-12 04:44:04
问题 I have the following boundary dataset for the United Kingdom, which shows all the counties: library(raster) library(sp) library(ggplot) # Download the data GB <- getData('GADM', country="gbr", level=2) Using the subset function it is really easy to filter the shapefile polygons by an attribute in the data. For example, if I want to exclude Northern Ireland: GB_sub <- subset(UK, NAME_1 != "Northern Ireland") However, there are lots of small islands which distort the scale data range, as shown

Invalid `.internal.selfref` warning, column not updated working with `SpatialPolygonsDataFrame`

主宰稳场 提交于 2019-12-12 00:31:58
问题 I'm trying to do some geospatial analysis in R which will involve adding attributes to SpatialPolygonsDataFrame s for coloring, etc. during plotting. For organization, I'd like to add these attributes to my SpatialPolygonsDataFrame s through a merge & update, but I keep getting the "Invalid .internal.selfref " warning & the columns won't be added. Poking around the questions and answers here, it seems to be related to the fact that the data for a SpatialPolygonsDataFrame object is stored in a

gCentroid shifting centroid towards concentration of points

爱⌒轻易说出口 提交于 2019-12-11 17:36:49
问题 I have a SpatialPointsDataFrame defining SD boundary, however when I compute the center with gCentroid it's shifted. c. = rgeos::gCentroid(c.) %>% as.data.frame() Why isn't it plotting it at the center? 回答1: It is because the mass of points is higher in the lower right corner. If you transform your object to a SpatialPolygons object (making it one shape) then it works: poly <- SpatialPolygons(Srl = list(Polygons( srl = list(Polygon(coords = coordinates(dat))), ID = 1))) gCentroid(spgeom =

OKTA(IdP) - Shibboleth(SP) with reverse proxy to Tomcat

℡╲_俬逩灬. 提交于 2019-12-11 15:46:10
问题 I am spinning a big wheel now. please shed some light. Reverse proxy is working with Apache. So, when I access https://hostname/app/default.html, it opens Tomcat app url. No issue. The tomcat app currently redirects to https://hostname/app/login.html which has a login box. 1) Do I need to disable UserDatabase on Tomcat server.xml ? <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org

计算两直线交点

旧巷老猫 提交于 2019-12-11 09:48:16
function LineToLineCP(VertLine, WallLine: TGPLineF): TGPPointF; var SP, EP, SP1, EP1: TGPPointF; t: Single; ReGP: TGPPointF; begin SP.X := VertLine.SP.X; SP.Y := VertLine.SP.Y; EP.X := VertLine.EP.X; EP.Y := VertLine.EP.Y; SP1.X := WallLine.SP.X; SP1.Y := WallLine.SP.Y; EP1.X := WallLine.EP.X; EP1.Y := WallLine.EP.Y; ReGP.X := SP.X; ReGP.Y := SP.Y; // 需判断 if IsEqualValue(SP.X, EP.X) and IsEqualValue(SP1.Y, EP1.Y) then begin ReGP.X := SP.X; ReGP.Y := SP1.Y; end else if IsEqualValue(SP.Y, EP.Y) and IsEqualValue(SP1.X, EP1.X) then begin ReGP.X := SP1.X; ReGP.Y := SP.Y; end else begin t := ((SP.X

Using crosstalk with leaflet and polylines

≡放荡痞女 提交于 2019-12-11 08:57:04
问题 I have a data frame with a number of rows, each of which represent a single train journey between two cities. I'm trying to use crosstalk to filter these journeys, and then plot them with leaflet. However, I can't figure out how to make it work with polylines. Here's some example code: library(readr) library(leaflet) library(crosstalk) library(sp) library(dplyr) journeys_text <- '"id","from","to","duration_car","duration_car_traffic","distance","duration","speedup_traffic","speedup","lat_from