User Tools

Site Tools


guides:snippets

Table of Contents

API Snippets

Documentation | API Snippets

This is a practical quick-reference covering 50 of the most common GIS operations in the DK API. Each snippet is shown in five languages side by side — C#, VB.NET, Delphi, Java, and Python — making it easy to compare idioms or port code between platforms. The collection is organized into eight areas: getting started (opening files, batch updates), layer management (creating, styling, and removing layers), viewport and navigation (zoom, coordinate conversion, mouse events), coordinate systems (EPSG assignment, reprojection, unit formatting), reading and querying vector data (iteration, SQL filters, spatial relationships via DE-9IM, hit testing), creating and editing vector data (shapes, attributes, interactive editor), geometry and spatial analysis (buffers, geodetic area/length, affine transforms, import), and raster and analysis (raster layers, IDW interpolation). The snippets were generated from DK sample applications with the assistance of Claude Haiku AI and may occasionally contain minor inaccuracies. Always cross-check against the linked API reference pages when in doubt.

API reference links follow each snippet description. Labels: .NET/VB covers both C# and VB.NET (same assemblies) · Delphi VCL / FMX are separate only for the viewer control, all other Delphi classes share one page · AX = ActiveX · Py = Python.

Namespace / import preamble (assumed for all snippets):

Language Required imports
C# using TatukGIS.NDK; using TatukGIS.NDK.WinForms;
VB.NET Imports TatukGIS.NDK : Imports TatukGIS.NDK.WinForms
Delphi uses VCL.GisViewerWnd, GisLayerVector, GisTypes, GisTypesUI, GisUtils;
Java import tatukgis.jdk.*; import tatukgis.rtl.TPoint;
Python import tatukgis_pdk as pdk

GIS refers to a TGIS_ViewerWnd instance placed on the form/window.

Getting Started

Open a project or layer file

GIS.Open() accepts project files (.ttkgp), shapefiles, raster files, and many other formats. The viewer auto-zooms to full extent after loading.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_Utils: .NET/VB · Delphi · Java · AX · Py

C#

GIS.Open(TGIS_Utils.GisSamplesDataDirDownload() + @"World\WorldDCW\world.shp");

VB.NET

GIS.Open(TGIS_Utils.GisSamplesDataDirDownload() & "World\WorldDCW\world.shp")

Delphi

GIS.Open(TGIS_Utils.GisSamplesDataDirDownload() + '\World\WorldDCW\world.shp');

Java

GIS.Open(TGIS_Utils.GisSamplesDataDirDownload() + "/World/WorldDCW/world.shp");

Python

GIS.Open(pdk.TGIS_Utils.GisSamplesDataDirDownload() + "/World/WorldDCW/world.shp")

Add a layer using the factory method

TGIS_Utils.GisCreateLayer() auto-detects the format from the file extension and returns the correct layer subclass. Prefer this over constructing layer types directly.

→ API: TGIS_Utils: .NET/VB · Delphi · Java · AX · Py
TGIS_LayerAbstract: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_LayerAbstract layer = TGIS_Utils.GisCreateLayer("countries", @"C:\data\countries.shp");
GIS.Add(layer);
GIS.FullExtent();

VB.NET

Dim layer As TGIS_LayerAbstract = TGIS_Utils.GisCreateLayer("countries", "C:\data\countries.shp")
GIS.Add(layer)
GIS.FullExtent()

Delphi

var layer := TGIS_Utils.GisCreateLayer('countries', 'C:\data\countries.shp');
GIS.Add(layer);
GIS.FullExtent;

Java

TGIS_LayerAbstract layer = TGIS_Utils.GisCreateLayer("countries", "C:/data/countries.shp");
GIS.Add(layer);
GIS.FullExtent();

Python

layer = pdk.TGIS_Utils.GisCreateLayer("countries", "C:/data/countries.shp")
GIS.Add(layer)
GIS.FullExtent()

Zoom the viewer to show all loaded layers.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py

C#

GIS.FullExtent();

VB.NET

GIS.FullExtent()

Delphi

GIS.FullExtent;

Java

GIS.FullExtent();

Python

GIS.FullExtent()

Lock and Unlock batch updates

Lock() / Unlock() suppress intermediate redraws. All changes accumulate and are painted in a single pass at Unlock().

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py

C#

GIS.Lock();
GIS.Open(@"C:\data\basemap.shp");
GIS.Add(overlayLayer);
GIS.Unlock();
GIS.FullExtent();

VB.NET

GIS.Lock()
GIS.Open("C:\data\basemap.shp")
GIS.Add(overlayLayer)
GIS.Unlock()
GIS.FullExtent()

Delphi

GIS.Lock;
GIS.Open('C:\data\basemap.shp');
GIS.Add(overlayLayer);
GIS.Unlock;
GIS.FullExtent;

Java

GIS.Lock();
GIS.Open("C:/data/basemap.shp");
GIS.Add(overlayLayer);
GIS.Unlock();
GIS.FullExtent();

Python

GIS.Lock()
GIS.Open("C:/data/basemap.shp")
GIS.Add(overlay_layer)
GIS.Unlock()
GIS.FullExtent()

Resolve the sample data directory

GisSamplesDataDirDownload() returns the path to the TatukGIS shared sample dataset, downloading it on first call if not present.

→ API: TGIS_Utils: .NET/VB · Delphi · Java · AX · Py

C#

string dataDir = TGIS_Utils.GisSamplesDataDirDownload();
GIS.Open(dataDir + @"World\WorldDCW\world.shp");

VB.NET

Dim dataDir As String = TGIS_Utils.GisSamplesDataDirDownload()
GIS.Open(dataDir & "World\WorldDCW\world.shp")

Delphi

var dataDir := TGIS_Utils.GisSamplesDataDirDownload();
GIS.Open(dataDir + '\World\WorldDCW\world.shp');

Java

String dataDir = TGIS_Utils.GisSamplesDataDirDownload();
GIS.Open(dataDir + "/World/WorldDCW/world.shp");

Python

data_dir = pdk.TGIS_Utils.GisSamplesDataDirDownload()
GIS.Open(data_dir + "/World/WorldDCW/world.shp")

Layer Management

Retrieve a layer by name

GIS.Get() finds a layer by its display name. When a file is loaded via Open(), the layer name defaults to the filename without extension.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("world");
if (layer != null)
    layer.Transparency = 30;

VB.NET

Dim layer = CType(GIS.Get("world"), TGIS_LayerVector)
If layer IsNot Nothing Then
    layer.Transparency = 30
End If

Delphi

var layer := TGIS_LayerVector(GIS.Get('world'));
if layer <> nil then
  layer.Transparency := 30;

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("world");
if (layer != null)
    layer.setTransparency(30);

Python

layer = GIS.Get("world")
if layer is not None:
    layer.Transparency = 30

Access a layer by index

Layers are ordered back-to-front. Index 0 is the bottommost layer.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var bottom = (TGIS_LayerVector)GIS.Items[0];

VB.NET

Dim bottom = CType(GIS.Items(0), TGIS_LayerVector)

Delphi

var bottom := TGIS_LayerVector(GIS.Items[0]);

Java

TGIS_LayerVector bottom = (TGIS_LayerVector)GIS.getItems().getItems(0);

Python

bottom = GIS.Items[0]

Create an in-memory vector layer

An in-memory layer has no file path. Always assign the same CS as the viewer so coordinates are interpreted correctly.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var overlay = new TGIS_LayerVector();
overlay.Name = "overlay";
overlay.CS   = GIS.CS;
GIS.Add(overlay);

VB.NET

Dim overlay As New TGIS_LayerVector()
overlay.Name = "overlay"
overlay.CS   = GIS.CS
GIS.Add(overlay)

Delphi

var overlay := TGIS_LayerVector.Create;
overlay.Name := 'overlay';
overlay.CS   := GIS.CS;
GIS.Add(overlay);

Java

TGIS_LayerVector overlay = new TGIS_LayerVector();
overlay.setName("overlay");
overlay.setCS(GIS.getCS());
GIS.Add(overlay);

Python

overlay = pdk.TGIS_LayerVector()
overlay.Name = "overlay"
overlay.CS   = GIS.CS
GIS.Add(overlay)

Remove a layer

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py

C#

GIS.Delete("overlay");

VB.NET

GIS.Delete("overlay")

Delphi

GIS.Delete('overlay');

Java

GIS.Delete("overlay");

Python

GIS.Delete("overlay")

Style a polygon layer — solid fill and outline

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Color: .NET/VB · Delphi · Java · AX · Py
TGIS_BrushStyle: .NET/VB · Delphi · Java · AX · Py

