Skip to content

Instantly share code, notes, and snippets.

@alamsal
alamsal / ArcmapCreateFeature
Last active August 29, 2015 14:16
Draw features in ArcMap using ArcGIS Addin tool (Arcobject's IRubberband Interface)
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
{
//create geometery
if (ArcMap.Document != null)
{
IScreenDisplay screenDisplay = ArcMap.Document.ActiveView.ScreenDisplay;
// Constants
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache);
// Explicit Cast
@alamsal
alamsal / QueryGDBTables
Last active August 29, 2015 14:16
Query personal gdb using ORDER BY and DISTINCT clause
public ICursor QueryRowViaQueryDef(IFeatureWorkspace featureWorkspace, String tables, String subFields, String whereClause)
{
// Create the query definition.
IQueryDef2 queryDef = featureWorkspace.CreateQueryDef() as IQueryDef2;
// Provide a list of table(s) to join.
queryDef.Tables = tables;
// Declare the subfields to retrieve.
queryDef.SubFields = subFields;
IMxDocument pMxDocument = ArcMap.Application.Document as IMxDocument;
IMap pMap = pMxDocument.FocusMap;
ILayer pLayer = pMap.get_Layer(0);
IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IFields pFields = (IFields)pFeatureClass;
ITable pTable = (ITable)pFeatureClass;
ICursor pCursor = pTable.Search(null, false);
IRow pRow = pCursor.NextRow();
while (pRow != null)
import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
/**
* Utility for converting ResultSets into some Output formats
@alamsal
alamsal / BoundaryCleanup.py
Created May 20, 2015 15:57
Tiler tools boundary clean up / An alternate to PIL Mogrify
import sys
from PIL import Image
imageFullPath = sys.argv[1]
rasterImage = Image.open(imageFullPath)
width,height = rasterImage.size
rasterImage = rasterImage.convert('RGBA')
pix = rasterImage.load()
@alamsal
alamsal / multidimensionalObjectArray.js
Created May 21, 2015 21:50
Multidimensional object array javascript
var indexes = {};
Data.forEach(function(indexPoint){
var zoneIndexes = indexes[indexPoint.zoneId];
if(zoneIndexes == null){
indexes[indexPoint.zoneId] = zoneIndexes = {};
}
zoneIndexes[indexPoint.date] = indexPoint.indexValue;
});
@alamsal
alamsal / default.hbs
Created July 21, 2015 22:32
Assemble: Multiple points of content insertion in layout
<!DOCTYPE html>
<html lang="en">
<head>
{{#block "head"}}
<meta charset="UTF-8">
<title>{{title}} | {{site.title}}</title>
<link rel="stylesheet" href="{{assets}}/{{stylesheet}}.css">
<link rel="stylesheet" href="{{assets}}/github.css">
{{/block}}
</head>
@alamsal
alamsal / ImageServiceRenderingrule.html
Created August 3, 2015 21:29
Image service rendering rule for FIA forest-type groups across the contiguous US
<html>
<head>
<meta charset=utf-8 />
<title>Identifying Imagery</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="//cdn.jsdelivr.net/leaflet/0.7.3/leaflet.css" />
<script src="//cdn.jsdelivr.net/leaflet/0.7.3/leaflet.js"></script>
<!-- Load Esri Leaflet from CDN -->
@alamsal
alamsal / forestSpecies.json
Last active August 29, 2015 14:26
Forest species sunbrust
{
"name" : "",
"children" :
[
{
"name" : "Softwoods",
"children" :
[
{
"order" : 1,
@alamsal
alamsal / forestSpecies.json
Created August 7, 2015 21:09
Forest Species Dendrogram
{
"name" : "",
"children" :
[
{
"name" : "Softwoods",
"children" :
[
{
"order" : 1,