Find the length of a bounding rectangle polygonCalculating distance between two points (Latitude, Longitude)Calculate Convex Hull of points from a set of (lat/long) pointsFinding duplicate values in a SQL tableHow do I view the full content of a text or varchar(MAX) column in SQL Server 2008 Management Studio?Select statement to find duplicates on certain fieldsFind all tables containing column with specified name - MS SQL ServerHow to change default database from SQL Server 2005 to SQL Server 2008Sql Server spatial data type Geometry, STDistance and units : Get meters?SQL query finding entries that lies close to each otherFind distance between two latitude and longitude in SQL querySQL Server spatial feature: .STDistance Does it return miles or meters?Can you execute WHERE clauses in a PostgreSQL stored procedure IF clause?

Female=gender counterpart?

Partial sums of primes

Did US corporations pay demonstrators in the German demonstrations against article 13?

Pronouncing Homer as in modern Greek

What if somebody invests in my application?

Can I rely on these GitHub repository files?

Why are on-board computers allowed to change controls without notifying the pilots?

Lifted its hind leg on or lifted its hind leg towards?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

Why does this part of the Space Shuttle launch pad seem to be floating in air?

How can I successfully establish a nationwide combat training program for a large country?

Lightning Web Component - do I need to track changes for every single input field in a form

How to prevent YouTube from showing already watched videos?

For airliners, what prevents wing strikes on landing in bad weather?

Is exact Kanji stroke length important?

Could solar power be utilized and substitute coal in the 19th century?

Do all polymers contain either carbon or silicon?

Have I saved too much for retirement so far?

Teaching indefinite integrals that require special-casing

Is there enough fresh water in the world to eradicate the drinking water crisis?

Is a naturally all "male" species possible?

What does the "3am" section means in manpages?

Perfect riffle shuffles

The most efficient algorithm to find all possible integer pairs which sum to a given integer



Find the length of a bounding rectangle polygon


Calculating distance between two points (Latitude, Longitude)Calculate Convex Hull of points from a set of (lat/long) pointsFinding duplicate values in a SQL tableHow do I view the full content of a text or varchar(MAX) column in SQL Server 2008 Management Studio?Select statement to find duplicates on certain fieldsFind all tables containing column with specified name - MS SQL ServerHow to change default database from SQL Server 2005 to SQL Server 2008Sql Server spatial data type Geometry, STDistance and units : Get meters?SQL query finding entries that lies close to each otherFind distance between two latitude and longitude in SQL querySQL Server spatial feature: .STDistance Does it return miles or meters?Can you execute WHERE clauses in a PostgreSQL stored procedure IF clause?













0















I manage a sql express database (using v17.9.1 SSMS) containing animal records (species names with geographic coords). The names and locations of species are changing frequently and I want to use SSMS to calculate the maximum linear distance for all species (in kilometres). I can do this manually in ArcMap by creating minimum bounding rectangles grouped by species name, changing the CRS to projected and calculating the lengths of the rectangles in metres, but this is done separately to the database and will not changed when the database is changed. I recently discovered geometry and geography data types and spatial functions like convexhullaggregate in sql express, which leads to believe I can do this in sql express.



The answer might lie in the answer to this question Calculate Convex Hull of points from a set of (lat/long) points, but I need some help getting it to work and am unsure if this is the right path to follow. I think it makes more sense to create a rectangle around a set of points because finding the longest edge of a rectangle should be straightforward. Anyway, here is my progress using the above example, starting with the geometry coordinates field 'position' and a field from the same table '_fldProjectID' that I will later substitute for the species name field (which lives in another table):



with cte as (
SELECT _fldProjectID, geometry::ConvexHullAggregate(position) AS Hull
FROM tblsite
where position is not null
group by _fldProjectID
)
select _fldProjectID, Number, Edge.Long as Long, Edge.Lat as Lat
from cte
cross apply (
select Number, Hull.STPointN(Number) as Edge
from dbadmin.dbo.Numbers
where Number < Hull.STNumPoints()
) as HullEdges


Currently, SSMS does not recognise 'Edge' and 'Number', and I am unsure what to replace 'dbadmin.dbo.numbers' with. After this I can see many examples on how to calculate the distance using STDistance, e.g. Calculating distance between two points (Latitude, Longitude)



