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.

Additional info - I don't need this to be on a map - I just need the shape of the route. Is there anything that can return that shape easily?

The list of coordinates are in an xml document and I'd like to be able to update that XML when I'm heading to a new location. Thoughts?

Edit 1: Thanks for the comment! here's the structure below:

<shape>
               <element>42.18462</element>
               <element>-88.63731</element>
               <element>42.18557</element>
               <element>-88.64003</element>
               <element>42.18853</element>
               <element>-88.64849</element>
               <element>42.19017</element>
               <element>-88.65314</element>
               <element>42.19106</element>
               <element>-88.65573</element>
</shape>

Thanks for any thoughts!

Edit 2: One more option -- I can get this as WKID coordinates as well:

<Shape>41.8857613,-87.6230011 41.8857689,-87.6222992 41.8851204,-87.6222916 41.8844986,-87.6222687 41.8844604,-87.6239014 41.8844604,-87.6244278 41.8844604,-87.6251984 41.8844604,-87.6253281 41.8844604,-87.6262283 41.8844604,-87.6264114 41.884491,-87.6279068 41.8844719,-87.6294632 41.8844795,-87.6309204 41.8844719,-87.6316833 </shape>
share|improve this question
    
Can you post the structure of the XML data? It will help people answer your question. –  sgrieve Nov 12 '12 at 14:51
3  
There are probably many ways of doing this. What software are you using? Is your route to be integrated in a website, in a GIS program (such as QGis or PostGis) or a statistical program such as R? –  yellowcap Nov 12 '12 at 15:13

3 Answers 3

You would need the relationship between the point, i.e. order of sequence or you need to manualy connect the dots, as it were, in an editor.

share|improve this answer

This task can be completed in many ways, so here is one which I would use in your situation. Assuming that the XML data is not too complex I would parse the data into an x list and a y list (and lists for any other attributes you may have) using python, and then write the data to a shapefile using the standalone module pyshp. I have written a bit about using this module on my blog, and it would be very simple to convert the coordinates into either a series of waypoints, or into a polyline. This script could then be executed every time the XML file was updated.

This code takes comma delimited data from a text file and creates a series of polylines using the end point of a line as the start point of the next line, it can obviously be refined based on your actual data.

import shapefile as shp

out_file = 'output.shp'
x = y = []

#read csv file
with open('data.csv','r') as f:
    lines = f.readlines()

#splitting out comma delimited data from each line
for i,line in enumerate(lines):
    if i > 0: #skip csv header
        x.append(float(line.strip('\n').split(',')[1]))
        y.append(float(line.strip('\n').split(',')[2]))

#Set up shapefile writer and create empty fields
w = shp.Writer(shp.POLYLINE)
w.field('Name','C',20) #Character Field

#Write data
for i,j in enumerate(x):
   if i < len(x) - 1:
        w.poly([[ [x[i], y[i]], [x[i+1], y[i+1]] ]], shapeType=shp.POLYLINE)
        w.record('Line '+str(i))

#Save shapefile
w.save(out_file)

Clearly my input data is in a different format to yours and trying to parse XML can be a pain, so I would recommend using Beautiful Soup, which can parse the data out of markup really easily, and will save you a lot of misery in the long run.

The benefit of using such an approach, in my opinion, is that you are not tied to a GIS, but will still be creating data in a common GIS format, allowing much more portability than using a tool to convert the data to csv and then loading it into ArcGIS et al.

share|improve this answer

if you are searching ready-to-use solutions, you can check out OpenStreetMap Track drawing websites here and here for online routers.

route

if not, you can use openlayers to connect your point for routing with reading it OpenLayers.Format.XML(); . beside this you should check out pyroute for mobile apps.

actually, you have lots of choice for drawing route. first of all you have to decide what you want.drawing route with apps or online routers. for another online routers is here - Draw a Route on the map, save as GPX- or KML-file. it can help you, if you can convert your data to GPX Route Data or Kml Route Data.

i hope it helps you...

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.