Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose a programmer has no knowledge of GIS, but wants to leverage his/her programming skills to get into GIS. Please list different GIS platforms, packages, etc. that use a particular language.

(I was thinking, as suggested, about doing a simple test of the code formatting capability of StackExchange. I figure this might be done in the context of a useful answer.)

When you answer, if the language is one of those listed below, please post a code snippet and test the formatting to make sure it works. Here's an excerpt from Jeff Atwood's answer on meta-stackoverflow.

The spec is:

<!-- language: lang-or-tag-here -->

    code goes here

<!-- language: lang-or-tag-here -->

    code goes here

You may use either a tag or a prettify language code to specify, though prettify language codes are always guaranteed to work regardless of what language the tag happens to be set to.

Use <!-- language-all: lang-or-tag --> to use the given highlighting for all the following code blocks.

The complete list of supported prettify code languages is:

  • lang-none
  • lang-default
  • lang-bsh
  • lang-c
  • lang-cpp
  • lang-cs
  • lang-csh
  • lang-css
  • lang-hs
  • lang-html
  • lang-java
  • lang-js
  • lang-lisp
  • lang-lua
  • lang-ml
  • lang-perl
  • lang-php
  • lang-py
  • lang-proto
  • lang-rb
  • lang-scala
  • lang-sh
  • lang-sql
  • lang-vb
  • lang-xml
share|improve this question

Some geospatial scripting languages:

1) Python/Jython

Python/Jython alone:

Python and Jython can be used alone for processing geospatial data without any software, using modules like osgeo (GDAL / OGR), PySAL, Shapely, Fiona, Pyshp,..., see Python Package Index, Topic:GIS or Geoscript (Jython). There are many examples on GST

as scripting language in applications

QGIS, GRASS GIS, GvSIG, OpenJump or Geoserver (and ArcGIS, see above) use Python/Jython for scripting:

  • Quantum GIS ( Python, 1.8, changes in master version)
from qgis.core import *
layer = qgis.utils.iface.activeLayer()
for elem in layer.selectedFeatures():
        geom= elem.geometry()
        attrs = elem.attributeMap()
  • GRASS GIS (Python)
from grass.script import raster as grassr
{'north':118869.900569, 'timestamp': '"none"', 'min': -456.08587646484398,
'datatype': 'FCELL', 'max': 265.500732421875, 'ewres':
 14.008076920000001, 'vertical_datum': '', 'west': 164160.653425,
 'units': '', 'title': ' (s_newfrst3)', 'east': 176641.849961, 'nsres':
  13.976472729999999, 'south': 112552.534895}
  • GvSIG (Jython)
from gvsig import *
layer = currentLayer()
features = layer.features()
for feature in features:
  geom = feature.geometry()
  values = feature.getValues()
  • OpenJump (Jython)
from org.openjump.util.python.JUMP_GIS_Framework import *
layer = getSelectedLayers()
for i in layer.iterator():
# first element of the layer
fc = layer[0].featureCollectionWrapper
for elem in range(fc.size):
    obj = fc.features[elem] 
    geom = obj.getGeometry()
  • GeoServer (Jython)
from geoserver import Catalog
cat = Catalog('aff_geol')
print cat.stores()
[u'affleurements', u'cartes']
st = cat['affleurements']
print st.layers()
l = st['affs']
print l.count()
print l.bounds()
(107206.74,148102.45,114110.46,157514.40, EPSG:31370)

and you can also use other Java libraries like the Java Topology Suite( Jython):

import sys
from com.vividsolutions.jts.geom import Point

2) Bash

GRASS GIS uses Bash (shell and scripts (.sh))

GRASS 6.4.2 (geol):~ > v.out.ascii in=ligneprofil format=standard | grep '^ '|\r.profile -c in=MNT res=30 output=profil.pts

3) R (no prettify code language)

You can use R for all geospatial treatments, see CRAN Task View: Analysis of Spatial Data:

geol <-readShapePoly("cal.shp")
geol = readOGR(dsn=".", layer="cal")
geol = importShapefile("cal.shp")
geol <- read.shapefile("cal")
# PostGIS
geol = readOGR("PG:dbname=test", "cal")

but GRASS GIS can also uses R directly:

GRASS 6.4.2 (geol):~ > R
R version ....
> library(spgrass6) 
> G <- gmeta6() # paramètres de Grass, région etc.
> montrait <- readRAST6(c("geologie", "mnt"),cat=c(TRUE, FALSE),  ignore.stderr=TRUE,plugin=NULL)

4) BeanShell(Java)

OpenJump can also use Beanshell (console or script)

layer = wc.layerManager .getLayer("road").featureCollectionWrapper;
getLongest() {
    max = -1;
    for (f : layer.features) { length = f.geometry.length; if (f.geometry.length > max) {max = length; result = f;}
return result;

5) Groovy (Java), Scala and JavaScript

You can use theses languages with GeoScript, see examples

6) JEQL Query Language

As shown by Martin Davis (label jeql)

shapefileReader t file: "agder/agder_buffer.shp";
t = select geomUnionMem(GEOMETRY) g from t;
ShapefileWriter t file: "result.shp";
share|improve this answer

Old school GIS without computers. lang-none

    Overlay acetate on paper maps, buffer with rulers,
    symbolize with dry-erase markers.
    No computers, so no language needed.
share|improve this answer

C# can be used to program ArcGIS. With ArcObjects this involves dealing with a lot of COM interop, so any knowledge there would be very helpful.

C# can also be used (without dealing with much interop) in the ArcGIS for WPF and the ArcGIS for Silverlight SDK's.

