Do we need spatial index for point type geometry in SQL Server?
If yes, how Tessellation and grid selections work in point type geometry?
Related
Does snowflake support geometry data type, which is used in SQL server? i only see geography data type in snowflake, whether same data from sql server to snowflake can be stored from geometry data type to geography data type column?
Snowflake supports only GEOGRAPHY data type. It's different than geometry data so you can not store them directly but you can try to convert it on SQL Server:
https://social.msdn.microsoft.com/Forums/en-US/a17a9320-8360-4497-942a-c3cbcec1d4cf/how-to-convert-geometry-to-geography-?forum=sqlspatial
Snowflake support GEOMETRY data type:
The GEOMETRY data type represents features in a planar (Euclidean, Cartesian) coordinate system.
The coordinates are represented as pairs of real numbers (x, y). Currently, only 2D coordinates are supported.
The units of the X and Y are determined by the spatial reference system (SRS) associated with the GEOMETRY object. The spatial reference system is identified by the spatial reference system identifier (SRID) number. Unless the SRID is provided when creating the GEOMETRY object or by calling ST_SETSRID, the SRID is 0.
I am selecting a number of Geometry types from a SQL server database; when I reduce, I am having issues getting the most reduction without my polygons collapsing in on each other.
Select
Polygon.Reduce(#reduceAmount).ToString()
FROM
PolygonTable
Is there way to reduce to a specific type of Geometry (like a polygon)?
I need some help, I have a stored procedure(SP) that contains NO parameters in SSMS. The SP generates spatial data by joining 2 tables one table containing two fields needed for labelling purposes and the other from a table that containsthe GEO field.
This SP populates spatial data in SSMS which I can view and interact with. All seems well so far...
I then use SSRS to create a data source and a dataset of the said stored procedure. Following this I create a new .rdl and insert a map choosing SQL Server spatial query as the source then selecting the stored procedure dataset. Following this SSRS attempts to join the data and I then receive the error from the Microsoft SQL Server Report Designer:
Unable to determine the spatial data type in the specified dataset field: GEO
I have searched the the internet for answers already and none suit predominately because they all refer to parameters causing the issue however my query does not contain nor pass any. I have tried the geo field as both a geography and geometry datatype no avail.
Any help or advice would be great.
I have just been playing with a Heat Map in SSRS using SQL Jason's example (http://www.sqljason.com/2012/03/heat-maps-for-ssrs-using-map-control.html).
It looks like your data doesn't have enough points. According to Teo Lachev (http://prologika.com/CS/blogs/blog/archive/2009/08/30/heat-maps-as-reports.aspx):
SQL Server describes polygons in Well-Known Text (WKT) standard
sponsored by Open Geospatial Consortium. For instance, a polygon is
described as five (surprise) points on the coordinate system, as
shown below. The fifth point is the same as the first point.
The example format you gave only had four points. The first and last are the same so there seems to be a missing point or you are not graphing rectangles. It doesn't look like the Spatial Data supports any other shapes. The Map wizard only shows rectangles in the Wizard when creating the map.
I want to know how to convert a SQL database in to SQL spatial db.
I have a SQL database "Register" which contains some tables as cables, components, etc. How can I make this database Spatial database.
Can somebody help me with how to do it?
I forgot to say that the database is SQL Server 2008, version 10.50.1600.1
I'm trying to find a description on the Internet, how to do it, but unfortunately I can not find.
If your asking how to convert latitude and longitude coordinates into spatial data, Sql server 2008 has functions like STGeomFromText that can be utilized like
INSERT INTO SpatialTable (GeogCol1)
VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));
GO
Or if you want to add a spatial column, you could use a computed column and add
geography::STGeomFromText('Point('+LongitudeColumn+' '+LatitudeColumn+')', 4326)
to the default value. This would work well for a spatial point. If you needed to do more complex shapes like polygons and polylines, I would suggest searhing here and here
It would be great to know what types of spatial data are you looking to store in your "spatial" database. Point (cities as an example), line (streets), polygons (sales areas) . Nothing makes a database spatial but tables that contain geometry and geography datatype fields make tables spatial. Create a table with a field of datatype geometry or geography and think about what you want to store in it (Points, Lines, Polygons) is a good start.
I have a Microsoft SQL Server database with a table of Locations. Each location has its address and latitude and longitude coordinates.
In my application, the user can input a zipcode and we return a list of close by locations.
This is my approach.
a) Using a zipcode DB I search the lat,lon for the zipcode (this is the center point).
b) I run a search like this
SELECT Position_ID, distance(pos_lon,pos_lat,zip_lon,zip_lat) dist
FROM Positions
ORDER BY dist
"distance" is a function that calculates the distance between two points.
The problem is that as my location DB increases the time to run these searches is starting to grow.
Is there a better approach?
If you're using SQL Server 2008, you probably want to look into the geography column type, the STDistance function and spatial indexes.
Spatial Indexing Overview
Geography Methods Supported by Spatial Indexes
How to: Create a Spatial Index
I would do a calculation of the box surrounding your zip code at the specified distance to get the lat/lon values for the four corners. Then do a simple comparison of your position values to select those which fall inside the square. This way, you don't have to calculate the distance from your zip code to every point in your db for every search.
Which version of SQL server? If 2008 have a look at the spatial type.
http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx
EDIT: Also limiting that query with a where would probably help as you likely don't want to go to far in any particular direction.