Spatial

Union all geometry in a SQL Server table like GeomUnion in Postgres

跟風遠走 提交于 2019-12-01 03:26:29
Just to clarify up-front: I'm talking about unioning geometry, not the SQL keyword UNION . I'm trying to move some spatial data from Postgres with PostGIS to SQL Server 2008. It was fine until I saw a statement like this: SELECT GeomUnion(the_geom) FROM some_table This unions all geometry in that column and return it as one result (similar to how COUNT works). As far I know, SQL Server only has the STUnion function, which unions one geometry with another. Is there any way to do something similar to the Postgres way? If it helps, the STUnion function works like this: SELECT first_geometry

SQL Server 2008 Performance on nullable geography column with spatial index

我的未来我决定 提交于 2019-11-30 23:49:30
I'm seeing some strange performance issues on SQL Server 2008 with a nullable geography column with a spatial index. Each null value is stored as a root node within the spatial index. E.g. A table with 5 000 000 addresses where 4 000 000 has a coordinate stored. Every time I query the index I have to scan through every root node, meaning I have to scan through 1 000 001 level 0 nodes. (1 root node for all the valid coordinates + 1M nulls) I cannot find this mentioned in the documentation, and I cannot see why SQL allows this column to be nullable if the indexing is unable to handle it. For now

Mysql within distance query

非 Y 不嫁゛ 提交于 2019-11-30 20:56:11
Options $lat = '25.7742658'; $lng = '-80.1936589'; $miles = 30; Query SELECT *, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM locations HAVING distance < $miles ORDER BY distance LIMIT 0, 20 I have a database table with 4 columns: unique id city name latitude (lat) longitude (lng) I'm using the query on top to return locations that are within a specified number of miles from the specified coordinates. It seems to work but I'm not sure how accurate it is. I'm curios to know

SQL Server - stored procedure suddenly become slow

99封情书 提交于 2019-11-30 20:49:59
I have written a stored procedure that, yesterday, typically completed in under a second. Today, it takes about 18 seconds. I ran into the problem yesterday as well, and it seemed to be solved by DROPing and re-CREATEing the stored procedure. Today, that trick doesn't appear to be working. :( Interestingly, if I copy the body of the stored procedure and execute it as a straightforward query it completes quickly. It seems to be the fact that it's a stored procedure that's slowing it down...! Does anyone know what the problem might be? I've searched for answers, but often they recommend running

How to create spatial index using EF 6.1 fluent API

一曲冷凌霜 提交于 2019-11-30 19:55:58
Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API? Short answer- No, it is not. I have seen this tangentially referenced throughout blogs and have found no concrete examples of implementation. It seems to be related to the fact that spatial indexes are filtered indexes, which are not supported in Entity Framework. As support for my answer I constructed a POC console app with the most recent version of Entity Framework (6.1). I took the following steps Created a model that had a property of the type DbGeography Enabled automatic

SQL Server 2008 Performance on nullable geography column with spatial index

好久不见. 提交于 2019-11-30 18:54:55
问题 I'm seeing some strange performance issues on SQL Server 2008 with a nullable geography column with a spatial index. Each null value is stored as a root node within the spatial index. E.g. A table with 5 000 000 addresses where 4 000 000 has a coordinate stored. Every time I query the index I have to scan through every root node, meaning I have to scan through 1 000 001 level 0 nodes. (1 root node for all the valid coordinates + 1M nulls) I cannot find this mentioned in the documentation, and

Create SpatialPointsDataframe

不羁的心 提交于 2019-11-30 18:53:48
I have a dataframe df1 with 10 columns. Two of these columns are lng and lat . I want to create a SpatialPointsDataframe from df1 . When I read on how to create a SpatialPointsDataframe it feels like I have to create a matrix m1 from my two coordinates columns and then assign that matrix to the dataframe ´df1`. That would be a detour since my coordinates are already a column in my dataframe df1 . Furthermore, how do I assure that the coordinates from my matrix m1 are assign to the correct rows in my dataframe df1 ? thats how my df1 would look like > df1 a b c d e lat lng 1 12 f2 23 dd 2d 15.6

How to use Spatial Data Types in asp.net vnext with EF 7?

ぐ巨炮叔叔 提交于 2019-11-30 18:45:30
in vnext , using Entity Framework 7 ( https://github.com/aspnet/EntityFramework ) how to use Spatial Data types (e.g. DbGeography ) in model (code-first method) to save points, shapes etc. when creating model for a table. e.g. public DbGeography gps_points {get; set;} I'm unable to use DbGeography . Update: Confirmed, this feature is not yet available in EF7, but may be available in future versions. to track any changes see: https://github.com/aspnet/EntityFramework/issues/242 https://github.com/aspnet/EntityFramework/issues/1100 Referring to your own issue at the github repository of Entity

How can I find the pixel-wise standard deviation?

江枫思渺然 提交于 2019-11-30 18:33:41
问题 I have 20 rasters with same resolution and extent. It's a time series and each raster is for one year. And I want to calculate the pixel-wise standard deviation of all rasters.So far, I am using the raster package. qq2<-list(maxras1,maxras2,maxras3,maxras4,maxras5,maxras6,maxras7,maxras8,maxras9,maxras10) qq2stack<-stack(qq2) qq2mean<-mean(qq2stack) qq2sd<-sd(qq2stack) The mean works. But standard deviation is giving me this error: Error in as.double(x) : cannot coerce type 'S4' to vector of

Migrate SPATIAL data from Oracle to Postgresql

六月ゝ 毕业季﹏ 提交于 2019-11-30 15:24:36
I am trying my best to migrate a spatial database from Oracle to Postgresql and failing miserably. I have tried many different avenues as you can see from my previous question on here and none are working. Can someone please tell me of a relatively painless way of doing this as I am now clueless with it. I have tried using 3rd party software such as SwisSQL but this failed with a multitude of errors. I have tried creating files full of insert statements and then creating a C# program to parse these and replace the oracle spatial types with relevant postgis ones and that failed with an out of