Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have lots of MultiPolylines, three-dimensional arrays where the bottom level is an array of lat/lngs, the second level is an array of those points (a single polyline), and the top level is the group of lines. Like this:

[
    [
        [50.12312,0.2541],
        [50.12322,0.2547],
        ...
    ],

        [52.412,1.142141],
        [51.9812,0.21237],
        ...
    ],
    ...
]

The polylines in each group are generally contiguous, and I would like to merge them so that connecting lines within a group become a single line. How can I do this programmatically without some sort of desktop software? Is there Python,PHP,JavaScript,etc. code out there for this task or do I have to write it from scratch?

share|improve this question
    
Do you have PostGIS somewhere in the stack ? if so st_linemerge or ST_CollectionHomogenize are helpful functions. –  simplexio Apr 8 '13 at 7:23

3 Answers 3

Merge overlapping should work, you would want to run on a vector layer or shapefile. ESRI has the tool, QGIS should have the tool, or you could look at the code and whip something up if you have time on your hands. You could try merge and dissolve operations as well depending on the sequence of proceedures. Try ArcGIS documentation to research the scope of your problem and range of possible options, and would likely apply to open source packages, conceptualy.

share|improve this answer

where you get this data? file , database or webservice ?

What i would do : Upload data to postgis , fix it there and use it from there.

If you want to create your own code then there is JTS for JAVA, Pysal for Python etc.

share|improve this answer

The Shapely Python Package can merge linear features. Look at method shapely.ops.linemerge(lines). It merges all contiguous elements of lines.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.