Hope someone can help,



Mike










share|improve this question
























  • Hey! As the author of the linked to answer, I can tell you that dbadmin.dbo.Numbers is just a numbers table (also called a "tally table"). There are a lot of methods for making one, a lot of them collected at sqlservercentral.com/blogs/dwainsql/2014/03/27/…. One note here is that a convex hull probably won't be a rectangle (or even a regular polygon). So if that's a requirement, this approach probably won't get you what you're looking for.

    – Ben Thul
    Mar 8 at 17:19















0















I manage a sql express database (using v17.9.1 SSMS) containing animal records (species names with geographic coords). The names and locations of species are changing frequently and I want to use SSMS to calculate the maximum linear distance for all species (in kilometres). I can do this manually in ArcMap by creating minimum bounding rectangles grouped by species name, changing the CRS to projected and calculating the lengths of the rectangles in metres, but this is done separately to the database and will not changed when the database is changed. I recently discovered geometry and geography data types and spatial functions like convexhullaggregate in sql express, which leads to believe I can do this in sql express.



The answer might lie in the answer to this question Calculate Convex Hull of points from a set of (lat/long) points, but I need some help getting it to work and am unsure if this is the right path to follow. I think it makes more sense to create a rectangle around a set of points because finding the longest edge of a rectangle should be straightforward. Anyway, here is my progress using the above example, starting with the geometry coordinates field 'position' and a field from the same table '_fldProjectID' that I will later substitute for the species name field (which lives in another table):



with cte as (
SELECT _fldProjectID, geometry::ConvexHullAggregate(position) AS Hull
FROM tblsite
where position is not null
group by _fldProjectID
)
select _fldProjectID, Number, Edge.Long as Long, Edge.Lat as Lat
from cte
cross apply (
select Number, Hull.STPointN(Number) as Edge
from dbadmin.dbo.Numbers
where Number < Hull.STNumPoints()
) as HullEdges


Currently, SSMS does not recognise 'Edge' and 'Number', and I am unsure what to replace 'dbadmin.dbo.numbers' with. After this I can see many examples on how to calculate the distance using STDistance, e.g. Calculating distance between two points (Latitude, Longitude)



Hope someone can help,



Mike










share|improve this question
























  • Hey! As the author of the linked to answer, I can tell you that dbadmin.dbo.Numbers is just a numbers table (also called a "tally table"). There are a lot of methods for making one, a lot of them collected at sqlservercentral.com/blogs/dwainsql/2014/03/27/…. One note here is that a convex hull probably won't be a rectangle (or even a regular polygon). So if that's a requirement, this approach probably won't get you what you're looking for.

    – Ben Thul
    Mar 8 at 17:19













0












0








0








I manage a sql express database (using v17.9.1 SSMS) containing animal records (species names with geographic coords). The names and locations of species are changing frequently and I want to use SSMS to calculate the maximum linear distance for all species (in kilometres). I can do this manually in ArcMap by creating minimum bounding rectangles grouped by species name, changing the CRS to projected and calculating the lengths of the rectangles in metres, but this is done separately to the database and will not changed when the database is changed. I recently discovered geometry and geography data types and spatial functions like convexhullaggregate in sql express, which leads to believe I can do this in sql express.



The answer might lie in the answer to this question Calculate Convex Hull of points from a set of (lat/long) points, but I need some help getting it to work and am unsure if this is the right path to follow. I think it makes more sense to create a rectangle around a set of points because finding the longest edge of a rectangle should be straightforward. Anyway, here is my progress using the above example, starting with the geometry coordinates field 'position' and a field from the same table '_fldProjectID' that I will later substitute for the species name field (which lives in another table):



with cte as (
SELECT _fldProjectID, geometry::ConvexHullAggregate(position) AS Hull
FROM tblsite
where position is not null
group by _fldProjectID
)
select _fldProjectID, Number, Edge.Long as Long, Edge.Lat as Lat
from cte
cross apply (
select Number, Hull.STPointN(Number) as Edge
from dbadmin.dbo.Numbers
where Number < Hull.STNumPoints()
) as HullEdges


