sp

Fastest cartesian distance (R) from each point in SpatialPointsDataFrame to closest points/lines in 2nd shapefile

﹥>﹥吖頭↗ 提交于 2020-06-13 11:28:07
问题 I want to know the fastest algorithms for obtaining the cartesian distances between each point in a SpatialPointsDataFrame ( X ) and either (a) the closest point in a second SpatialPointsDataFrame ( Y ), or (b) the closest line segment in a SpatialLinesDataFrame ( Y ). So this is basically 2 questions, with perhaps the same answer. For the lines, I know I can use dist2Line(X,Y, distfun=distGeo) but this is insanely slow. I also tried using nncross , after converting both X and Y to ppp

Spatial line start and end point in R

拈花ヽ惹草 提交于 2020-06-01 06:41:10
问题 I am attempting to use the sp package to access the start and end points of a linestring, similar to what ST_StartPoint and ST_EndPoint would produce using psql . No matter how I try to access the line, I get errors or NULL value: > onetrip@lines[[1]][1] Error in onetrip@lines[[1]][1] : object of type 'S4' is not subsettable > onetrip@lines@Lines@coords Error: trying to get slot "Lines" from an object of a basic class ("list") with no slots > onetrip@lines$Lines NULL The only solution that

Spatial line start and end point in R

╄→尐↘猪︶ㄣ 提交于 2020-06-01 06:41:10
问题 I am attempting to use the sp package to access the start and end points of a linestring, similar to what ST_StartPoint and ST_EndPoint would produce using psql . No matter how I try to access the line, I get errors or NULL value: > onetrip@lines[[1]][1] Error in onetrip@lines[[1]][1] : object of type 'S4' is not subsettable > onetrip@lines@Lines@coords Error: trying to get slot "Lines" from an object of a basic class ("list") with no slots > onetrip@lines$Lines NULL The only solution that

R measuring distance from a coastline

北城余情 提交于 2020-05-25 04:29:25
问题 I have a set of coordinates: d1 <- data_frame( title = c("base1", "base2", "base3", "base4"), lat = c(57.3, 58.8, 47.2, 57.8, 65.4, 56.7, 53.3), long = c(0.4, 3.4, 3.5, 1.2, 1.5, 2.6, 2.7)) I would like to know whether the coordinates fall on land, in the sea, or are 3 miles inside a coastline. The coordinates should fall somewhere within the UK, so I know that I need to draw a shape file of the UK and plot the points onto it. I just don't know how to measure whether the points fall in the

How do I generate a Hexagonal grid in R

主宰稳场 提交于 2020-05-09 19:14:06
问题 I would like to be able to create a SpatialPolygons object (which is a Hexagonal grid) that covers another SpatialPolygon. I would like all the Hexagons to have a diameter of 1km (ideally i can vary this) and for all the hexagons together to cover the whole object. The method below only seems to cover a small amount of it... Below is my attempt using the sp package: require(sp) data(meuse.riv) meuse.sr = SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)), "x"))) plot(meuse.sr) HexPts <

Map Australian cities - R spatial

风格不统一 提交于 2020-05-08 12:51:23
问题 I want to draw a map of Australia and represent each city as a dot. Then highlight the cities with a high population (>1M) library(sp) library(maps) data(canada.cities) head(canada.cities) I have checked the sp package where this can be done for Canada and some other countries. But Australia details are not there. Is there a special way to get the data for a country we like (name of cities, long, lat, pop)? 回答1: Now you have the data using world.cities , you can plot them a few ways library

Map Australian cities - R spatial

穿精又带淫゛_ 提交于 2020-05-08 12:50:13
问题 I want to draw a map of Australia and represent each city as a dot. Then highlight the cities with a high population (>1M) library(sp) library(maps) data(canada.cities) head(canada.cities) I have checked the sp package where this can be done for Canada and some other countries. But Australia details are not there. Is there a special way to get the data for a country we like (name of cities, long, lat, pop)? 回答1: Now you have the data using world.cities , you can plot them a few ways library

android 布局中的单位及分辨率自解

杀马特。学长 韩版系。学妹 提交于 2020-04-06 23:50:41
先上一个网上copy的 px :是屏幕的像素点 in :英寸 mm :毫米 pt :磅, 1/72 英寸 dp :一个基于 density 的抽象单位,如果一个 160dpi 的屏幕, 1dp=1px dip :等同于 dp sp :同 dp 相似,但还会根据用户的字体大小偏好来缩放。 建议使用 sp 作为文本的单位,其它用 dip 然后是我自己的理解: Android 的屏幕密度是以 160 为基准的 , 屏幕密度 (densityDpi) 为 160 时 , 是将一英寸分为 160 份 , 每一份是 1 像素 . 如果屏幕密度 (densityDpi) 为 240 时 , 是将一英寸分为 240 份 , 每一份是 1 像素 . 1 英寸 /160( 机器 x) = 1 英寸 /240( 机器 y) = 1px 打个比方 , 一个三英寸的显示屏幕的机器 , 如果屏幕密度 (densityDpi) 为 160, 即密度比 (density)1.0 时 , 画一条 160dip 和 160px 的线条 , 两个都是 1 英寸 . 可如果还是三英寸的屏幕 , 如果屏幕密度 (densityDpi) 变为 320, 即密度比 (density)2.0 时 ,1 英寸有 320 像素了 , 此时 160px 显示就是半英寸 . 160dip 显示还是 1 英寸 , 因为 1dip =

Plot a list of lines with R lattice package

╄→尐↘猪︶ㄣ 提交于 2020-03-21 06:40:31
问题 I'm trying to show some variogram model fits on the top of xy.plots . The panel.plots work for all except for a list of lines I wanted to add to corresponding subplots . require(gstat) require(sp) data(meuse) names(meuse) #make directional variograms b<-variogram(log(zinc)~1, meuse, alpha = c(0, 45, 90, 135)) #split the variogram data by direction a<-lapply(1:length(unique(b$dir.hor)), function(i) subset(b, grepl(unique(b$dir.hor)[[i]], b$dir.hor))) #get the model fit parameters for each

Plot a list of lines with R lattice package

隐身守侯 提交于 2020-03-21 06:40:13
问题 I'm trying to show some variogram model fits on the top of xy.plots . The panel.plots work for all except for a list of lines I wanted to add to corresponding subplots . require(gstat) require(sp) data(meuse) names(meuse) #make directional variograms b<-variogram(log(zinc)~1, meuse, alpha = c(0, 45, 90, 135)) #split the variogram data by direction a<-lapply(1:length(unique(b$dir.hor)), function(i) subset(b, grepl(unique(b$dir.hor)[[i]], b$dir.hor))) #get the model fit parameters for each