Skip to content

Instantly share code, notes, and snippets.

@lossyrob
lossyrob / gist:8983681
Created February 13, 2014 20:57
geotrellis-geotools dependency tree
[info] com.azavea.geotrellis:geotrellis-geotools_2.10:0.10.0-SNAPSHOT [S]
[info] +-com.azavea.geotrellis:geotrellis_2.10:0.10.0-SNAPSHOT [S]
[info] | +-com.azavea.geotrellis:geotrellis-macros_2.10:0.10.0-SNAPSHOT [S]
[info] | | +-org.scala-lang:scala-reflect:2.10.1 (evicted by: 2.10.2)
[info] | | +-org.scala-lang:scala-reflect:2.10.2 [S]
[info] | |
[info] | +-com.typesafe.akka:akka-actor_2.10:2.2.3 [S]
[info] | | +-com.typesafe:config:1.0.2
[info] | |
[info] | +-com.typesafe.akka:akka-cluster_2.10:2.2.3 [S]
@lossyrob
lossyrob / maptojson.scala
Created February 20, 2014 15:30
Mao to Json
// TODO: See if this is any good and worth refactoring. From some internal Scala code written by someone at Azavea.
package object json {
def quote(s:String) = if(s == null) "\"\"" else "\"" + (s.replace("\\", "\\\\").replace("\"", "\\\"")) + "\""
def quote(a:Any):String = if(a == null) "\"\"" else quote(a.toString)
def arrayToJson(left:String, as:Array[String], right:String) = if (as.length > 0) {
val n = as.foldLeft(0)(_ + _.length + 1) + left.length + right.length
val b = new StringBuilder(n)
b.append(left)
b.append(as(0))
@lossyrob
lossyrob / averagelotsofrasters.scala
Created June 25, 2014 16:58
AverageLotsOfRasters for GeoTrellis 0.8
package geotrellis.raster.op
import geotrellis._
import geotrellis.feature.Extent
import geotrellis.process._
import geotrellis.raster.op._
import geotrellis.testkit._
import geotrellis.raster.op.local.Add
import org.scalatest._
/** GDAL will translate a GeoTIFF with these boundies in EPSG:4326 -
* Upper Left ( -85.4969788, 35.4371767) ( 85d29'49.12"W, 35d26'13.84"N)
* Lower Left ( -85.4969788, 35.3464955) ( 85d29'49.12"W, 35d20'47.38"N)
* Upper Right ( -85.2701788, 35.4371767) ( 85d16'12.64"W, 35d26'13.84"N)
* Lower Right ( -85.2701788, 35.3464955) ( 85d16'12.64"W, 35d20'47.38"N)
* Center ( -85.3835788, 35.3918361) ( 85d23' 0.88"W, 35d23'30.61"N)
*
* to these boundry points in EPSG:3857 -
* Upper Left (-9517480.140, 4223451.561) ( 85d29'49.12"W, 35d26'13.84"N)
* Lower Left (-9517480.140, 4211063.427) ( 85d29'49.12"W, 35d20'47.24"N)
@lossyrob
lossyrob / WashingtonDC.wkt
Last active August 29, 2015 14:07
Washing DC transit system in at list of lines as WKT. MultiLineString([lines]).union ends up with an invalid MultiLineString.
This file has been truncated, but you can view the full file.
LINESTRING (-77.001406 38.825079, -77.001508 38.825046, -77.001406 38.825079, -77.00138 38.824887, -77.001353 38.824578, -77.001423 38.824358, -77.001591 38.824169, -77.002189 38.82389, -77.002175 38.823876, -77.00221 38.823879, -77.002011 38.823588, -77.001943 38.823399, -77.001921 38.823229, -77.001931 38.822728, -77.001941 38.822547, -77.001952 38.822279, -77.001961 38.821829, -77.00129 38.821289, -77.000743 38.821709, -77.000664 38.821766, -77.000643 38.821752, -76.999292 38.822807, -76.998492 38.823449, -76.998182 38.823676, -76.998099 38.82361, -76.998099 38.82361, -76.998101 38.823739, -76.997962 38.823849, -76.997344 38.824301, -76.997316 38.824282, -76.996921 38.824608, -76.99644 38.825, -76.996131 38.825249, -76.99591 38.825408, -76.99591 38.825413, -76.99591 38.825413, -76.993595 38.82723, -76.992603 38.827978, -76.992539 38.828044, -76.99202 38.828395, -76.991052 38.829198, -76.991013 38.829228, -76.99103 38.829244, -76.990473 38.829628, -76.988993 38.83079, -76.988932 38.830836, -76.98897 38.8308
@lossyrob
lossyrob / MergeQueue.scala
Last active August 29, 2015 14:12
Merge Queue: Queue which merges Long ranges.
package mergequeue
class MergeQueue(initialSize: Int = 1) {
private var array = if(initialSize <= 1) { Array.ofDim[(Long, Long)](1) } else { Array.ofDim[(Long, Long)](initialSize) }
private var _size = 0
def size = _size
private def removeElement(i: Int): Unit = {
if(i < _size - 1) {
@lossyrob
lossyrob / AccumuloAttributeCatalog.scala
Created December 24, 2014 16:31
Attribute Catalog classes
package geotrellis.spark.io.accumulo
import geotrellis.spark._
import geotrellis.spark.io._
import spray.json._
import scala.collection.JavaConversions._
import org.apache.spark.Logging
@lossyrob
lossyrob / fossdem-livecode.scala
Created February 1, 2015 13:30
Code that was live coded during the FOSDEM 2015 talk "Distributed Tile Processing with GeoTrellis and Spark"
import geotrellis.raster._
import geotrellis.vector._
import geotrellis.spark._
import geotrellis.spark.io.accumulo._
import org.apache.accumulo.core.client.security.tokens.PasswordToken
implicit val _sc = sc
// Get accumulo instance and the catalog.
@lossyrob
lossyrob / ingest-spatial.sh
Last active August 29, 2015 14:15
Spark submit for an ingest job in Accumulo
### INGEST SPATIAL GEOTIFF IN ACCUMULO ###
# geotrellis-spark JAR. Shouldn't have to change this one if running in the root folder (remember to run ./sbt "project spark" assembly)
JAR=/Users/rob/proj/gt/geotrellis/spark/target/scala-2.10/geotrellis-spark-assembly-0.10.0-SNAPSHOT.jar
# Directory with the input tiled GeoTIFF's
INPUT=file:/Users/rob/proj/climate/data/one-month-tiles
# Table to store tiles
TABLE=nexmonth
@lossyrob
lossyrob / index-gt-uzaygezen.scala
Created April 10, 2015 17:57
Indexes for SpatialKey and SpaceTimeKey using Uzaygezen
package geotrellis.spark.io.hadoop
import geotrellis.spark._
import geotrellis.raster._
// "com.google.uzaygezen" % "uzaygezen-core" % "0.2"
import com.google.uzaygezen.core.CompactHilbertCurve
import com.google.uzaygezen.core.MultiDimensionalSpec
import com.google.uzaygezen.core.BitVector
import com.google.uzaygezen.core.BitVectorFactories