Writing and editing a GIS shape file

Writing and editing GIS files through Python can be used to generate shape files for the Mineral Rights plugin. This script to create a .shp file from scratch is attached at the bottom of this page.

First, create a set of points.

The first point and the last points must match.

The two keys names must be "X" and "Y".

data = TraverseData("test", "X", "Y")
data.addPoint(3636766.83, 708415.7)
data.addPoint(3652222.08, 774496.82)
data.addPoint(3633203.43, 706684.87)
data.addPoint(3636766.83, 708415.7)

Assign a coordinate reference system to that set

In the example below, "32040" is the EPSG code of "NAD27 Texas South Central" and "unknown" indicates that the WGS84 transform is not known.

There is no need to specify the WGS84 transform if all points are in a NADCON or NTV2 area.

coordinateSystem = CoordinateSystem("32040:unknown")
data.setCoordinateSystem(coordinateSystem)

Then write the shape file to disk

writer = TraverseDataWriter(data)
writer.writeInBackground('C:\\Data\\test.shp')

Once the script has finished executing, the following notification should appear:

To load a set of points from file

Use the following file format as a template. This file is attached at the bottom of this page.

<?xml version="1.0"?>
<Polyline>
 <Keys>
  <Key name="X"/>
  <Key name="Y"/>
 </Keys>
<Point X="3636766.83" Y="708415.7"/>
<Point X="3652222.08" Y="774496.82"/>
<Point X="3633203.43" Y="706684.87"/>
<Point X="3636766.83" Y="708415.7"/>
</Polyline>

Make sure to give the ".xpl" extension to this file. Example: test.xpl

Then change the first 5 lines of your script to just one line:

data = TraverseData('C:\\Data\\test.xpl')

Setting Features

As part of the Mineral Rights plugin, you need to set features that will be used to control depth intervals.

Use the following "feature" script as a template. This script is attached at the bottom of this page.

Making the "feature" script contextual

To execute this script from the "File Explorer" window, place it in a Contextual_GIS_Data_Node folder

Remove the first line of the script. The "data" variable will be populated automatically when the script is called from a contextual menu.

Reference the root folder of your Python scripts in Tools->Options->Environment->Paths

Go to Tools->Options->Environment->Python Scripts (or Tools->Options->Python->Scripts in INTViewer 5.2) and click "Refresh from Disk". Your script should be listed automatically.

Open the Window->File Explorer window. Locate your shape file and right-click its node to launch the script.

The same principle can be applied to convert a.xpl file into a .shp file. In this case, the folder name would be Contextual_Polyline_Data_Node.