calculating multiple polyline distances within multiple polygons

140 views
Skip to first unread message

pdolo...@gmail.com

unread,
Jun 6, 2016, 4:24:44 PM6/6/16
to MapInfo-L
Allo.

I am relatively new to MapInfo and am having difficulties creating a SQL statement that will calculate the distance of multiple polylines within multiple polygons.  Nevertheless, I am able to write a statement which will yield totals for an individual polyline within a single polygon, but would rather not have to repeat this 400+ times. The snapshot below will offer a better reference at my intentions:



I have three layers: "green" polylines, "red" polylines and zip code boundaries.  I would like to extract footages for both the green and red polylines, but categorized by zip code - and for all zip codes.

Thanks in advance for any assistance.
GaryProjectCapture.PNG
Auto Generated Inline Image 1

Uffe Kousgaard

unread,
Jun 6, 2016, 5:26:21 PM6/6/16
to mapi...@googlegroups.com
Hi,

You would have to run SQL similar to this:

select ziptable.zip, sum(length(obj),"km")
from green_lines, ziptable
where green_lines.obj within ziptable.obj
group by ziptable.zip
order by ziptable.zip

If you replace "within" with "intersects", you will get a higher sum, because it will include more lines, also those where the centroid of the line may be outside of the zip code.

Repeat for "red_lines".

Regards
Uffe Kousgaard

pdolo...@gmail.com wrote:
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pdolo...@gmail.com

unread,
Jun 6, 2016, 6:48:08 PM6/6/16
to MapInfo-L
Thanks Uffe.
I will give it a try.

Ean

Peter Horsbøll Møller

unread,
Jun 7, 2016, 1:51:48 AM6/7/16
to mapi...@googlegroups.com

And if your lines cross the zip boundaries you might want to “split” them at the boundary so that you only measure the length of the line that actually lies within the zip area:

 

select ziptable.zip, sum(ObjectLen(Overlap(green_lines.obj, ziptable.obj),"km"))
from green_lines, ziptable
where green_lines.obj Intersects ziptable.obj


group by ziptable.zip
order by ziptable.zip

If you are working with projected data I would recommend using CartesianObjectLen in stead of ObjectLen.

 

Peter Horsbøll Møller

Pitney Bowes

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of pdolo...@gmail.com
Sent: 7. juni 2016 00:48
To: MapInfo-L <mapi...@googlegroups.com>
Subject: Re: [MI-L] calculating multiple polyline distances within multiple polygons

 

Thanks Uffe.
I will give it a try.

Ean

On Monday, June 6, 2016 at 4:26:21 PM UTC-5, Uffe Kousgaard wrote:

Hi,

You would have to run SQL similar to this:

select ziptable.zip, sum(length(obj),"km")
from green_lines, ziptable
where green_lines.obj within ziptable.obj
group by ziptable.zip
order by ziptable.zip

If you replace "within" with "intersects", you will get a higher sum, because it will include more lines, also those where the centroid of the line may be outside of the zip code.

Repeat for "red_lines".

Regards
Uffe Kousgaard

pdolo...@gmail.com wrote:

Allo.

I am relatively new to MapInfo and am having difficulties creating a SQL statement that will calculate the distance of multiple polylines within multiple polygons.  Nevertheless, I am able to write a statement which will yield totals for an individual polyline within a single polygon, but would rather not have to repeat this 400+ times. The snapshot below will offer a better reference at my intentions:

I would like to extract footages for both the green and red polylines, but categorized by zip code - and for all zip codes.

Reply all
Reply to author
Forward
0 new messages