sp

SpatialPolygons - Creating a set of polygons in R from coordinates

最后都变了- 提交于 2019-11-27 12:53:05
I am trying to take create a set of polygons from vertex locations, saved in X,Y format. Here is an example of my data - each row represents the vertices for one polygon. the polygons are squares square <- rbind(c(255842.4, 4111578, 255862.4, 4111578, 255862.4, 4111558, 255842.4, 4111558, 255842.4, 4111578, 255842.4, 4111578), c(257397.0, 4111309, 257417.0, 4111309, 257417.0, 4111289, 257397.0, 4111289, 257397.0, 4111309, 257397.0, 4111309)) ID <- c("SJER1", "SJER2")' I am using SpatialPolygons , thus my data need to be in a list. so i created a loop to attempt to get my data into a list

Converting a “map” object to a “SpatialPolygon” object

夙愿已清 提交于 2019-11-27 03:15:06
问题 I am guessing there is a simple solution to the problem I have been having, but I am having some trouble. I am trying to convert the following map object: require(maps) usa <- map("state") into a SpatialPolygon object using the map2SpatialPolygons function: require(maptools) usa.sp <- map2SpatialPolygons(usa, IDs=usa$names,proj4string=CRS("+proj=longlat")) I keep getting the following error: Error in map2SpatialPolygons(usa, IDs = usa$names, proj4string = CRS("+proj=longlat")) : map and IDs

How to efficiently calculate distance between pair of coordinates using data.table :=

一曲冷凌霜 提交于 2019-11-26 16:43:33
I want to find the most efficient (fastest) method to calculate the distances between pairs of lat long coordinates. A not so efficient solution has been presented (here) using sapply and spDistsN1{sp} . I believe this could be made much faster if one would use spDistsN1{sp} inside data.table with the := operator but I haven't been able to do that. Any suggestions? Here is a reproducible example : # load libraries library(data.table) library(dplyr) library(sp) library(rgeos) library(UScensus2000tract) # load data and create an Origin-Destination matrix data("oregon.tract") # get centroids as a

How to efficiently calculate distance between pair of coordinates using data.table :=

*爱你&永不变心* 提交于 2019-11-26 04:54:00
问题 I want to find the most efficient (fastest) method to calculate the distances between pairs of lat long coordinates. A not so efficient solution has been presented (here) using sapply and spDistsN1{sp} . I believe this could be made much faster if one would use spDistsN1{sp} inside data.table with the := operator but I haven\'t been able to do that. Any suggestions? Here is a reproducible example : # load libraries library(data.table) library(dplyr) library(sp) library(rgeos) library