Skip to content

Instantly share code, notes, and snippets.

@geographika
geographika / assign_points_to_polygons.sql
Created December 19, 2010 12:13
A SQL statement to assign points a polygon ID
UPDATE child SET ParentId = parent.FID
FROM ChildTableName child
,ParentTableName parent
WHERE ChildTableName.GEOM.STWithin(parent.GEOM) = 1
@geographika
geographika / show_points_and_polys.sql
Created December 19, 2010 13:11
SQL code to mix two geometry types in a temporary table
--sample assumes two tables - reference.Townland and bioenergy.soils
--create a sample area by buffering a point
DECLARE @g AS geometry;
SET @g = geometry::STGeomFromText('POINT (200000 200000)', 29902).STBuffer(1000);
--create a temporary table variable to store results
DECLARE @results TABLE (GEOM Geometry);
--select all the polygons in our sample area and add them to the same table
INSERT INTO @results
@geographika
geographika / PDF_Thumbnails.py
Created January 18, 2011 18:17
A simple script to generate thumbnail previews of PDFs. Requires ImageMagick and Ghostscript
import subprocess
import shlex, os, glob
#ensure ImageMagick and Ghostscript are installed
#tested on Python 2.7 / Windows XP
#this folder contains the convert.exe
image_magick_path = "C:\\Program Files\\ImageMagick-6.6.7-Q16\\"
os.chdir(image_magick_path)
@geographika
geographika / LinearReferencingExample.sql
Created January 22, 2011 18:48
Sample SQL code to demonstrate linear referencing in SQL Server
--example use of the CreateLinearReferenceFeature function
--see http://geographika.co.uk/linear-referencing-in-sql-server-2008 for details
--can be run directly in Management Studio once the Register.sql
--script has added the SQLSpatialTools.dll to the database
DECLARE @original_line AS geometry
--create a line feature
SET @original_line = geometry::STGeomFromText('LINESTRING (313401 232075,
313401.6885 232075.662,
313419.0265 232036.7775, 313434.913 232000.2635, 313456.0535 231952.438,
@geographika
geographika / arcobjects_python.py
Created April 17, 2011 11:31
ArcObjects and Python
def AppendPaths(paths):
"""Append all the paths with DLLs to be used by the script to the Python Path"""
import sys
for p in paths:
sys.path.append(p)
def AddReferences(refs):
"""Add references to the required DLLs"""
import clr
@geographika
geographika / gist:1019119
Created June 10, 2011 15:51
Sample WFS Request
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="Test" srsName="EPSG:900913">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<ogc:PropertyName>the_geom</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:900913">
<gml:lowerCorner>-773942.72965167 6944065.5166421</gml:lowerCorner>
<gml:upperCorner>-768936.10429989 6946745.5899459</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
@geographika
geographika / gist:1019212
Created June 10, 2011 16:28
WFS Sample MapFile
MAP
NAME "MyMap"
WEB
METADATA
"ows_enable_request" "*"
"wfs_srs" "EPSG:29902 EPSG:900913" #this setting has #1 priority
"ows_srs" "EPSG:29902 EPSG:900913" #this setting is used if no wfs_srs is present
END
END
# If your map does not have a projectionobject then WMS layers will return errors such as:
@geographika
geographika / wms_tester.py
Created June 23, 2012 15:03
A Python script to automatically check WMS services return images, and check images are not blank.
"""
Copyright (C) 2012 S. Girvin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
@geographika
geographika / nosetemplate.py
Created October 10, 2012 18:35
node template sample
from nose.plugins import Plugin
class HtmlOutput(Plugin):
"""
This is the plugin class
A simple HTMLPlugin can be seen at https://github.com/nose-devs/nose/blob/master/examples/html_plugin/htmlplug.py
However this does not use templates
"""
pass
@geographika
geographika / LayerParamNode.js
Last active September 5, 2015 18:54
GeoExt.tree.LayerParamNode work in progress
/*
* Copyright (c) 2008-2015 The Open Source Geospatial Foundation
*
* Published under the BSD license.
* See https://github.com/geoext/geoext2/blob/master/license.txt for the full
* text of the license.
*/
/*
* @requires GeoExt/Version.js