Spatial

MySQL INSERT/UPDATE on POINT column

不羁岁月 提交于 2019-12-03 08:22:59
I'm trying to populate my DB with geographical places of my country. One of my tables have 4 fields: ID[PK], latitude. longitude ande geoPoint EDIT `SCDBs`.`Punto_Geografico`; SET @lat = 18.469692; SET @lon = -63.93212; SET @g = 'POINT(@lat @lon)'; UPDATE Punto_Geografico SET latitude = @lat, longitude =@lon, geoPoint =@g WHERE idpunto_geografico = 0; im getting the following error: Error Code: 1416 Cannot get geometry object from data you send to the GEOMETRY field I'm pretty sure that 'geoPoint' field is a POINT field with a spatial index. Am i missing anything.14 Marc B Try doing it without

SQL Geometry find all points in a radius

浪子不回头ぞ 提交于 2019-12-03 07:46:24
问题 I am fluent in SQL but new to using the SQL Geometry features. I have what is probably a very basic problem to solve, but I haven't found any good resources online that explain how to use geometry objects. (Technet is a lousy way to learn new things...) I have a collection of 2d points on a Cartesian plane, and I am trying to find all points that are within a collection of radii. I created and populated a table using syntax like: Update [Things] set [Location] = geometry::Point(@X, @Y, 0) (@X

Correct way of finding distance between two coordinates using spatial function in MySql

家住魔仙堡 提交于 2019-12-03 07:46:17
问题 I am trying to calculate distance between two locations using spatial functions in both Mysql and PostgresSQL. I have taken the latitude and longitude from Google. The details are below Location one - Lat: 42.260223; Lon: -71.800010 Location two - Lat: 42.245647; Lon: -71.802521 SQL Query used: SELECT DISTANCE(GEOMFROMTEXT('Point(42.260223 -71.800010)'),GEOMFROMTEXT('Point(42.245647 -71.802521)')) The both databases are giving the same result 0.014790703059697. But when I calculate distance

spatial clustering in R (simple example)

倾然丶 夕夏残阳落幕 提交于 2019-12-03 07:04:57
I have this simple data.frame lat<-c(1,2,3,10,11,12,20,21,22,23) lon<-c(5,6,7,30,31,32,50,51,52,53) data=data.frame(lat,lon) The idea is to find the spatial clusters based on the distance First, I plot the map (lon,lat) : plot(data$lon,data$lat) so clearly I have three clusters based in the distance between the position of points. For this aim, I've tried this code in R : d= as.matrix(dist(cbind(data$lon,data$lat))) #Creat distance matrix d=ifelse(d<5,d,0) #keep only distance < 5 d=as.dist(d) hc<-hclust(d) # hierarchical clustering plot(hc) data$clust <- cutree(hc,k=3) # cut the dendrogram to

Calculate Minimum Bounding Rectangle Of 2D Shape By Coordinates

a 夏天 提交于 2019-12-03 06:36:43
I have a solution that uses spatial data to represent a cluster of points on a map. I have the need to used the coordinates that represent the extents of a cluster to find the minimum bounding rectangle that can contain said cluster of points. Does any simple algorithm exist to be able to calculate this or is there any built in functionality in C# to achieve this. I am aware of the NetTopologySuite but am not sure how/if I could use this to achieve the same goal. I have a list of coordinates so I would need to pass this list of strings into it and get the MBR out. The easiest solution, and I

SQL Spatial Join

那年仲夏 提交于 2019-12-03 06:30:38
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? Or do I need to loop through the Point table and call the above query multiple times? This should work:

How to take a subset from a netCDF file using latitude/longitude boundaries in R

ぃ、小莉子 提交于 2019-12-03 06:14:55
I have a netCDF file that I wish to extract a subset from defined by latitude/longitude boundaries (i.e. a lat/long defined box), using the ‘ncdf’ package in R. A summary of my netCDF file is below. It has two dimensions (latitude and longitude) and 1 variable (10U_GDS4_SFC). It is essentially a lat/long grid containing wind values: [1] "file example.nc has 2 dimensions:" [1] "lat_0 Size: 1280" [1] "lon_1 Size: 2560" [1] "------------------------" [1] "file example.nc has 1 variables:" [1] "float 10U_GDS4_SFC[lon_1,lat_0] Longname:10 metre U wind component Missval:1e+30" The latitude variable

Spatial Data Structures for moving objects?

柔情痞子 提交于 2019-12-03 05:50:43
问题 I was wondering what is the best data structure to deal with a lot of moving objects(spheres, triangles, boxes, points, etc)? I'm trying to answer two questions, Nearest Neighbor and Collsion detection. I do realize that traditionally, data structures like R trees are used for nearest neighbor queries and Oct/Kd/BSP are used for collision detection problems dealing with static objects, or with very few moving objects. I'm just hoping that there is something else out there that is better. I

How to persist a calculated GEOMETRY or GEOGRAPHY column

时间秒杀一切 提交于 2019-12-03 03:35:21
I'm trying to create a table under SQL Server 2008 containing a GEOMETRY column and a calculated variation thereof. Considering the following table where the calculated column returns a buffered geometry: CREATE TABLE [dbo].[Test] ( [Geometry] GEOMETRY NOT NULL, [Buffer] FLOAT NOT NULL, [BufferedGeometry] AS ([Geometry].STBuffer([Buffer])) PERSISTED ); The problem with this is it results in the following error: Msg 4994, Level 16, State 1, Line 2 Computed column 'BufferedGeometry' in table 'Test' cannot be persisted because the column type, 'geometry', is a non-byte-ordered CLR type. I have

How to replace NA's in a raster object

我只是一个虾纸丫 提交于 2019-12-03 02:10:11
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 data.frame ), but to no avail. dfr <- as.data.frame(r, na.rm=T) summary(dfr) # test # Min. : 128.4 # 1st Qu.: 293.2 # Median : 371.4 # Mean : 423.2 # 3rd Qu.: 499.8 # Max. :1805.8 # NA's :6097 I'm not sure it makes sense to remove NA values from a raster object, but you can easily replace it. For example: oldpar <- par(mfrow=c(1, 2)) plot(r) r[is.na(r)] <-