Currently, SSMS does not recognise 'Edge' and 'Number', and I am unsure what to replace 'dbadmin.dbo.numbers' with. After this I can see many examples on how to calculate the distance using STDistance, e.g. Calculating distance between two points (Latitude, Longitude)



Hope someone can help,



Mike










share|improve this question
















I manage a sql express database (using v17.9.1 SSMS) containing animal records (species names with geographic coords). The names and locations of species are changing frequently and I want to use SSMS to calculate the maximum linear distance for all species (in kilometres). I can do this manually in ArcMap by creating minimum bounding rectangles grouped by species name, changing the CRS to projected and calculating the lengths of the rectangles in metres, but this is done separately to the database and will not changed when the database is changed. I recently discovered geometry and geography data types and spatial functions like convexhullaggregate in sql express, which leads to believe I can do this in sql express.



The answer might lie in the answer to this question Calculate Convex Hull of points from a set of (lat/long) points, but I need some help getting it to work and am unsure if this is the right path to follow. I think it makes more sense to create a rectangle around a set of points because finding the longest edge of a rectangle should be straightforward. Anyway, here is my progress using the above example, starting with the geometry coordinates field 'position' and a field from the same table '_fldProjectID' that I will later substitute for the species name field (which lives in another table):



with cte as (
SELECT _fldProjectID, geometry::ConvexHullAggregate(position) AS Hull
FROM tblsite
where position is not null
group by _fldProjectID
)
select _fldProjectID, Number, Edge.Long as Long, Edge.Lat as Lat
from cte
cross apply (
select Number, Hull.STPointN(Number) as Edge
from dbadmin.dbo.Numbers
where Number < Hull.STNumPoints()
) as HullEdges


Currently, SSMS does not recognise 'Edge' and 'Number', and I am unsure what to replace 'dbadmin.dbo.numbers' with. After this I can see many examples on how to calculate the distance using STDistance, e.g. Calculating distance between two points (Latitude, Longitude)



Hope someone can help,



Mike







sql sql-server ssms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 8:16









jarlh

29.8k52138




29.8k52138










asked Mar 8 at 8:13









MikeMike

1




1












  • Hey! As the author of the linked to answer, I can tell you that dbadmin.dbo.Numbers is just a numbers table (also called a "tally table"). There are a lot of methods for making one, a lot of them collected at sqlservercentral.com/blogs/dwainsql/2014/03/27/…. One note here is that a convex hull probably won't be a rectangle (or even a regular polygon). So if that's a requirement, this approach probably won't get you what you're looking for.

    – Ben Thul
    Mar 8 at 17:19

















  • Hey! As the author of the linked to answer, I can tell you that dbadmin.dbo.Numbers is just a numbers table (also called a "tally table"). There are a lot of methods for making one, a lot of them collected at sqlservercentral.com/blogs/dwainsql/2014/03/27/…. One note here is that a convex hull probably won't be a rectangle (or even a regular polygon). So if that's a requirement, this approach probably won't get you what you're looking for.

    – Ben Thul
    Mar 8 at 17:19
















Hey! As the author of the linked to answer, I can tell you that dbadmin.dbo.Numbers is just a numbers table (also called a "tally table"). There are a lot of methods for making one, a lot of them collected at sqlservercentral.com/blogs/dwainsql/2014/03/27/…. One note here is that a convex hull probably won't be a rectangle (or even a regular polygon). So if that's a requirement, this approach probably won't get you what you're looking for.

– Ben Thul
Mar 8 at 17:19





Hey! As the author of the linked to answer, I can tell you that dbadmin.dbo.Numbers is just a numbers table (also called a "tally table"). There are a lot of methods for making one, a lot of them collected at sqlservercentral.com/blogs/dwainsql/2014/03/27/…. One note here is that a convex hull probably won't be a rectangle (or even a regular polygon). So if that's a requirement, this approach probably won't get you what you're looking for.

– Ben Thul
Mar 8 at 17:19












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059110%2ffind-the-length-of-a-bounding-rectangle-polygon%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059110%2ffind-the-length-of-a-bounding-rectangle-polygon%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme