How to extract the coordinates of a parcel in gvSIG

We can get the coordinates of the vertexes of one or more parcels in an easy way in gvSIG through scripting.

We can do it on SHP files as well as DWG, DGN or DXF.


For that we will have to create a new script in gvSIG, from the Tools->Scripting->Scripting Composer menu.

Once it is created, naming it as we want, we copy this source code on it:

from gvsig import *
from commonsdialog import *

def main(*args):
    """Read wkt"""
    sel = currentLayer().getSelection()
    pfile = str(saveFileDialog("Select output text file")[0])
    f = open(pfile,'w')
    for s in sel:
        g = str(s.geometry().convertToWKT())
    print pfile

After that we save the script.

Now, on the gvSIG View, we select the parcel/s that we want, and we open the Scripting Launcher (Tools->Scripting->Scripting Launcher menu).

We press with double-click on the Script that we had created, and a new window will be opened, where we can select the output file that will contain the coordinates, and the folder (it is recommendable to name it as a .txt in order to be recognized by the text editor easily).

If we open that file later, we will be able to see the coordinates of the different vertexes of the parcel, and if it was a polyline we can see the coordinates of each line that forms it.

If we had selected several elements, they will be visualized separately at the same file.

At the first line the values of the different fields of that register will be shown. It will allow us to know which element the information is referring to, in case we had selected several parcels.

We hope that this tool is useful for you!

This entry was posted in CAD, english, gvSIG Desktop and tagged . Bookmark the permalink.

One Response to How to extract the coordinates of a parcel in gvSIG

  1. Mark Spence says:

    I like it but query over the “legality” of doing so on commercially sourced data? I’m not an expert on the legal side but I wouldn’t be surprised if doing such infringed the data licencing terms.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s