C#

var poly = (TGIS_LayerVector)GIS.Get("countries");
poly.Params.Area.Color        = TGIS_Color.LightGray;
poly.Params.Area.OutlineColor = TGIS_Color.Black;
poly.Params.Area.Pattern      = TGIS_BrushStyle.Solid;
GIS.InvalidateWholeMap();

VB.NET

Dim poly = CType(GIS.Get("countries"), TGIS_LayerVector)
poly.Params.Area.Color        = TGIS_Color.LightGray
poly.Params.Area.OutlineColor = TGIS_Color.Black
poly.Params.Area.Pattern      = TGIS_BrushStyle.Solid
GIS.InvalidateWholeMap()

Delphi

var poly := TGIS_LayerVector(GIS.Get('countries'));
poly.Params.Area.Color        := TGIS_Color.LightGray;
poly.Params.Area.OutlineColor := TGIS_Color.Black;
poly.Params.Area.Pattern      := TGIS_BrushStyle.Solid;
GIS.InvalidateWholeMap;

Java

TGIS_LayerVector poly = (TGIS_LayerVector)GIS.Get("countries");
poly.getParams().getArea().setColor(TGIS_Color.getLightGray());
poly.getParams().getArea().setOutlineColor(TGIS_Color.getBlack());
poly.getParams().getArea().setPattern(TGIS_BrushStyle.Solid);
GIS.InvalidateWholeMap();

Python

poly = GIS.Get("countries")
poly.Params.Area.Color        = pdk.TGIS_Color().LightGray
poly.Params.Area.OutlineColor = pdk.TGIS_Color().Black
poly.Params.Area.Pattern      = pdk.TGIS_BrushStyle().Solid
GIS.InvalidateWholeMap()

Style a polygon with transparent fill (outline only)

Set Pattern = Clear to suppress the fill while retaining the outline.

→ API: TGIS_BrushStyle: .NET/VB · Delphi · Java · AX · Py
TGIS_Color: .NET/VB · Delphi · Java · AX · Py

C#

overlay.Params.Area.OutlineColor = TGIS_Color.Blue;
overlay.Params.Area.Pattern      = TGIS_BrushStyle.Clear;

VB.NET

overlay.Params.Area.OutlineColor = TGIS_Color.Blue
overlay.Params.Area.Pattern      = TGIS_BrushStyle.Clear

Delphi

overlay.Params.Area.OutlineColor := TGIS_Color.Blue;
overlay.Params.Area.Pattern      := TGIS_BrushStyle.Clear;

Java

overlay.getParams().getArea().setOutlineColor(TGIS_Color.getBlue());
overlay.getParams().getArea().setPattern(TGIS_BrushStyle.Clear);

Python

overlay.Params.Area.OutlineColor = pdk.TGIS_Color().Blue
overlay.Params.Area.Pattern      = pdk.TGIS_BrushStyle().Clear

Style a line layer

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Color: .NET/VB · Delphi · Java · AX · Py

C#

var rivers = (TGIS_LayerVector)GIS.Get("rivers");
rivers.Params.Line.Color        = TGIS_Color.Blue;
rivers.Params.Line.Width        = 15;   // units: 1/100 mm
rivers.Params.Line.OutlineWidth = 5;
GIS.InvalidateWholeMap();

VB.NET

Dim rivers = CType(GIS.Get("rivers"), TGIS_LayerVector)
rivers.Params.Line.Color        = TGIS_Color.Blue
rivers.Params.Line.Width        = 15
rivers.Params.Line.OutlineWidth = 5
GIS.InvalidateWholeMap()

Delphi

var rivers := TGIS_LayerVector(GIS.Get('rivers'));
rivers.Params.Line.Color        := TGIS_Color.Blue;
rivers.Params.Line.Width        := 15;
rivers.Params.Line.OutlineWidth := 5;
GIS.InvalidateWholeMap;

Java

TGIS_LayerVector rivers = (TGIS_LayerVector)GIS.Get("rivers");
rivers.getParams().getLine().setColor(TGIS_Color.getBlue());
rivers.getParams().getLine().setWidth(15);
rivers.getParams().getLine().setOutlineWidth(5);
GIS.InvalidateWholeMap();

Python

rivers = GIS.Get("rivers")
rivers.Params.Line.Color        = pdk.TGIS_Color().Blue
rivers.Params.Line.Width        = 15
rivers.Params.Line.OutlineWidth = 5
GIS.InvalidateWholeMap()

Style a point / marker layer

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Color: .NET/VB · Delphi · Java · AX · Py

C#

var cities = (TGIS_LayerVector)GIS.Get("cities");
cities.Params.Marker.Color = TGIS_Color.Red;
GIS.InvalidateWholeMap();

VB.NET

Dim cities = CType(GIS.Get("cities"), TGIS_LayerVector)
cities.Params.Marker.Color = TGIS_Color.Red
GIS.InvalidateWholeMap()

Delphi

var cities := TGIS_LayerVector(GIS.Get('cities'));
cities.Params.Marker.Color := TGIS_Color.Red;
GIS.InvalidateWholeMap;

Java

TGIS_LayerVector cities = (TGIS_LayerVector)GIS.Get("cities");
cities.getParams().getMarker().setColor(TGIS_Color.getRed());
GIS.InvalidateWholeMap();

Python

cities = GIS.Get("cities")
cities.Params.Marker.Color = pdk.TGIS_Color().Red
GIS.InvalidateWholeMap()

Set layer transparency

Transparency ranges from 0 (opaque) to 100 (fully transparent).

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var buffer = (TGIS_LayerVector)GIS.Get("buffer");
buffer.Transparency = 50;
GIS.InvalidateWholeMap();

VB.NET

Dim buffer = CType(GIS.Get("buffer"), TGIS_LayerVector)
buffer.Transparency = 50
GIS.InvalidateWholeMap()

Delphi

var buffer := TGIS_LayerVector(GIS.Get('buffer'));
buffer.Transparency := 50;
GIS.InvalidateWholeMap;

Java

TGIS_LayerVector buffer = (TGIS_LayerVector)GIS.Get("buffer");
buffer.setTransparency(50);
GIS.InvalidateWholeMap();

Python

buffer = GIS.Get("buffer")
buffer.Transparency = 50
GIS.InvalidateWholeMap()

Viewport and Navigation


Set the viewer interaction mode

Switch the viewer mode freely at runtime to control how mouse/touch events are interpreted.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_ViewerMode: .NET/VB · Delphi · Java · AX · Py

C#

GIS.Mode = TGIS_ViewerMode.Zoom;
GIS.Mode = TGIS_ViewerMode.Drag;
GIS.Mode = TGIS_ViewerMode.Select;
GIS.Mode = TGIS_ViewerMode.Edit;

VB.NET

GIS.Mode = TGIS_ViewerMode.Zoom
GIS.Mode = TGIS_ViewerMode.Drag
GIS.Mode = TGIS_ViewerMode.Select
GIS.Mode = TGIS_ViewerMode.Edit

Delphi

GIS.Mode := TGIS_ViewerMode.Zoom;
GIS.Mode := TGIS_ViewerMode.Drag;
GIS.Mode := TGIS_ViewerMode.Select;
GIS.Mode := TGIS_ViewerMode.Edit;

Java

GIS.setMode(TGIS_ViewerMode.Zoom);
GIS.setMode(TGIS_ViewerMode.Drag);
GIS.setMode(TGIS_ViewerMode.Select);
GIS.setMode(TGIS_ViewerMode.Edit);

Python

GIS.Mode = pdk.TGIS_ViewerMode().Zoom
GIS.Mode = pdk.TGIS_ViewerMode().Drag
GIS.Mode = pdk.TGIS_ViewerMode().Select
GIS.Mode = pdk.TGIS_ViewerMode().Edit

Zoom to a layer's geographic extent

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("countries");
GIS.Zoom = layer.ProjectedExtent;

VB.NET

Dim layer = CType(GIS.Get("countries"), TGIS_LayerVector)
GIS.Zoom = layer.ProjectedExtent

Delphi

var layer := TGIS_LayerVector(GIS.Get('countries'));
GIS.Zoom := layer.ProjectedExtent;

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("countries");
GIS.setZoom(layer.getProjectedExtent());

Python

layer    = GIS.Get("countries")
GIS.Zoom = layer.ProjectedExtent

Zoom to a specific geographic extent

TGIS_Utils.GisExtent() is a convenience constructor for TGIS_Extent (xmin, ymin, xmax, ymax).

→ API: TGIS_Extent: .NET/VB · Delphi · Java · AX · Py
TGIS_Utils: .NET/VB · Delphi · Java · AX · Py

