Questions tagged [spatial]

Spatial data types store geometric data, that is data related to an object's position in space.

Spatial data types store an object's position in space, colloquially these types are "geometric" or "geographic", and operating on them will make use of geodesic or Cartesian calculations. The applied field devoted to spatial data is Geographic Information Systems (GIS); the GIS Stack Exchange should be considered for questions with this tag.

Many popular databases engines now include support of spatial data types, including:

3312 questions
17
votes
2 answers

Check if point is in spatial object which consists of multiple polygons/holes

I have a SpatialPolygonsDataFrame with 11589 objects of class "polygons". 10699 of those objects consists of exactly 1 polygon, however the rest of those objects consists of multiple polygons (2 to 22). If an object of consists of multiple…
majom
  • 7,863
  • 7
  • 55
  • 88
17
votes
3 answers

Determining the distance between two ZIP codes (alternatives to mapdist)

I want to calculate the distance between approx. 100,000 different ZIP codes. I know about the mapdist function in the ggmap package mapdist works perfectly: library(ggmap) mapdist('Washington', 'New York', mode = 'driving') # from to…
majom
  • 7,863
  • 7
  • 55
  • 88
17
votes
6 answers

Storing objects for locating by x,y coordinates

I'm trying to determine a fast way of storing a set of objects, each of which have an x and y coordinate value, such that I can quickly retrieve all objects within a certain rectangle or circle. For small sets of objects (~100) the naive approach of…
Derek Lewis
  • 1,067
  • 1
  • 10
  • 16
16
votes
1 answer

SpatialPolygons - Creating a set of polygons in R from coordinates

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,…
Leah Wasser
  • 717
  • 3
  • 8
  • 22
16
votes
1 answer

Entity Framework: SqlGeography vs DbGeography

What is the difference, or intended purpose of these two object that represent the same Geography datatype in a Microsoft SQL Database? System.Data.Entity.Spatial.DbGeography and Microsoft.SqlServer.Types.SqlGeography They can't be cast between…
simbolo
  • 7,279
  • 6
  • 56
  • 96
16
votes
2 answers

How to replace NA's in a raster object

I need to replace the NA's in the raster object (r) from the example below. library(raster) filename <- system.file("external/test.grd", package="raster") r <- raster(filename) I also tried to remove these these (and place the result in a…
ils
  • 473
  • 2
  • 4
  • 9
15
votes
3 answers

What technique should be used to prune 2d collision checks?

From the outset, collision detection feels like it is an O(n^2) problem. You have a bunch of objects and you need to check if each object is colliding with any of the other objects. However, I know that it is wildly ineffecient to check each…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
15
votes
3 answers

How do I use a geospatial query in the 2.1 MongoDB C# driver?

I've been banging my head on this one for days. I have a very simple query I'm trying to run in C#, it looks like this in the shell. db.runCommand({geoNear: "items", near: {type: "Point", coordinates : [-111.283344899999, 47.4941836]}, spherical :…
14
votes
1 answer

Reading shape file with sf::st_read fails to capture encoding UTF8

I want to read a shape file which is encoded in UTF8. It works fine when I read it using rgdal::readOGR but sf::st_read fails to get the correct Encode. Any suggestions on how to solve this? For a reproducible example, the shape file I'm trying to…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
14
votes
1 answer

EF Core 2.2 spatial type can't be added to db migration

I'm trying to build a database with a spatial object using EF core 2.2, and i'm getting a problem with trying to create the database migrations. using https://learn.microsoft.com/en-us/ef/core/modeling/spatial , specifically: class Country { …
Phil
  • 1,852
  • 2
  • 28
  • 55
14
votes
3 answers

R Overlay points and polygons with a certain degree of tolerance

Using R, I would like to overlay some spatial points and polygons in order to assign to the points some attributes of the geographic regions I have taken into consideration. What I usually do is to use the command over of the sppackage. My problems…
Nemesi
  • 781
  • 3
  • 13
  • 29
14
votes
1 answer

What is the difference between Microsoft.Spatial and System.Spatial libraries

I would like to know what is the difference between two spatial libraries - Microsoft.Spatial and System.Spatial? When I'm looking into the code of those two I see almost the same classes. Both has for example GeographyPoint or Geography abstract…
Dawid Rutkowski
  • 2,658
  • 1
  • 29
  • 36
14
votes
3 answers

Convert Begin and End Coordinates into Spatial Lines in R

I have a set of begin and end coordinates that look like this: begin.coord <- data.frame(lon=c(-85.76,-85.46,-85.89), lat=c(38.34,38.76,38.31)) end.coord <- data.frame(lon=c(-85.72,-85.42,-85.85), lat=c(38.38,38.76,38.32)) I am trying to create a…
Joe Ripberger
  • 569
  • 1
  • 7
  • 19
14
votes
1 answer

Extract feature coordinates from SpatialPolygons and other sp classes

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 =…
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
14
votes
1 answer

Combine Voronoi polygons and maps

I would like to combine Voronoi polygons with map, in order to use this later for spatial analysis. I have number of points and shapefile that i want to combine and then save as shapefile/spatial polygons. To get voronoi polygons i use function from…
Maciej
  • 3,255
  • 1
  • 28
  • 43