Hi Saqib,
How about the following steps - this will create approximate centrelines. That is, they won't be perfectly placed an equidistance from each side of the road or footpath. You will need to ensure you are running the "MapCad" MapBasic Tool Add In, which will provide the required tools under the "Spatial" tab.
- Ensure your polygons have a unique ID
- Convert to lines
- Identify end lines based on their short length, and delete. Prior to deletion, you might be able to double-check that you have selected the right lines by ensuring they intersect with a neighbouring polygon. This double-check won't work in all cases, however.
- Delete the lines on one side of the road. This can be done by differentiating lines based on their direction of travel. The following selects lines travelling north to south: Select * from road_poly_test where ObjectGeography(obj, OBJ_GEO_LINEENDY) - ObjectGeography(obj, OBJ_GEO_LINEBEGY) <=0 into NorthSouthLinesOnce these are selected, delete them from the table.
- Combine Using Column - combine lines based on your unique ID column, storing results in a new table. You'll probably want to use the "Value" method for the aggregation.
- Create parallel lines. You will not know which side the parallel lines are to be placed, so choose the "both sides" option. Also choose the "Delete source object" option. Hopefully you can choose an appropriate distance based on the average width of the original polygons.
- Compare the results to the original polygons – select all lines that are not within a polygon and delete:
First, select all within an original polygon:
Select * from road_poly_test As "l", road_casement_polygon As "p" where str$(l.obj)="line" And l.obj within p.obj Into insideLines
Then invert the selection:
And delete. Result:
- Clean up your results:
Examples:
Check for lines that are made of multiple segments – these will have gaps that need to be fixed. These might have occurred at Step 3, where small lines were deleted.
Check for polygons that do not contain a road centreline, or contain more than one road centreline.
------------------------------
James Nolet
GIS Manager
Caf Consulting
Mentone office, VIC, Australia
------------------------------
Original Message:
Sent: 07-31-2024 08:20
From: Saqib Amin
Subject: Line in the middle of Polygon
Hi All,
I have a dataset which has multiple polygons, I have been asked to represent the same dataset as a line dataset. Basically it's polygons of various roads and footpaths.
I don't have FME, is there a way I can create a centre line in the middle of the polygon from start to end?
Many thanks,
Saqib
------------------------------
Saqib Amin
------------------------------