C#

GIS.Zoom = TGIS_Utils.GisExtent(-20.0, 35.0, 40.0, 70.0);

VB.NET

GIS.Zoom = TGIS_Utils.GisExtent(-20.0, 35.0, 40.0, 70.0)

Delphi

GIS.Zoom := TGIS_Utils.GisExtent(-20.0, 35.0, 40.0, 70.0);

Java

GIS.setZoom(TGIS_Utils.GisExtent(-20.0, 35.0, 40.0, 70.0));

Python

GIS.Zoom = pdk.TGIS_Utils().GisExtent(-20.0, 35.0, 40.0, 70.0)

Convert screen coordinates to map coordinates

Converts a pixel position from a mouse event to geographic map coordinates.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_Point: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Point mapPt = GIS.ScreenToMap(new Point(e.X, e.Y));

VB.NET

Dim mapPt As TGIS_Point = GIS.ScreenToMap(New Point(CInt(_e.X), CInt(_e.Y)))

Delphi

var mapPt := GIS.ScreenToMap(Point(X, Y));

Java

TGIS_Point mapPt = GIS.ScreenToMap(new TPoint(evt.getX(), evt.getY()));

Python

map_pt = GIS.ScreenToMap(pdk.TPoint(int(x), int(y)))

Trigger a map repaint

InvalidateWholeMap() schedules a full redraw. InvalidateTopmost() redraws only the topmost layer.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py

C#

GIS.InvalidateWholeMap();
GIS.InvalidateTopmost();

VB.NET

GIS.InvalidateWholeMap()
GIS.InvalidateTopmost()

Delphi

GIS.InvalidateWholeMap;
GIS.InvalidateTopmost;

Java

GIS.InvalidateWholeMap();
GIS.InvalidateTopmost();

Python

GIS.InvalidateWholeMap()
GIS.InvalidateTopmost()

Handle a map click (TapSimple event)

TapSimpleEvent fires on every single mouse/touch press on the viewer.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_ViewerMode: .NET/VB · Delphi · Java · AX · Py

C#

GIS.TapSimpleEvent += GIS_TapSimpleEvent;
 
private void GIS_TapSimpleEvent(object _sender, TGIS_TapEventArgs _e)
{
    if (GIS.Mode != TGIS_ViewerMode.Select) return;
    TGIS_Point mapPt = GIS.ScreenToMap(new Point((int)_e.X, (int)_e.Y));
}

VB.NET

Private Sub GIS_TapSimpleEvent(_sender As Object, _e As TGIS_TapEventArgs) Handles GIS.TapSimpleEvent
    If GIS.Mode <> TGIS_ViewerMode.Select Then Return
    Dim mapPt As TGIS_Point = GIS.ScreenToMap(New Point(CInt(_e.X), CInt(_e.Y)))
End Sub

Delphi

