Spatial

rgeos gIntersection in loop takes too long to clip path network

风流意气都作罢 提交于 2019-12-08 08:17:49
问题 I am using gIntersection to clip a nationwide path network by polygons one at a time from a SpatialPolygonsDataFrame. I am looping through each polygon, clipping the path network, calculating the length of the clipped paths, and saving this to a dataframe called path.lgth: poly<-readShapePoly("C:\\temp\\polygons.shp") paths<-readShapeLines("C:\\temp\\paths.shp") #loop through all polygons clipping lines path.lgth<-data.frame() for (i in 1:length(poly)){ clip<-gIntersection(paths,poly[i,])

Speed up text comparisons (feature vectors) with spatial MySQL features

前提是你 提交于 2019-12-08 06:57:03
问题 I have a function which takes two arrays containing the tokens/words of two texts and gives out the cosine similarity value which shows the relationship between both texts. The function takes an array $tokensA (0=>house, 1=>bike, 2=>man) and an array $tokensB (0=>bike, 1=>house, 2=>car) and calculates the similarity which is given back as a floating point value. function cosineSimilarity($tokensA, $tokensB) { $a = $b = $c = 0; $uniqueTokensA = $uniqueTokensB = array(); $uniqueMergedTokens =

creating road network datasets in R

允我心安 提交于 2019-12-08 06:54:30
问题 I have a line shapefile containing roads, and I'd like to use it to create a network dataset. In ArcGIS, I'd do this with the Network Analyst extension (see here). Is there an R package with the equivalent functionality? I've checked out Bivand's Cran Task View for the analysis of spatial data, and I've searched a bit on SO and the GIS SE, but I haven't found any good leads. I've also looked through Bivand et al.'s (2013) Applied Spatial Data Analysis with R. I've been using R for a while,

Efcore Spatial Query: A number is expected at position 9 of the input. The input has @p0. -

与世无争的帅哥 提交于 2019-12-08 06:47:56
问题 I'm trying to get around the fact that Entity Framework Core doesn't have support for Spatial Types by using the DBSet.FromSQL Method, and hand rolling a migration to add a geography column on SQL Server. Here's my DataContext public interface IDataContext { DbSet<PointOfInterest> PointsOfInterest { get; set; } int SaveChanges(); Task<int> SaveChangesAsync(CancellationToken cancellationToken); } public class DataContext : DbContext, IDataContext { public DataContext(DbContextOptions options)

MySQL VS Postgres/POSTGIS spatial database support [duplicate]

筅森魡賤 提交于 2019-12-08 05:13:07
问题 This question already has answers here : GIS: PostGIS/PostgreSQL vs. MySql vs. SQL Server? [closed] (5 answers) Closed 4 years ago . We're building a small-sized GIS Web application (as a school project) right now. In terms of spatial database support and capabilities, which is better? 回答1: Check it out for yourself, you know what you're looking for in your GIS-application: http://www.bostongis.com/PrinterFriendly.aspx?content_name=sqlserver2008_postgis_mysql_compare In general PostGIS is

How can I return a substring of a LINESTRING in SQL Server 2008 Spatial?

耗尽温柔 提交于 2019-12-08 04:48:29
问题 Say I have a LINESTRING defined as LINESTRING(-122.360 47.656, -122.343 47.656, -122.310 47.690, -122.310 47.670, -122.300 47.630) And I want to get a substring from POINT(-122.360 47.656) to POINT(-122.310 47.690) How can I return a substring of a LINESTRING in SQL Server 2008 Spatial? 回答1: Well, I managed to do it in a CLR user defined function. It is not quite a "substring" method per se, but I needed to subdivide a LINESTRING into multiple LINESTRINGs each of either X units in length or

Get spatial points within radius using NHibernate Spatial

可紊 提交于 2019-12-08 04:34:22
问题 I'm currently trying to naivly get the k-nearest neighbors of a set of points, given a value k, a coordinate to use as center and a radius serving as the max distance to find points within. I'm using geographical points (SRID 4326) on a MSSQL 2008 database. The neighbors are naivly found ordering the query by the distance to the point and limiting the result. My trouble starts at limiting the points by the given radius. The distances returned by the Distance function are much larger than

Interpolating Gridded 3D Data to a finer scale

别来无恙 提交于 2019-12-07 22:51:35
问题 I have a NetCDF file of a probability surface. It's a 30x30 grid of 0.25 degree lat/lon intervals with a probability surface described in the z dimension. I can easily import this into Panoply, a NetCDF viewer: And it's then a breeze (checking one box) to interpolate/smooth the raw data to a finer grid size: However, I don't just want to visualize the data, I want to plot it in R along with bathymetry and point data. That all is no problem, but I have not found a straightforward way to

Adding CRS in sp seems inconsistent

瘦欲@ 提交于 2019-12-07 22:17:50
问题 I want to use the over() function from the sp package in R . I assigne a CRS . #say that polygon is EPSG3857 (Web Mercator PROJECTION) proj4string(finalPolygon) <- CRS("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs") and all seems good. str(finalPolygon) > ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot > .. .. ..@ projargs: chr "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1

get cell number within a distance of one point (raster)

落花浮王杯 提交于 2019-12-07 20:53:51
问题 I need to get the cell numbers within a distance (e.g., 10 km) of one point using R, but I didn't figure out how to handle it for the raster data. library(raster) r <- raster(ncols=10, nrows=10) cellFromXY(r, c(2,2)) # get the cell number of one point How to get the cell numbers within a distance of one point? 回答1: Use extract with the buffer option and cellnumbers=TRUE r <- raster(ncols=100, nrows=100) r[]<-runif(ncell(r)) xy <- cbind(-50, seq(-80, 80, by=20)) extract(r, xy[1:3,], buffer