Spatial

STContains on Geography column

时光怂恿深爱的人放手 提交于 2019-12-04 06:28:43
问题 I have a bus point in Lat/long (geography). I want to check where my bus point (lat/long) lies in a region. My region is a set of lat/long points. I have lat/long of a region (Outline of the lat/longs which makes a region) in geography form. Now I have one point lat/long and I want to identify if that point lies inside my region. How can I do that? 4000 points make an outline of a region and one point is to check if that exist in that region or not. How will I check that? I think I can use

Value of coordinates() for a SpatialPolygonsDataFrame object?

淺唱寂寞╮ 提交于 2019-12-04 04:57:28
问题 I am trying to get a pseudo barycenter for polygons in a spatial polygon dataframe. Today I stumbled upon the coordinates function that actually returns something for a SpatialPolygonsDataFrame . Unfortunately I found nothing in the help of coordinates about the value for SpatialPolygonsDataFrame . Could somebody tell me what these coordinates are? 回答1: It is the polygon centroid. The source code is found here, look for function FindCG . The equations computed are equivalent to those found on

extract() data from raster with small polygons - rounded weights too small

雨燕双飞 提交于 2019-12-04 03:31:15
Using R, I am trying to extract data from a raster layer using a polygon layer. The polygons are much smaller than the raster cells: Now I call extract() from raster library: a <- extract(raster, polygons, weights = TRUE, small = TRUE) a # ... # [[1551]] # value weight # 209 0.03 # top left cell - more than 50% of the polygon area There are two problems - the weight is the proportion of the cell area covered by the polygon, and the weights are rounded to 1/100. In my case, only the top left cell is present in the output (value 209) - the weight of 3 other cells was rounded to zero and they

Spatial nearest neighbor assignment in R

﹥>﹥吖頭↗ 提交于 2019-12-04 01:57:36
问题 I am working on a study that is trying to assign particulate matter exposure to specific individuals based on their addresses. I have two data sets with longitude and latitude coordinates. One if for individuals and one if for pm exposure blocks. I want to assign each subject with a pm exposure block based on the block that is closest. library(sp) library(raster) library(tidyverse) #subject level data subjectID<-c("A1","A2","A3","A4") subjects<-data.frame(tribble( ~lon,~lat, -70.9821391, 42

Extract feature coordinates from SpatialPolygons and other sp classes

 ̄綄美尐妖づ 提交于 2019-12-03 23:40:10
Package sp provides a number of classes for different spatial concepts (points, lines, polygons). For some classes, accessing feature coordinates is straightforward, e.g. SpatialLines . All examples were taken from respective class help pages. l1 = cbind(c(1,2,3),c(3,2,2)) l1a = cbind(l1[,1]+.05,l1[,2]+.05) l2 = cbind(c(1,2,3),c(1,1.5,1)) Sl1 = Line(l1) Sl1a = Line(l1a) Sl2 = Line(l2) S1 = Lines(list(Sl1, Sl1a), ID="a") S2 = Lines(list(Sl2), ID="b") Sl = SpatialLines(list(S1,S2)) coordinates(Sl) # [prints a list of two with corresponding segments] For SpatialPolygons , coordinates() returns

Entity Framework not getting Spatial type data in result from Sql Server stored procedure

烂漫一生 提交于 2019-12-03 22:16:04
I'm using Entity Framework 6 with .Net 4.5 . I have a stored procedure that selects and returns data. One of the return columns is a geography type . In Visual Studio 2015, I right click the .edmx file, click "Update Model From Database...". This action gets my stored procedure and creates a complex type of storeprocedurename_Result. All the columns are represented in the complex type objects except the geography type . At the same time one of my table also have Geography type but that table is retrieved successfuly with the geography column and it is functioning properly. So, i can guess

Which approach is faster for getting all POIs from MySQL/MariaDB with PHP/Laravel

旧街凉风 提交于 2019-12-03 22:02:05
Correct me if I'm wrong. There are three approaches to get the nearest homes, users have created in my website: To create a table with two columns(latitude, longitude) that both of them are float and say: Here it is: $latitude = 50; $longitude = 60; SELECT * FROM my_table WHERE (latitude <= $latitude+10 AND latitude >= $latitude-10) AND (longitude <= $longitude+10 AND longitude >= $longitude-10) that 10 here means 1km for example. In this approach we can also use harvesine formula. To merge those columns(latitude, longitude) to one column named point as POINT type and again search each row one

spatial filtering by proximity in R

↘锁芯ラ 提交于 2019-12-03 21:16:32
I have occurrence points for a species, and I'd like to remove potential sampling bias (where some regions might have much greater density of points than others). One way to do this would be to maximize a subset of points that are no less than a certain distance X of each other. Essentially, I would prevent points from being too close to each other. Are there any existing R functions to do this? I've searched through various spatial packages, but haven't found anything, and can't figure out exactly how to implement this myself. An example occurrence point dataset can be downloaded here .

natural neighbour interpolation. error in calculating polygon intersection area

老子叫甜甜 提交于 2019-12-03 20:30:36
I am trying to write this algorithm in R. Does it exist in any package already?!? This is what I did (with help from SO and various blog posts): library(rgdal) library(ggmap) require("maptools") require("plyr") locations<- unique(cbind(data22[,1], data22[,2])) [,1] [,2] [1,] 24.9317 60.1657 [2,] 24.9415 60.1608 [3,] 24.9331 60.1577 [4,] 24.9228 60.1477 [5,] 24.9370 60.1545 [6,] 24.9491 60.1559 [7,] 24.9468 60.1591 [8,] 24.9494 60.1675 [9,] 24.9561 60.1609 [10,] 24.9218 60.1632 [11,] 24.9213 60.1605 [12,] 24.9219 60.1557 [13,] 24.9208 60.1704 [14,] 24.9233 60.1714 [15,] 24.9469 60.1737 [16,] 24

SQL Spatial Join

雨燕双飞 提交于 2019-12-03 17:47:41
问题 I have 2 tables one with points as geographies and other with polygons as geographies. I am able to find which polygon a single point falls(from the point table) by the following query: DECLARE @p geography; select @p = PointGeom from dbo.PointTable where ID = 1 SELECT a.ID, ATTRIBUTE1, geom from dbo.PolygonTable a where geom.STIntersects(@p) = 1; However, I want to do a join between the two tables and get the polygons in which each of the points in the Point Table fall. Is it even possible?