background preloader

SQL Server

Facebook Twitter

Algorithm - Greatest linear dimension 2d set of points. Convex Hull Algorithms. Create a polygon without ConvexHull. By "more accurate" I assume you mean that you want to provide a "tighter" fit around the points.

Create a polygon without ConvexHull

However, it's not quite that simple... if anything, concave hulls are less accurate, less useful, (and more complicated) than convex hulls. The reason is that, for any given set of points, there is only one convex hull. As a result, STConvexHull() is a simple, repeatable function - it will always return the same shape when called on a given set of points. However, there may be many different possible concave hulls that you can create from a set of points. Consider the diagram below, which shows the (single) convex hull from a set of points, as well as just three of the possible concave hulls. There are algorithms that you can use to create concave hulls, but different algorithms will give different results and with many valid "correct" answers, which one do you choose? SQL Server Spatial Tools. Spatial Reference Identifiers (SRIDs) Each spatial instance has a spatial reference identifier (SRID).

Spatial Reference Identifiers (SRIDs)

The SRID corresponds to a spatial reference system based on the specific ellipsoid used for either flat-earth mapping or round-earth mapping. A spatial column can contain objects with different SRIDs. However, only spatial instances with the same SRID can be used when performing operations with SQL Server spatial data methods on your data. The result of any spatial method derived from two spatial data instances is valid only if those instances have the same SRID that is based on the same unit of measurement, datum, and projection used to determine the coordinates of the instances. The most common units of measurement of a SRID are meters or square meters. If two spatial instances do not have the same SRID, the results from a geometry or geography Data Type method used on the instances will return NULL.

Geometry1.STIntersects(geometry2) = 1. Reading and Writing Files in SQL Server using T-SQL. T-SQL stored procedures for reading and writing files can be hugely useful on those occasions where SQL Server’s standard techniques aren’t up to the task.

Reading and Writing Files in SQL Server using T-SQL

Phil Factor’s FileSystem Object (FSO)-based stored procedures may well help you out in a tight corner. For more techniques, see The TSQL of Text Files. SQL Server has never been short of ways to read from and write to files and it is always better to use the standard techniques provided by SQL Server where possible. However, most of them are really designed for reading and writing tabular data and aren't always trouble-free when used with large strings or relatively unstructured data. For reading tabular data from a file, whether character-delimited or binary, there is nothing that replaces the hoary old Bulk Copy Program (BCP), which underlies more esoteric methods such as Bulk Insert. Thankfully, when armed with OLE Automation and the FileSystem Object (FSO), all sorts of things are possible. Send e-mail attach all files in a folder.

Two possible approaches: 1.

Send e-mail attach all files in a folder

Use a foreach loop with a file enumerator, two variables (file and files), and a script task. Assign the file to the foreach loop's variable mapping, pass both values into the script task (file as readonly and files as readwrite), and update the files variable with: SQL Server - Learning Spatial stuff - Importing shapefiles in SQL Server database. OGR2OGR Patterns for SQL Server.

The Geospatial Data Abstraction Library (GDAL) is an open source library and set of tools for converting and manipulating spatial data.

OGR2OGR Patterns for SQL Server

While GDAL itself deals with raster data – GeoTIFFs, ECW, DEMs and the like – its sister project, OGR, deals with vector data formats such as ESRI Shapefiles, MapInfo, KML, or SQL Server geography/geometry data. The OGR2OGR utility is the specific GDAL/OGR component for transforming data between these different vector formats. GDAL/OGR is pretty powerful, offering many of the same features as commercial GIS software costing £’000s. However, the tools are not that easy to use, exposing only command-line interfaces which are pretty intolerant to any syntax errors. What’s more, many of the OGR2OGR code examples you’ll find on the internet focus on PostGIS as a backend database (for which support is more mature) rather than SQL Server, as I typically use. Installation General Notes. Google Earth Library.

Shape2SQL. Pop Rivett and the FTP directory. [dbo].

Pop Rivett and the FTP directory

[s_ftp_GetDir] GO then we'll need a very similar routine in order to get a file from a remote FTP{ site */ IF EXISTS ( SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo]. [s_ftp_GetFile]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1 ) DROP PROCEDURE [dbo]. [s_ftp_GetFile] GO.

SSIS