Skip to content

Instantly share code, notes, and snippets.

View ianturton's full-sized avatar
🏠
Working from home

Ian Turton ianturton

🏠
Working from home
View GitHub Profile
@ianturton
ianturton / torchgeo_object_detection_example.ipynb
Created March 8, 2024 16:26 — forked from calebrob6/torchgeo_object_detection_example.ipynb
Short example of object detection training in TorchGeo.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ianturton
ianturton / BufferPoint.java
Created February 17, 2021 11:47
Find polygons with in a set distance of a point
package com.ianturton.cookbook.operations;
import java.awt.geom.Point2D;
import java.util.List;
import javax.measure.Quantity;
import javax.measure.Unit;
import javax.measure.UnitConverter;
import javax.measure.quantity.Length;
@ianturton
ianturton / NullIslands.java
Created November 19, 2020 11:43
Simple GeoTools code to generate the Null Island archipelago
package com.ianturton.cookbook.projections;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.cli.CommandLine;
@ianturton
ianturton / OSGridTest.java
Created April 20, 2020 12:44
OS Grid Reference conversion
package spike;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.locationtech.jts.geom.Coordinate;
public class OSGridrefTest {
@Test
@ianturton
ianturton / README.md
Last active October 19, 2019 08:23
Python for finding the minimum number of place names to fill the alphabet

Once I asked a question on gis.stackexchange.com which lead to a chunk of the UK academic production being lost for the day. But anyway we decided that we needed to vectorise the font typeface.

This led me to think about how many towns (or county boroughs) we actually needed to get all the letters of the alphabet, this code answers the question - 6. 'Newcastle upon Tyne', 'Wolverhampton', 'Kingston upon Hull', 'West Bromwich', 'Merthyr Tydfil', 'Halifax' Provided that you don't care about J, Q & Z!

Update

@ianturton
ianturton / UpdateByPolygon.java
Created January 9, 2018 13:48
A basic and inefficient program to replace a polygon's area in a raster with a new value using GeoTools.
package com.ianturton.cookbook.raster;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
import javax.media.jai.RasterFactory;
import org.geotools.coverage.CoverageFactoryFinder;
import org.geotools.coverage.grid.GridCoordinates2D;
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>USA states population</Name>
<UserStyle>
<Name>population</Name>
<Title>Population in the United States</Title>
<Abstract>A sample filter that filters the United States into three
@ianturton
ianturton / install.sh
Last active September 4, 2017 11:59
Installing ZooWPS on Ubuntu
# install mandatory libs etc
sudo apt-get install autoconf
sudo apt-get install gettext
sudo apt-get install curl
sudo apt-get autoremove
sudo apt-get install fastcgi
sudo apt-get install libfcgi libfcgi-dev
sudo apt-get install libapache2-mod-fastcgi
sudo apt-get install flex bison
sudo apt-get install libxml2 libxml2-dev
@ianturton
ianturton / CellTower.java
Last active October 27, 2021 11:23
GeoTools program to calculate a wedge shaped polygon 10 degrees wide given a lat,lon radius and azimuth.
package spike;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import org.geotools.referencing.GeodeticCalculator;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
@ianturton
ianturton / GenerateRandomData.java
Created July 20, 2016 12:11
A simple class to create random test data with GeoTools
package com.ianturton.cookbook.utilities;
import java.util.ArrayList;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;