public static IPolyline MakePolyline(IPoint p1, IPoint p2)
    var polyline = new PolylineClass() as IPolyline;
    ((IZAware)polyline).ZAware = true;
    ((IMAware)polyline).MAware = true;
    polyline.SpatialReference = p1.SpatialReference;
    return polyline;
share|improve this answer

A lot of WebGIS development is done via JavaScript. Here is some sample code using OpenLayers:

        var lon = 5;
        var lat = 40;
        var zoom = 5;
        var map, layer;

        function init(){
            map = new OpenLayers.Map( 'map' );
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "", {layers: 'basic'} );

            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            map.addControl( new OpenLayers.Control.LayerSwitcher() );
share|improve this answer

ArcGIS since 10.0 uses Python via the arcpy module.

Using the Python that comes with ArcGIS:

import arcpy

# Make dictionary of lookup table
dictCityProvince = {}
rows = arcpy.SearchCursor(r"C:\temp\test.gdb\CityProvinceLookup")
for row in rows:
    dictCityProvince[row.CITY] = row.PROVINCE
del row,rows

If this works, then you should be good to go.

share|improve this answer

Development for the Android Platform is done using Java.

Here is some code from the OsmDroid project:

 * Logs all Location-changes to <code>mRouteRecorder</code>.
 * @author plusminus
private class SampleLocationListener implements LocationListener {
    public void onLocationChanged(final Location loc) {
        if (loc != null) {
            if (SampleMapActivity.this.mDoGPSRecordingAndContributing)

        } else {
share|improve this answer

A lot of projects are developed in C++.

Here is some source code from QGis:

  Open the specified project file; prompt to save previous project if necessary.
  Used to process a commandline argument or OpenDocument AppleEvent.
void QgisApp::openProject( const QString & fileName )
  // possibly save any pending work before opening a different project
  if ( saveDirty() )
    // error handling and reporting is in addProject() function
    addProject( fileName );
  return ;
share|improve this answer

C can be used with the ArcSDE C API.

I see that it can be downloaded for 10.1 here, but is not mentioned in the list of API's on the help page. I don't see any online help for 10.1, only 10.0 help.

void check_rc_(SE_CONNECTION Connection, SE_STREAM Stream, LONG rc, 
                 char *comment, LONG line_no, char* file_name) ;
static LONG S_create_layer (SE_CONNECTION connection, CHAR *table,CHAR *keyword,LONG precision);
static LONG S_point_cases(SE_CONNECTION connection,const CHAR* table);
static LONG S_line_cases(SE_CONNECTION connection,const CHAR* table);
static LONG S_polygon_cases(SE_CONNECTION connection,const CHAR* table);

LONG  main(int argc, char *argv[]){
    CHAR            *server, 
    SE_CONNECTION   conn;
    SE_ERROR        error;
    LONG            result;
    BOOL            all_step_passed=TRUE;

        printf("usage: %s <server> <instance> <database> <user> <passwd> <result_layer>",argv[0]);


    printf("\nConnecting to SDE server %s:%s as %s\n",server,instance,user);
    result = SE_connection_create( server, instance, database, user, passwd, &error, &conn );

    /*Create a layer to store results*/
    printf("\n\nCreating a layer to store results......\n");
    result=S_create_layer (conn,rslt_layer_name,"DEFAULTS",64);
        return result;
        printf("\tLayer %s created.\n",rslt_layer_name);

    /*point shapes*/
    printf("* Generating buffer for point shapes......                                *\n");
        return result;

    /* line shapes */
    printf("* Generating buffer for line shapes......                                 *\n");
        return result;

    /* polygon shapes */
    printf("* Generating buffer for polygon shapes......                              *\n");
        return result;


share|improve this answer

Visual Basic

Sub SelectByBufferedLine()
    Dim xy As String
    xy = InputBox("Enter x,y coordinates for line in metres. x1,y1 x2,y2 ...xn,yn e.g. 200000,200000 250000,200000 280000,250000", "Select by buffered line (keyboard input)")
    If (xy = "") Then Exit Sub
    xy = Replace(xy, " ", ",")
    xy = Replace(xy, ",,", ",")
    Dim arr As Object
    arr = Split(xy, ",")
    Dim numvals As Integer, n As Object
    numvals = (UBound(arr, 1) - LBound(arr, 1)) + 1
    If (numvals < 4) Or ((numvals Mod 2) <> 0) Then Exit Sub
    For Each n In arr
        If (Not IsNumeric(n)) Then Exit Sub
    ' Create polyline from array of x,y's
    Dim pt As IPoint
    pt = New Geometry.Point
    Dim pGeometry As IGeometry
    pGeometry = New Polyline
    Dim thePointCollection As IPointCollection
    thePointCollection = pGeometry
    Dim i As Long
    For i = LBound(arr, 1) To UBound(arr, 1) - 1 Step 2
        pt.PutCoords(arr(i), arr(i + 1))
    ' Buffer the line
    Dim topoOP As ITopologicalOperator
    Dim theBufferPoly As IPolygon
    topoOP = pGeometry
    Dim bufdist As String
    bufdist = InputBox("Enter buffer distance(m)", "Select by buffered line", 0)
    If (Not IsNumeric(bufdist)) Then Exit Sub
    theBufferPoly = topoOP.Buffer(bufdist)
    pGeometry = theBufferPoly
    ' Query the Active Layer
    Call SpatialQuery(My.ArcMap.Application, pGeometry)
    ' Set Visible Extent
    Dim pDoc As IMxDocument = My.ArcMap.Document
    Dim theExtent As IEnvelope
    theExtent = pGeometry.Envelope
    theExtent.Expand(2, 2, True)
    pDoc.ActiveView.Extent = theExtent
End Sub
share|improve this answer

Your Answer


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.