[R-sig-Geo] Reordering geographical coordinates clockwise to make a polygon

Edzer Pebesma edzer@pebe@m@ @ending from uni-muen@ter@de
Mon Nov 5 19:25:59 CET 2018


Sorry for my previous answer, I didn't get the question fully.

I'm afraid I still don't get the question fully, but functions that
might help are sf::st_line_merge (creates a LINESTRING from line pieces)
and sf::st_polygonize (creates a polygon from a LINESTRING that forms a
closed ring)

On 11/5/18 5:35 PM, Patrick Giraudoux wrote:
> 
> Apologize to answer to myself: the way described below would work only 
> if there are no concave "peninsula" towards north or south inside the 
> polygon. Even thinking about an alternate solution, e.g. the Traveling 
> Salesman Problem (TSP), ie. the shortest route linking all points, one 
> could get wrong since points of  a narrowpeninsula could have points 
> closest to the opposite border than from the next point on the border...
> 
> Suppose we are stuck, and should redraw polygons by hand
> 
> 
> Le 05/11/2018 à 14:02, Patrick Giraudoux a écrit :
>>
>> Dear listers,
>>
>> There is an interesting post here: 
>> https://stackoverflow.com/questions/6989100/sort-points-in-clockwise-order 
>> dealing on the issue. However, I would like to know if a function has 
>> been already developped in a R package.
>>
>> I am coping with a young colleague's shapefile where borders of 
>> polygons have been drawn as lines quite inconsistently. To change this 
>> SpatialLinesDataFrame into a SpatialPoints object is easy. The idea is 
>> to  select the points  bordering each polygon (delete the others), 
>> define the point set as a Polygon, then rebuild step by step a 
>> SpatialPolygonsDataFrame with all its (~25) polygons. It would be much 
>> quicker than to redraw one by one the 5160 data points (two times on 
>> borders shared by two polygons).
>>
>> The problem is that the points must be reordered clockwise (the way 
>> lines making the  borders is all except clockwise) before making them 
>> a polygon.
>>
>> Any function already developped for that ?
>>
>> Cheers,
>>
>> Patrick
>>
>>
>>
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2472 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20181105/ad5df84e/attachment.bin>


More information about the R-sig-Geo mailing list