I am a complete newb at this stuff and don't know what I don't know. I may use incorrect language.

Essentially, I want to convert the shapes in a Microsoft Visio diagram into a shapefile. I pretty much want the diagram to BECOME a shapefile.

I have a csv file which describes 10-15 arbitrary polygons from that Visio diagram:

ShapeNo ShapeName PointNo   X    Y
1       My Square   2       37  155
1       My Square   4       116 155
1       My Square   6       116 234
1       My Square   8       37  234
1       My Square   10      37  155

Polygons are going to be squares, rectangles, with the occasional circle/oval. I'll generate the file above with a script which exports each point of each shape in the diagram. Part and parcel of the X/Y info is the relation of each shape to the others.

I'm hoping QGIS can take this information and essentially create a shapefile for me based on some arbitrary lat/lon "center".

Can this be done? If so, a push in the right direction (articles, keywords, walk-throughs) would be really appreciated.

  • Welcome @Russell Christopher no appologies needed. Just ask away and always mark the right answer (for you).
    – Brad Nesom
    Jun 6, 2012 at 13:59
  • 1
    How much flexibility do you have with your script? Can you generate any kind of output you need? i.e could you generate something like this for each object en.wikipedia.org/wiki/Well-known_text
    – Nathan W
    Jun 6, 2012 at 14:03
  • 1
    @NathanW I certainly could modify the script to export something like POLYGON ((37 155, 116 155, 116 134, 37 234, 37,155)) per shape instead of the format above. What would that buy me? Jun 6, 2012 at 14:35
  • What is the purpose for having to convert your diagram objects into shapefile polygons. The purpose of GIS is to represent information in a spatial manner. Does your diagram have a spatial component to it, that is, does it represent/describe a point or area on the earths surface.
    – dchaboya
    Jun 6, 2012 at 18:24
  • @dchaboya Long story, but in essence I need to display a Business Intelligence "Strategy Map" (map != GIS in this case) that behaves in a particular way when a user interacts with it. The tool I'll be using (Tableau) will give me that "particular way" if what I'm showing is geospatial. Therefore, I need to turn these shapes into something that is mappable so I can get the visual behavior my users need. Clear as mud, most likely. Jun 6, 2012 at 19:17

3 Answers 3


Russel gave you answer. Make WKT file (well known text). Its that easy.

POLYGON ((268 597, 268 721, 401 721, 401 597, 268 597)) POLYGON ((623 720, 485 485, 720 395, 840 664, 623 720))

Save this in standard 'test.txt' file. I am not sure if you can find a python script online to make a shapefile from this.Are you good with python script? I am pasting a code below. May be this will help.

imports are same standard ones that i always import, and i dont know how to post a python code because you might have indentation issues. Good luck.

#-- general import
import os
import sys

#-- OGR 
    from osgeo import ogr
except ImportError:
    import ogr
#-- Shapely
from shapely.wkb import loads as wkbloads
from shapely.wkt import loads as wktloads
from shapely.geometry import Polygon
from shapely.geometry import LineString
from shapely.geometry import MultiPoint

from shapely.geos import lgeos


def main():
  print "test.txt"
  fIn = open(INFILE)

  for line in fIn.readlines():
    print geom


def write_shapefile(lsFeat, outfile):

    driver = ogr.GetDriverByName('ESRI Shapefile') #-- we create a new SHP file
    if os.path.exists(outfile):
            driver.DeleteDataSource(outfile) #-- if it exists, overwrite it
    ds = driver.CreateDataSource(outfile)
    layer = ds.CreateLayer(outfile, geom_type=ogr.wkbPolygon) #-- we create a SHP with polygons


if __name__ == "__main__":

I see you can export Visio Shapes (file, save as) to a .dxf (AutoCAD exchange file). Most GIS packages will import dxf.


I link you to this question because it does show some of the diversity in the answer.
Probably not for you.
Points to Polygons

csv to shapefile might be more in-line with what you are looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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