procedure TMainForm.GISTapSimpleEvent(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if GIS.Mode <> TGIS_ViewerMode.Select then Exit;
  var mapPt := GIS.ScreenToMap(Point(X, Y));
end;

Java

GIS.setOnTapSimple(new TMouseEvent() {
    @Override
    public void Invoke(MouseEvent me) {
        if (GIS.getMode() != TGIS_ViewerMode.Select) return;
        TGIS_Point mapPt = GIS.ScreenToMap(new TPoint(me.getX(), me.getY()));
    }
});

Python

def on_tap_simple(sender, button, shift, x, y):
    if GIS.Mode != pdk.TGIS_ViewerMode().Select:
        return
    map_pt = GIS.ScreenToMap(pdk.TPoint(int(x), int(y)))
 
GIS.TapSimpleEvent = on_tap_simple

Coordinate Systems


Assign a coordinate system to a layer by EPSG code

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("roads");
layer.SetCSByEPSG(4326);

VB.NET

Dim layer = CType(GIS.Get("roads"), TGIS_LayerVector)
layer.SetCSByEPSG(4326)

Delphi

var layer := TGIS_LayerVector(GIS.Get('roads'));
layer.SetCSByEPSG(4326);

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("roads");
layer.SetCSByEPSG(4326);

Python

layer = GIS.Get("roads")
layer.SetCSByEPSG(4326)

Create a coordinate system by EPSG code

Common codes: 4326 = WGS 84 (degrees), 3857 = Web Mercator (metres), 3395 = World Mercator (metres).

→ API: TGIS_CSFactory: .NET/VB · Delphi · Java · AX · Py

C#

GIS.CS = TGIS_CSFactory.ByEPSG(3395);

VB.NET

GIS.CS = TGIS_CSFactory.ByEPSG(3395)

Delphi

GIS.CS := TGIS_CSFactory.ByEPSG(3395);

Java

GIS.setCS(TGIS_CSFactory.ByEPSG(3395));

Python

GIS.CS = pdk.TGIS_CSFactory.ByEPSG(3395)

Transform a point between two coordinate systems

→ API: TGIS_CSFactory: .NET/VB · Delphi · Java · AX · Py
TGIS_Point: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_CS    srcCS = TGIS_CSFactory.ByEPSG(4326);
TGIS_CS    dstCS = TGIS_CSFactory.ByEPSG(3395);
TGIS_Point ptIn  = new TGIS_Point(21.0, 52.0);
TGIS_Point ptOut = dstCS.FromCS(srcCS, ptIn);

VB.NET

Dim srcCS = TGIS_CSFactory.ByEPSG(4326)
Dim dstCS = TGIS_CSFactory.ByEPSG(3395)
Dim ptIn  = New TGIS_Point(21.0, 52.0)
Dim ptOut = dstCS.FromCS(srcCS, ptIn)

Delphi

var srcCS := TGIS_CSFactory.ByEPSG(4326);
var dstCS := TGIS_CSFactory.ByEPSG(3395);
var ptIn  := TGIS_Utils.GisPoint(21.0, 52.0);
var ptOut := dstCS.FromCS(srcCS, ptIn);

Java

TGIS_CS    srcCS = TGIS_CSFactory.ByEPSG(4326);
TGIS_CS    dstCS = TGIS_CSFactory.ByEPSG(3395);
TGIS_Point ptIn  = new TGIS_Point(21.0, 52.0);
TGIS_Point ptOut = dstCS.FromCS(srcCS, ptIn);

Python

src_cs = pdk.TGIS_CSFactory.ByEPSG(4326)
dst_cs = pdk.TGIS_CSFactory.ByEPSG(3395)
pt_in  = pdk.TGIS_Utils().GisPoint(21.0, 52.0)
pt_out = dst_cs.FromCS(src_cs, pt_in)

Format distance and area with units

TGIS_CSUnits converts raw SI values to labelled strings. EPSG 904201 = standard metric units (km / km²).

→ API: TGIS_CSUnits: .NET/VB · Delphi · Java · AX · Py
TGIS_Utils: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_CSUnits unit = TGIS_Utils.CSUnitsList.ByEPSG(904201);
string distText   = unit.AsLinear(shape.LengthCS(), true);
string areaText   = unit.AsAreal(shape.AreaCS(), true, "%s\xB2");

VB.NET

Dim unit As TGIS_CSUnits = TGIS_Utils.CSUnitsList.ByEPSG(904201)
Dim distText = unit.AsLinear(shape.LengthCS(), True)
Dim areaText = unit.AsAreal(shape.AreaCS(),    True, "%s²")

Delphi

var unit_ := TGIS_Utils.CSUnitsList.ByEPSG(904201);
var distText := unit_.AsLinear(shape.LengthCS(), True);
var areaText := unit_.AsAreal(shape.AreaCS(),    True, '%s²');

Java

TGIS_CSUnits unit = TGIS_Utils.CSUnitsList.ByEPSG(904201);
String distText   = unit.AsLinear(shape.LengthCS(), true);
String areaText   = unit.AsAreal(shape.AreaCS(),    true, "%s²");

Python

unit      = pdk.TGIS_Utils.CSUnitsList.ByEPSG(904201)
dist_text = unit.AsLinear(shape.LengthCS(), True)
area_text = unit.AsAreal(shape.AreaCS(),    True, "%s²")

Reading and Querying Vector Data


Iterate all shapes in a layer

Loop() with layer.Extent as the spatial filter includes every shape in the layer.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("world");
foreach (TGIS_Shape shp in layer.Loop(layer.Extent, "", null, ""))
    Console.WriteLine(shp.GetField("NAME"));

VB.NET

Dim layer = CType(GIS.Get("world"), TGIS_LayerVector)
For Each shp As TGIS_Shape In layer.Loop(layer.Extent, "", Nothing, "")
    Console.WriteLine(shp.GetField("NAME"))
Next

Delphi

var layer := TGIS_LayerVector(GIS.Get('world'));
for var shp in layer.Loop(layer.Extent, '', nil, '') do
  Writeln(shp.GetField('NAME'));

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("world");
for (Object obj : layer.Loop(layer.getExtent(), "", null, "")) {
    TGIS_Shape shp = (TGIS_Shape)obj;
    System.out.println(shp.GetField("NAME"));
}

Python

layer = GIS.Get("world")
for shp in layer.Loop(layer.Extent, "", None, ""):
    print(shp.GetField("NAME"))

Filter shapes by SQL WHERE clause

The second Loop() parameter is a SQL WHERE expression against the attribute table.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("cities");
foreach (TGIS_Shape shp in layer.Loop(layer.Extent, "POPULATION > 1000000", null, ""))
    shp.IsSelected = true;
GIS.InvalidateWholeMap();

VB.NET

Dim layer = CType(GIS.Get("cities"), TGIS_LayerVector)
For Each shp As TGIS_Shape In layer.Loop(layer.Extent, "POPULATION > 1000000", Nothing, "")
    shp.IsSelected = True
Next
GIS.InvalidateWholeMap()

Delphi

var layer := TGIS_LayerVector(GIS.Get('cities'));
for var shp in layer.Loop(layer.Extent, 'POPULATION > 1000000', nil, '') do
  shp.IsSelected := True;
GIS.InvalidateWholeMap;

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("cities");
for (Object obj : layer.Loop(layer.getExtent(), "POPULATION > 1000000", null, ""))
    ((TGIS_Shape)obj).setIsSelected(true);
GIS.InvalidateWholeMap();

Python

layer = GIS.Get("cities")
for shp in layer.Loop(layer.Extent, "POPULATION > 1000000", None, ""):
    shp.IsSelected = True
GIS.InvalidateWholeMap()

Spatial extent filter — shapes visible on screen

GIS.VisibleExtent limits the loop to shapes whose bounding box intersects the viewport.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("roads");
foreach (TGIS_Shape shp in layer.Loop(GIS.VisibleExtent, "", null, ""))
{
    // process only visible shapes
}

VB.NET

Dim layer = CType(GIS.Get("roads"), TGIS_LayerVector)
For Each shp As TGIS_Shape In layer.Loop(GIS.VisibleExtent, "", Nothing, "")
    ' process only visible shapes
Next

Delphi

var layer := TGIS_LayerVector(GIS.Get('roads'));
for var shp in layer.Loop(GIS.VisibleExtent, '', nil, '') do
begin
  // process only visible shapes
end;

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("roads");
for (Object obj : layer.Loop(GIS.getVisibleExtent(), "", null, "")) {
    // process only visible shapes
}

Python

layer = GIS.Get("roads")
for shp in layer.Loop(GIS.VisibleExtent, "", None, ""):
    pass  # process only visible shapes

Spatial relationship query with DE-9IM

The fourth Loop() parameter is a DE-9IM matrix string. “T*****FF*” selects shapes contained within a query shape.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Shape polygon = queryLayer.GetShape(1).MakeEditable();
GIS.Lock();
foreach (TGIS_Shape shp in world.Loop(polygon.Extent, "label LIKE 's%'", polygon, "T*****FF*"))
    shp.IsSelected = true;
GIS.Unlock();
GIS.InvalidateWholeMap();

VB.NET

Dim polygon = queryLayer.GetShape(1).MakeEditable()
GIS.Lock()
For Each shp As TGIS_Shape In world.Loop(polygon.Extent, "label LIKE 's%'", polygon, "T*****FF*")
    shp.IsSelected = True
Next
GIS.Unlock()
GIS.InvalidateWholeMap()

Delphi

var polygon := queryLayer.GetShape(1).MakeEditable;
GIS.Lock;
for var shp in world.Loop(polygon.Extent, 'label LIKE ''s%''', polygon, 'T*****FF*') do
  shp.IsSelected := True;
GIS.Unlock;
GIS.InvalidateWholeMap;

Java

TGIS_Shape polygon = queryLayer.GetShape(1).MakeEditable();
GIS.Lock();
for (Object obj : world.Loop(polygon.getExtent(), "label LIKE 's%'", polygon, "T*****FF*"))
    ((TGIS_Shape)obj).setIsSelected(true);
GIS.Unlock();
GIS.InvalidateWholeMap();

Python

polygon = query_layer.GetShape(1).MakeEditable()
GIS.Lock()
for shp in world.Loop(polygon.Extent, "label LIKE 's%'", polygon, "T*****FF*"):
    shp.IsSelected = True
GIS.Unlock()
GIS.InvalidateWholeMap()

Read a shape attribute

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

string name = (string)shp.GetField("NAME");
double pop  = Convert.ToDouble(shp.GetField("POPULATION"));

VB.NET

Dim name As String = CStr(shp.GetField("NAME"))
Dim pop  As Double = CDbl(shp.GetField("POPULATION"))

Delphi

var name := string(shp.GetField('NAME'));
var pop  := Double(shp.GetField('POPULATION'));

Java

String name = (String)shp.GetField("NAME");
double pop  = Double.parseDouble(shp.GetField("POPULATION").toString());

Python

name = shp.GetField("NAME")
pop  = float(shp.GetField("POPULATION"))

Find shapes at a map position (hit test)

GIS.Locate() returns the topmost shape within precision map units. Dividing 5 screen pixels by GIS.Zoom gives map-unit tolerance.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Point mapPt    = GIS.ScreenToMap(new Point(e.X, e.Y));
TGIS_Shape shp      = (TGIS_Shape)GIS.Locate(mapPt, 5.0 / GIS.Zoom);
if (shp != null) shp.Flash();

VB.NET

Dim mapPt As TGIS_Point = GIS.ScreenToMap(New Point(CInt(_e.X), CInt(_e.Y)))
Dim shp   As TGIS_Shape = CType(GIS.Locate(mapPt, 5.0 / GIS.Zoom), TGIS_Shape)
If shp IsNot Nothing Then shp.Flash()

Delphi

var mapPt := GIS.ScreenToMap(Point(X, Y));
var shp   := TGIS_Shape(GIS.Locate(mapPt, 5.0 / GIS.Zoom));
if shp <> nil then shp.Flash;

Java

TGIS_Point mapPt = GIS.ScreenToMap(new TPoint(evt.getX(), evt.getY()));
TGIS_Shape shp   = (TGIS_Shape)GIS.Locate(mapPt, 5.0 / GIS.getZoom());
if (shp != null) shp.setIsSelected(true);

Python

map_pt = GIS.ScreenToMap(pdk.TPoint(int(x), int(y)))
shp    = GIS.Locate(map_pt, 5.0 / GIS.Zoom)
if shp is not None:
    shp.Flash()

Get a shape by its unique ID

Every shape has a persistent Uid. Use it to re-fetch a shape after iterating or repainting.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

long       shpId = shp.Uid;
TGIS_Shape found = layer.GetShape(shpId);

VB.NET

Dim shpId As Long     = shp.Uid
Dim found As TGIS_Shape = layer.GetShape(shpId)

Delphi

var shpId := shp.Uid;
var found := layer.GetShape(shpId);

Java

int        shpId = (int)shp.getUid();
TGIS_Shape found = layer.GetShape(shpId);

Python

shp_id = shp.Uid
found  = layer.GetShape(shp_id)

Select and deselect shapes

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

shp.IsSelected = true;
shp.IsSelected = !shp.IsSelected;
layer.DeselectAll();
GIS.InvalidateWholeMap();

VB.NET

shp.IsSelected = True
shp.IsSelected = Not shp.IsSelected
layer.DeselectAll()
GIS.InvalidateWholeMap()

Delphi

shp.IsSelected := True;
shp.IsSelected := not shp.IsSelected;
layer.DeselectAll;
GIS.InvalidateWholeMap;

Java

shp.setIsSelected(true);
shp.setIsSelected(!shp.getIsSelected());
layer.DeselectAll();
GIS.InvalidateWholeMap();

Python

shp.IsSelected = True
shp.IsSelected = not shp.IsSelected
layer.DeselectAll()
GIS.InvalidateWholeMap()

Creating and Editing Vector Data


Create a point shape

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_ShapeType: .NET/VB · Delphi · Java · AX · Py
TGIS_Lock: .NET/VB · Delphi · Java · AX · Py

C#

var layer = (TGIS_LayerVector)GIS.Get("overlay");
TGIS_Shape pt = layer.CreateShape(TGIS_ShapeType.Point);
pt.Lock(TGIS_Lock.Extent);
pt.AddPart();
pt.AddPoint(new TGIS_Point(21.0, 52.0));
pt.Unlock();
GIS.InvalidateWholeMap();

VB.NET

Dim layer = CType(GIS.Get("overlay"), TGIS_LayerVector)
Dim pt As TGIS_Shape = layer.CreateShape(TGIS_ShapeType.Point)
pt.Lock(TGIS_Lock.Extent)
pt.AddPart()
pt.AddPoint(New TGIS_Point(21.0, 52.0))
pt.Unlock()
GIS.InvalidateWholeMap()

Delphi

var layer := TGIS_LayerVector(GIS.Get('overlay'));
var pt    := layer.CreateShape(TGIS_ShapeType.Point);
pt.Lock(TGIS_Lock.Extent);
pt.AddPart;
pt.AddPoint(TGIS_Utils.GisPoint(21.0, 52.0));
pt.Unlock;
GIS.InvalidateWholeMap;

Java

TGIS_LayerVector layer = (TGIS_LayerVector)GIS.Get("overlay");
TGIS_Shape pt = layer.CreateShape(TGIS_ShapeType.Point);
pt.Lock(TGIS_Lock.Extent);
pt.AddPart();
pt.AddPoint(new TGIS_Point(21.0, 52.0));
pt.Unlock();
GIS.InvalidateWholeMap();

Python

layer = GIS.Get("overlay")
pt    = layer.CreateShape(pdk.TGIS_ShapeType().Point)
pt.Lock(pdk.TGIS_Lock().Extent)
pt.AddPart()
pt.AddPoint(pdk.TGIS_Utils().GisPoint(21.0, 52.0))
pt.Unlock()
GIS.InvalidateWholeMap()

Create a polyline (arc) shape

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_ShapeType: .NET/VB · Delphi · Java · AX · Py
TGIS_Lock: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Shape arc = layer.CreateShape(TGIS_ShapeType.Arc);
arc.Lock(TGIS_Lock.Extent);
arc.AddPart();
arc.AddPoint(new TGIS_Point(10.0, 50.0));
arc.AddPoint(new TGIS_Point(15.0, 52.0));
arc.AddPoint(new TGIS_Point(21.0, 52.0));
arc.Unlock();
GIS.InvalidateWholeMap();

VB.NET

Dim arc As TGIS_Shape = layer.CreateShape(TGIS_ShapeType.Arc)
arc.Lock(TGIS_Lock.Extent)
arc.AddPart()
arc.AddPoint(New TGIS_Point(10.0, 50.0))
arc.AddPoint(New TGIS_Point(15.0, 52.0))
arc.AddPoint(New TGIS_Point(21.0, 52.0))
arc.Unlock()
GIS.InvalidateWholeMap()

Delphi

var arc := layer.CreateShape(TGIS_ShapeType.Arc);
arc.Lock(TGIS_Lock.Extent);
arc.AddPart;
arc.AddPoint(TGIS_Utils.GisPoint(10.0, 50.0));
arc.AddPoint(TGIS_Utils.GisPoint(15.0, 52.0));
arc.AddPoint(TGIS_Utils.GisPoint(21.0, 52.0));
arc.Unlock;
GIS.InvalidateWholeMap;

Java

TGIS_Shape arc = layer.CreateShape(TGIS_ShapeType.Arc);
arc.Lock(TGIS_Lock.Extent);
arc.AddPart();
arc.AddPoint(new TGIS_Point(10.0, 50.0));
arc.AddPoint(new TGIS_Point(15.0, 52.0));
arc.AddPoint(new TGIS_Point(21.0, 52.0));
arc.Unlock();
GIS.InvalidateWholeMap();

Python

arc = layer.CreateShape(pdk.TGIS_ShapeType().Arc)
arc.Lock(pdk.TGIS_Lock().Extent)
arc.AddPart()
arc.AddPoint(pdk.TGIS_Utils().GisPoint(10.0, 50.0))
arc.AddPoint(pdk.TGIS_Utils().GisPoint(15.0, 52.0))
arc.AddPoint(pdk.TGIS_Utils().GisPoint(21.0, 52.0))
arc.Unlock()
GIS.InvalidateWholeMap()

Create a polygon shape

Unlock() automatically closes the ring if the first and last vertices differ.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py
TGIS_ShapeType: .NET/VB · Delphi · Java · AX · Py
TGIS_Lock: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Shape poly = layer.CreateShape(TGIS_ShapeType.Polygon);
poly.Lock(TGIS_Lock.Extent);
poly.AddPart();
poly.AddPoint(new TGIS_Point(10.0, 10.0));
poly.AddPoint(new TGIS_Point(10.0, 80.0));
poly.AddPoint(new TGIS_Point(80.0, 90.0));
poly.AddPoint(new TGIS_Point(90.0, 10.0));
poly.Unlock();
GIS.InvalidateWholeMap();

VB.NET

Dim poly As TGIS_Shape = layer.CreateShape(TGIS_ShapeType.Polygon)
poly.Lock(TGIS_Lock.Extent)
poly.AddPart()
poly.AddPoint(New TGIS_Point(10.0, 10.0))
poly.AddPoint(New TGIS_Point(10.0, 80.0))
poly.AddPoint(New TGIS_Point(80.0, 90.0))
poly.AddPoint(New TGIS_Point(90.0, 10.0))
poly.Unlock()
GIS.InvalidateWholeMap()

Delphi

var poly := layer.CreateShape(TGIS_ShapeType.Polygon);
poly.Lock(TGIS_Lock.Extent);
poly.AddPart;
poly.AddPoint(TGIS_Utils.GisPoint(10.0, 10.0));
poly.AddPoint(TGIS_Utils.GisPoint(10.0, 80.0));
poly.AddPoint(TGIS_Utils.GisPoint(80.0, 90.0));
poly.AddPoint(TGIS_Utils.GisPoint(90.0, 10.0));
poly.Unlock;
GIS.InvalidateWholeMap;

Java

TGIS_Shape poly = layer.CreateShape(TGIS_ShapeType.Polygon);
poly.Lock(TGIS_Lock.Extent);
poly.AddPart();
poly.AddPoint(new TGIS_Point(10.0, 10.0));
poly.AddPoint(new TGIS_Point(10.0, 80.0));
poly.AddPoint(new TGIS_Point(80.0, 90.0));
poly.AddPoint(new TGIS_Point(90.0, 10.0));
poly.Unlock();
GIS.InvalidateWholeMap();

Python

poly = layer.CreateShape(pdk.TGIS_ShapeType().Polygon)
poly.Lock(pdk.TGIS_Lock().Extent)
poly.AddPart()
poly.AddPoint(pdk.TGIS_Utils().GisPoint(10.0, 10.0))
poly.AddPoint(pdk.TGIS_Utils().GisPoint(10.0, 80.0))
poly.AddPoint(pdk.TGIS_Utils().GisPoint(80.0, 90.0))
poly.AddPoint(pdk.TGIS_Utils().GisPoint(90.0, 10.0))
poly.Unlock()
GIS.InvalidateWholeMap()

Lock a shape for bulk vertex edits

Lock(TGIS_Lock.Extent) defers bounding-box recalculation until Unlock(). Always use try/finally to guarantee Unlock() is called.

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_Lock: .NET/VB · Delphi · Java · AX · Py

C#

shp.Lock(TGIS_Lock.Extent);
try
{
    shp.AddPart();
    foreach (var pt in myPoints)
        shp.AddPoint(pt);
}
finally { shp.Unlock(); }

VB.NET

shp.Lock(TGIS_Lock.Extent)
Try
    shp.AddPart()
    For Each pt In myPoints
        shp.AddPoint(pt)
    Next
Finally
    shp.Unlock()
End Try

Delphi

shp.Lock(TGIS_Lock.Extent);
try
  shp.AddPart;
  for var pt in myPoints do
    shp.AddPoint(pt);
finally
  shp.Unlock;
end;

Java

shp.Lock(TGIS_Lock.Extent);
try {
    shp.AddPart();
    for (TGIS_Point pt : myPoints)
        shp.AddPoint(pt);
} finally { shp.Unlock(); }

Python

shp.Lock(pdk.TGIS_Lock().Extent)
try:
    shp.AddPart()
    for pt in my_points:
        shp.AddPoint(pt)
finally:
    shp.Unlock()

Make a file-backed shape editable

Call MakeEditable() before modifying a shape or passing it to a long-lived spatial query, to pin it in memory.

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Shape editable = layer.GetShape(uid).MakeEditable();

VB.NET

Dim editable As TGIS_Shape = layer.GetShape(uid).MakeEditable()

Delphi

var editable := layer.GetShape(uid).MakeEditable;

Java

TGIS_Shape editable = layer.GetShape(uid).MakeEditable();

Python

editable = layer.GetShape(uid).MakeEditable()

Set a shape attribute

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

shp.SetField("NAME",       "Warsaw");
shp.SetField("POPULATION", 1794000);

VB.NET

shp.SetField("NAME",       "Warsaw")
shp.SetField("POPULATION", 1794000)

Delphi

shp.SetField('NAME',       'Warsaw');
shp.SetField('POPULATION', 1794000);

Java

shp.SetField("NAME",       "Warsaw");
shp.SetField("POPULATION", 1794000);

Python

shp.SetField("NAME",       "Warsaw")
shp.SetField("POPULATION", 1794000)

Delete all shapes from a layer

RevertShapes() clears all shapes while keeping the layer schema (fields, CS, styling).

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

layer.RevertShapes();

VB.NET

layer.RevertShapes()

Delphi

layer.RevertShapes;

Java

layer.RevertShapes();

Python

layer.RevertShapes()

Interactive shape editor — start drawing

The built-in editor creates shapes as the user clicks vertices. The shape is finalised on double-click or right-click.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_ShapeType: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Point startPt = GIS.ScreenToMap(new Point(e.X, e.Y));
GIS.Editor.CreateShape(editLayer, startPt, TGIS_ShapeType.Polygon);
GIS.Mode = TGIS_ViewerMode.Edit;

VB.NET

Dim startPt As TGIS_Point = GIS.ScreenToMap(New Point(e.X, e.Y))
GIS.Editor.CreateShape(editLayer, startPt, TGIS_ShapeType.Polygon)
GIS.Mode = TGIS_ViewerMode.Edit

Delphi

var startPt := GIS.ScreenToMap(Point(X, Y));
GIS.Editor.CreateShape(editLayer, startPt, TGIS_ShapeType.Polygon);
GIS.Mode := TGIS_ViewerMode.Edit;

Java

TGIS_Point startPt = GIS.ScreenToMap(new TPoint(evt.getX(), evt.getY()));
GIS.getEditor().CreateShape(editLayer, startPt, TGIS_ShapeType.Polygon);
GIS.setMode(TGIS_ViewerMode.Edit);

Python

start_pt = GIS.ScreenToMap(pdk.TPoint(int(x), int(y)))
GIS.Editor.CreateShape(edit_layer, start_pt, pdk.TGIS_ShapeType().Polygon)
GIS.Mode = pdk.TGIS_ViewerMode().Edit

Geometry and Spatial Analysis


Create a spatial buffer

TGIS_Topology.MakeBuffer() returns a polygon buffer of the input shape. Negative distances produce an inward (erosion) buffer.

→ API: TGIS_Topology: .NET/VB · Delphi · Java · AX · Py
TGIS_Shape: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Topology tpl    = new TGIS_Topology();
TGIS_Shape    buffer = tpl.MakeBuffer(sourceShp, 5000);  // 5 km
if (buffer != null)
{
    bufferLayer.RevertShapes();
    bufferLayer.AddShape(buffer);
    GIS.FullExtent();
}

VB.NET

Dim tpl    As New TGIS_Topology()
Dim buffer As TGIS_Shape = tpl.MakeBuffer(sourceShp, 5000)
If buffer IsNot Nothing Then
    bufferLayer.RevertShapes()
    bufferLayer.AddShape(buffer)
    GIS.FullExtent()
End If

Delphi

var tpl    := TGIS_Topology.Create;
var buffer := tpl.MakeBuffer(sourceShp, 5000);
if buffer <> nil then
begin
  bufferLayer.RevertShapes;
  bufferLayer.AddShape(buffer);
  GIS.FullExtent;
end;

Java

TGIS_Topology tpl    = new TGIS_Topology();
TGIS_Shape    buffer = tpl.MakeBuffer(sourceShp, 5000);
if (buffer != null) {
    bufferLayer.RevertShapes();
    bufferLayer.AddShape(buffer);
    GIS.FullExtent();
}

Python

tpl    = pdk.TGIS_Topology()
buffer = tpl.MakeBuffer(source_shp, 5000)
if buffer is not None:
    buffer_layer.RevertShapes()
    buffer_layer.AddShape(buffer)
    GIS.FullExtent()

Calculate geodetic area

AreaCS() returns the geodetically correct area in square metres.

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_CSUnits: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_CSUnits unit = TGIS_Utils.CSUnitsList.ByEPSG(904201);
labelArea.Text = unit.AsAreal(shape.AreaCS(), true, "%s\xB2");

VB.NET

Dim unit As TGIS_CSUnits = TGIS_Utils.CSUnitsList.ByEPSG(904201)
labelArea.Text = unit.AsAreal(shape.AreaCS(), True, "%s²")

Delphi

var unit_ := TGIS_Utils.CSUnitsList.ByEPSG(904201);
labelArea.Caption := unit_.AsAreal(shape.AreaCS(), True, '%s²');

Java

TGIS_CSUnits unit = TGIS_Utils.CSUnitsList.ByEPSG(904201);
labelArea.setText(unit.AsAreal(shape.AreaCS(), true, "%s²"));

Python

unit = pdk.TGIS_Utils.CSUnitsList.ByEPSG(904201)
label_area.Caption = unit.AsAreal(shape.AreaCS(), True, "%s²")

Calculate geodetic length / perimeter

LengthCS() returns cumulative length of polyline segments (or polygon perimeter) in metres.

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_CSUnits: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_CSUnits unit = TGIS_Utils.CSUnitsList.ByEPSG(904201);
labelLength.Text = unit.AsLinear(shape.LengthCS(), true);

VB.NET

Dim unit As TGIS_CSUnits = TGIS_Utils.CSUnitsList.ByEPSG(904201)
labelLength.Text = unit.AsLinear(shape.LengthCS(), True)

Delphi

var unit_ := TGIS_Utils.CSUnitsList.ByEPSG(904201);
labelLength.Caption := unit_.AsLinear(shape.LengthCS(), True);

Java

TGIS_CSUnits unit = TGIS_Utils.CSUnitsList.ByEPSG(904201);
labelLength.setText(unit.AsLinear(shape.LengthCS(), true));

Python

unit = pdk.TGIS_Utils.CSUnitsList.ByEPSG(904201)
label_length.Caption = unit.AsLinear(shape.LengthCS(), True)

Get the centroid of a shape

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_Point: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_Point center = shape.Centroid();
Console.WriteLine($"Lon={center.X:F4}, Lat={center.Y:F4}");

VB.NET

Dim center As TGIS_Point = shape.Centroid()
Console.WriteLine($"Lon={center.X:F4}, Lat={center.Y:F4}")

Delphi

var center := shape.Centroid();
Writeln(Format('Lon=%.4f, Lat=%.4f', [center.X, center.Y]));

Java

TGIS_Point center = shape.Centroid();
System.out.printf("Lon=%.4f, Lat=%.4f%n", center.getX(), center.getY());

Python

center = shape.Centroid()
print(f"Lon={center.X:.4f}, Lat={center.Y:.4f}")

Copy geometry between shapes

CopyGeometry() copies vertices without attributes. CreateCopy() makes a fully independent deep copy including attributes.

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_Lock: .NET/VB · Delphi · Java · AX · Py

C#

// Geometry only:
TGIS_Shape dst = dstLayer.CreateShape(TGIS_ShapeType.Polygon);
dst.Lock(TGIS_Lock.Extent);
dst.CopyGeometry(srcShape);
dst.Unlock();
 
// Full deep copy:
TGIS_Shape clone = srcShape.CreateCopy();
dstLayer.AddShape(clone);

VB.NET

' Geometry only:
Dim dst As TGIS_Shape = dstLayer.CreateShape(TGIS_ShapeType.Polygon)
dst.Lock(TGIS_Lock.Extent)
dst.CopyGeometry(srcShape)
dst.Unlock()
 
' Full deep copy:
Dim clone As TGIS_Shape = srcShape.CreateCopy()
dstLayer.AddShape(clone)

Delphi

// Geometry only:
var dst := dstLayer.CreateShape(TGIS_ShapeType.Polygon);
dst.Lock(TGIS_Lock.Extent);
dst.CopyGeometry(srcShape);
dst.Unlock;
 
// Full deep copy:
var clone := srcShape.CreateCopy;
dstLayer.AddShape(clone);

Java

// Geometry only:
TGIS_Shape dst = dstLayer.CreateShape(TGIS_ShapeType.Polygon);
dst.Lock(TGIS_Lock.Extent);
dst.CopyGeometry(srcShape);
dst.Unlock();
 
// Full deep copy:
TGIS_Shape clone = srcShape.CreateCopy();
dstLayer.AddShape(clone);

Python

# Geometry only:
dst = dst_layer.CreateShape(pdk.TGIS_ShapeType().Polygon)
dst.Lock(pdk.TGIS_Lock().Extent)
dst.CopyGeometry(src_shape)
dst.Unlock()
 
# Full deep copy:
clone = src_shape.CreateCopy()
dst_layer.AddShape(clone)

Affine transform — rotate a shape around its centroid

Transform() applies a 2D affine matrix to all vertices.

→ API: TGIS_Shape: .NET/VB · Delphi · Java · AX · Py
TGIS_Utils: .NET/VB · Delphi · Java · AX · Py

C#

double     angle    = Math.PI / 4;
double     cosA     = Math.Cos(angle);
double     sinA     = Math.Sin(angle);
TGIS_Point pivot    = shape.Centroid();
TGIS_Shape editable = shape.MakeEditable();
editable.Transform(
    TGIS_Utils.GisPoint3DFrom2D(pivot),
    cosA, sinA, -sinA, cosA, 0, 0,
    false, false, false);
GIS.InvalidateWholeMap();

VB.NET

Dim angle    = Math.PI / 4
Dim cosA     = Math.Cos(angle)
Dim sinA     = Math.Sin(angle)
Dim pivot    = shape.Centroid()
Dim editable = shape.MakeEditable()
editable.Transform(
    TGIS_Utils.GisPoint3DFrom2D(pivot),
    cosA, sinA, -sinA, cosA, 0, 0,
    False, False, False)
GIS.InvalidateWholeMap()

Delphi

var angle    := PI / 4;
var cosA     := Cos(angle);
var sinA     := Sin(angle);
var pivot    := shape.Centroid;
var editable := shape.MakeEditable;
editable.Transform(
  TGIS_Utils.GisPoint3DFrom2D(pivot),
  cosA, sinA, -sinA, cosA, 0, 0,
  False, False, False);
GIS.InvalidateWholeMap;

Java

double     angle    = Math.PI / 4;
double     cosA     = Math.cos(angle);
double     sinA     = Math.sin(angle);
TGIS_Point pivot    = shape.Centroid();
TGIS_Shape editable = shape.MakeEditable();
editable.Transform(
    TGIS_Utils.GisPoint3DFrom2D(pivot),
    cosA, sinA, -sinA, cosA, 0, 0,
    false, false, false);
GIS.InvalidateWholeMap();

Python

import math
angle    = math.pi / 4
cos_a    = math.cos(angle)
sin_a    = math.sin(angle)
pivot    = shape.Centroid()
editable = shape.MakeEditable()
editable.Transform(
    pdk.TGIS_Utils().GisPoint3DFrom2D(pivot),
    cos_a, sin_a, -sin_a, cos_a, 0, 0,
    False, False, False)
GIS.InvalidateWholeMap()

Import / convert a vector layer

ImportLayer() reads from a source layer and writes to the destination, optionally clipping to an extent and filtering by SQL.

→ API: TGIS_LayerVector: .NET/VB · Delphi · Java · AX · Py

C#

var src = (TGIS_LayerVector)GIS.Get("source");
var dst = (TGIS_LayerVector)TGIS_Utils.GisCreateLayer("clipped", @"C:\out\clipped.shp");
dst.ImportLayer(src, GIS.VisibleExtent, TGIS_ShapeType.Polygon, "AREA > 10000", true);

VB.NET

Dim src = CType(GIS.Get("source"), TGIS_LayerVector)
Dim dst = CType(TGIS_Utils.GisCreateLayer("clipped", "C:\out\clipped.shp"), TGIS_LayerVector)
dst.ImportLayer(src, GIS.VisibleExtent, TGIS_ShapeType.Polygon, "AREA > 10000", True)

Delphi

var src := TGIS_LayerVector(GIS.Get('source'));
var dst := TGIS_LayerVector(TGIS_Utils.GisCreateLayer('clipped', 'C:\out\clipped.shp'));
dst.ImportLayer(src, GIS.VisibleExtent, TGIS_ShapeType.Polygon, 'AREA > 10000', True);

Java

TGIS_LayerVector src = (TGIS_LayerVector)GIS.Get("source");
TGIS_LayerVector dst = (TGIS_LayerVector)TGIS_Utils.GisCreateLayer("clipped", "C:/out/clipped.shp");
dst.ImportLayer(src, GIS.getVisibleExtent(), TGIS_ShapeType.Polygon, "AREA > 10000", true);

Python

src = GIS.Get("source")
dst = pdk.TGIS_Utils.GisCreateLayer("clipped", "C:/out/clipped.shp")
dst.ImportLayer(src, GIS.VisibleExtent, pdk.TGIS_ShapeType().Polygon, "AREA > 10000", True)

Raster and Analysis


Open a raster layer

Raster files (GeoTIFF, ECW, JPEG 2000, etc.) use the same GIS.Open() call as vector data.

→ API: TGIS_ViewerWnd: .NET/VB · Delphi VCL · Delphi FMX · Java · AX · Py
TGIS_LayerPixel: .NET/VB · Delphi · Java · AX · Py

C#

GIS.Open(@"C:\data\elevation.tif");
GIS.FullExtent();

VB.NET

GIS.Open("C:\data\elevation.tif")
GIS.FullExtent()

Delphi

GIS.Open('C:\data\elevation.tif');
GIS.FullExtent;

Java

GIS.Open("C:/data/elevation.tif");
GIS.FullExtent();

Python

GIS.Open("C:/data/elevation.tif")
GIS.FullExtent()

Create an in-memory raster layer

TGIS_LayerPixel.Build() allocates a blank pixel buffer. Compute height from the extent aspect ratio to keep pixels square.

→ API: TGIS_LayerPixel: .NET/VB · Delphi · Java · AX · Py

C#

var src = (TGIS_LayerVector)GIS.Get("temperatures");
var dst = new TGIS_LayerPixel();
dst.Name = "grid";
TGIS_Extent ext = src.Extent;
int w = 400;
int h = Convert.ToInt32(Math.Round((ext.YMax - ext.YMin) / (ext.XMax - ext.XMin) * w));
dst.Build(true, src.CS, ext, w, h);
dst.Params.Pixel.GridShadow = false;
GIS.Add(dst);

VB.NET

Dim src = CType(GIS.Get("temperatures"), TGIS_LayerVector)
Dim dst As New TGIS_LayerPixel()
dst.Name = "grid"
Dim ext = src.Extent
Dim w   = 400
Dim h   = CInt(Math.Round((ext.YMax - ext.YMin) / (ext.XMax - ext.XMin) * w))
dst.Build(True, src.CS, ext, w, h)
dst.Params.Pixel.GridShadow = False
GIS.Add(dst)

Delphi

var src := TGIS_LayerVector(GIS.Get('temperatures'));
var dst := TGIS_LayerPixel.Create;
dst.Name := 'grid';
var ext := src.Extent;
var w   := 400;
var h   := Round((ext.YMax - ext.YMin) / (ext.XMax - ext.XMin) * w);
dst.Build(True, src.CS, ext, w, h);
dst.Params.Pixel.GridShadow := False;
GIS.Add(dst);

Java

TGIS_LayerVector src = (TGIS_LayerVector)GIS.Get("temperatures");
TGIS_LayerPixel  dst = new TGIS_LayerPixel();
dst.setName("grid");
TGIS_Extent ext = src.getExtent();
int w = 400;
int h = (int)Math.round((ext.getYMax() - ext.getYMin()) / (ext.getXMax() - ext.getXMin()) * w);
dst.Build(true, src.getCS(), ext, w, h);
dst.getParams().getPixel().setGridShadow(false);
GIS.Add(dst);

Python

src = GIS.Get("temperatures")
dst = pdk.TGIS_LayerPixel()
dst.Name = "grid"
ext = src.Extent
w   = 400
h   = round((ext.YMax - ext.YMin) / (ext.XMax - ext.XMin) * w)
dst.Build(True, src.CS, ext, w, h)
dst.Params.Pixel.GridShadow = False
GIS.Add(dst)

IDW interpolation from a point layer

TGIS_InterpolationIDW estimates grid cell values as a distance-weighted average of surrounding sample points. BusyEvent delivers progress: Pos=0 initialise, Pos>0 update, Pos<0 done.

→ API: TGIS_InterpolationIDW: .NET/VB · Delphi · Java · AX · Py
TGIS_LayerPixel: .NET/VB · Delphi · Java · AX · Py

C#

TGIS_InterpolationIDW vtg = new TGIS_InterpolationIDW();
vtg.Exponent   = 3.0;
vtg.BusyEvent += (s, ev) => {
    if      (ev.Pos == 0) progressBar.Maximum = (int)ev.EndPos;
    else if (ev.Pos  > 0) progressBar.Value   = (int)ev.Pos;
};
vtg.Generate(src, src.Extent, "TEMP", dst, dst.Extent);
 
dst.GenerateRamp(
    TGIS_Color.Blue, TGIS_Color.Lime, TGIS_Color.Red,
    dst.MinHeight, (dst.MaxHeight - dst.MinHeight) / 2.0, dst.MaxHeight,
    false,
    (dst.MaxHeight - dst.MinHeight) / 100.0,
    (dst.MaxHeight - dst.MinHeight) / 10.0,
    null, false);
GIS.FullExtent();

VB.NET

Dim vtg As New TGIS_InterpolationIDW()
vtg.Exponent = 3.0
AddHandler vtg.BusyEvent, Sub(s, ev)
    If ev.Pos = 0 Then      progressBar.Maximum = CInt(ev.EndPos)
    ElseIf ev.Pos > 0 Then  progressBar.Value   = CInt(ev.Pos)
End Sub
vtg.Generate(src, src.Extent, "TEMP", dst, dst.Extent)
 
dst.GenerateRamp(
    TGIS_Color.Blue, TGIS_Color.Lime, TGIS_Color.Red,
    dst.MinHeight, (dst.MaxHeight - dst.MinHeight) / 2.0, dst.MaxHeight,
    False,
    (dst.MaxHeight - dst.MinHeight) / 100.0,
    (dst.MaxHeight - dst.MinHeight) / 10.0,
    Nothing, False)
GIS.FullExtent()

Delphi

var vtg := TGIS_InterpolationIDW.Create;
vtg.Exponent := 3.0;
vtg.BusyEvent :=
  procedure(Sender: TObject; EventArgs: TGIS_BusyEventArgs)
  begin
    if EventArgs.Pos = 0 then      progressBar.Max      := Round(EventArgs.EndPos)
    else if EventArgs.Pos > 0 then progressBar.Position := Round(EventArgs.Pos);
  end;
vtg.Generate(src, src.Extent, 'TEMP', dst, dst.Extent);
 
dst.GenerateRamp(
  TGIS_Color.Blue, TGIS_Color.Lime, TGIS_Color.Red,
  dst.MinHeight, (dst.MaxHeight - dst.MinHeight) / 2.0, dst.MaxHeight,
  False,
  (dst.MaxHeight - dst.MinHeight) / 100.0,
  (dst.MaxHeight - dst.MinHeight) / 10.0,
  nil, False);
GIS.FullExtent;

Java

TGIS_InterpolationIDW vtg = new TGIS_InterpolationIDW();
vtg.setExponent(3.0);
vtg.Generate(src, src.getExtent(), "TEMP", dst, dst.getExtent());
 
dst.GenerateRamp(
    TGIS_Color.getBlue(), TGIS_Color.getLime(), TGIS_Color.getRed(),
    dst.getMinHeight(), (dst.getMaxHeight() - dst.getMinHeight()) / 2.0, dst.getMaxHeight(),
    false,
    (dst.getMaxHeight() - dst.getMinHeight()) / 100.0,
    (dst.getMaxHeight() - dst.getMinHeight()) / 10.0,
    null, false);
GIS.FullExtent();

Python

vtg          = pdk.TGIS_InterpolationIDW()
vtg.Exponent = 3.0
vtg.Generate(src, src.Extent, "TEMP", dst, dst.Extent)
 
dst.GenerateRamp(
    pdk.TGIS_Color().Blue, pdk.TGIS_Color().Lime, pdk.TGIS_Color().Red,
    dst.MinHeight, (dst.MaxHeight - dst.MinHeight) / 2.0, dst.MaxHeight,
    False,
    (dst.MaxHeight - dst.MinHeight) / 100.0,
    (dst.MaxHeight - dst.MinHeight) / 10.0,
    None, False)
GIS.FullExtent()

Quick-reference index

# Concept Key API API refs
01 Open a project or layer file GIS.Open() ViewerWnd · Utils
02 Add a layer via factory TGIS_Utils.GisCreateLayer() Utils · LayerAbstract
03 Navigate to full extent GIS.FullExtent() ViewerWnd
04 Batch updates without flicker GIS.Lock() / GIS.Unlock() ViewerWnd
05 Resolve sample data path GisSamplesDataDirDownload() Utils
06 Get layer by name GIS.Get(“name”) ViewerWnd · LayerVector
07 Get layer by index GIS.Items[0] ViewerWnd · LayerVector
08 Create in-memory layer new TGIS_LayerVector() LayerVector
09 Remove a layer GIS.Delete(“name”) ViewerWnd
10 Style polygon — solid fill Params.Area.Color / Pattern LayerVector · Color · BrushStyle
11 Style polygon — outline only Pattern = Clear BrushStyle · Color
12 Style line layer Params.Line.Color / Width LayerVector · Color
13 Style point / marker layer Params.Marker.Color LayerVector · Color
14 Layer transparency layer.Transparency = 50 LayerVector
15 Set interaction mode GIS.Mode = TGIS_ViewerMode.* ViewerWnd · ViewerMode
16 Zoom to layer extent GIS.Zoom = layer.ProjectedExtent ViewerWnd · LayerVector
17 Zoom to custom extent GIS.Zoom = GisExtent(…) Extent · Utils
18 Screen → map coordinates GIS.ScreenToMap(point) ViewerWnd · Point
19 Trigger map repaint GIS.InvalidateWholeMap() ViewerWnd
20 Handle map click TapSimpleEvent ViewerWnd · ViewerMode
21 Assign CS by EPSG layer.SetCSByEPSG(4326) LayerVector
22 Create CS by EPSG TGIS_CSFactory.ByEPSG(3395) CSFactory
23 Transform point between CS cs.FromCS(srcCS, point) CSFactory · Point
24 Format distance / area TGIS_CSUnits.AsLinear() / AsAreal() CSUnits · Utils
25 Iterate all shapes layer.Loop(extent, “”, null, “”) LayerVector · Shape
26 SQL attribute filter layer.Loop(ext, “FIELD > val”, …) LayerVector · Shape
27 Spatial extent filter layer.Loop(GIS.VisibleExtent, …) ViewerWnd · LayerVector
28 DE-9IM spatial query layer.Loop(ext, “”, shape, “T*FF*”) LayerVector · Shape
29 Read attribute shp.GetField(“FIELD”) Shape
30 Hit test at map position GIS.Locate(mapPt, 5/GIS.Zoom) ViewerWnd · Shape
31 Get shape by UID layer.GetShape(uid) LayerVector · Shape
32 Select / deselect shapes shp.IsSelected / DeselectAll() Shape · LayerVector
33 Create point shape CreateShape(Point) + AddPoint() LayerVector · ShapeType · Lock
34 Create polyline shape CreateShape(Arc) + AddPart() LayerVector · ShapeType · Lock
35 Create polygon shape CreateShape(Polygon) + AddPart() LayerVector · ShapeType · Lock
36 Bulk vertex edit pattern shp.Lock(Extent) … shp.Unlock() Shape · Lock
37 Pin file-backed shape shp.MakeEditable() Shape
38 Set shape attribute shp.SetField(“FIELD”, value) Shape
39 Delete all shapes layer.RevertShapes() LayerVector
40 Interactive editor GIS.Editor.CreateShape() ViewerWnd · ShapeType
41 Spatial buffer TGIS_Topology.MakeBuffer(shape, m) Topology · Shape
42 Geodetic area shape.AreaCS() Shape · CSUnits
43 Geodetic length / perimeter shape.LengthCS() Shape · CSUnits
44 Shape centroid shape.Centroid() Shape · Point
45 Copy / clone geometry CopyGeometry() / CreateCopy() Shape · Lock
46 Affine transform (rotate) shape.Transform(pivot, cos, sin, …) Shape · Utils
47 Vector layer import / clip dstLayer.ImportLayer(src, ext, …) LayerVector
48 Open raster layer GIS.Open(“file.tif”) ViewerWnd · LayerPixel
49 Create in-memory raster TGIS_LayerPixel.Build(true, cs, ext, w, h) LayerPixel
50 IDW interpolation TGIS_InterpolationIDW.Generate(…) IDW · LayerPixel

API refs column links to the .NET/VB.NET documentation. Each API page contains “Available also on: Delphi | Java | ActiveX | Python” links to the platform-specific equivalents.

2026/06/13 13:52

Page Tools