Skip to content

Instantly share code, notes, and snippets.

View hugoledoux's full-sized avatar

Hugo Ledoux hugoledoux

View GitHub Profile
@hugoledoux
hugoledoux / citygml_solid.xml
Created April 12, 2014 19:13
Excerpt from a CityGML file containing one building modelled as a <gml:Solid>
<?xml version="1.0" encoding="utf-8"?>
<CityModel ... >
<cityObjectMember>
<bldg:Building>
<bldg:lod1Solid>
<gml:Solid>
<gml:exterior>
<gml:CompositeSurface>
<gml:surfaceMember>
<gml:Polygon>
@hugoledoux
hugoledoux / citygml_multisurface.xml
Created April 12, 2014 19:19
Excerpt from a CityGML file containing one building modelled as a <gml:MultiSurface>
<?xml version="1.0" encoding="utf-8"?>
<CityModel ... >
<cityObjectMember>
<bldg:Building>
<bldg:lod1MultiSurface>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hugoledoux
hugoledoux / wkt2geojson.py
Last active August 29, 2015 14:10
WKT --> simple geojson file
import json
from shapely.wkt import loads
allgeoms = []
# 0. valid square
allgeoms.append(loads('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'))
# 1. both rings same orientation
allgeoms.append(loads('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 3 1, 3 3, 1 1))'))
@hugoledoux
hugoledoux / 021L.geojson
Created December 29, 2014 09:59
Example of a rather big polygon, part of the Canada Land Cover dataset. It has 148,612 vertices in total, and 5,132 inner rings.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hugoledoux
hugoledoux / aretrianglesvalid.py
Last active August 29, 2015 14:16
are the triangles in a shapefile valid?
import sys
import os
import fiona
from shapely.geometry import Polygon
from shapely.geometry import asShape
from shapely.geometry import mapping
#-- Global variables
INFILE = "Vlak_3D_LOD0/terreinVlak_3D_LOD0.shp"
@hugoledoux
hugoledoux / gmlsolid.gml
Last active August 29, 2015 14:19
GML solid with one interior rings and one interior shell
<gml:Solid>
<gml:exterior>
<gml:CompositeSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:pos>0.000000 0.000000 1.000000</gml:pos>
<gml:pos>1.000000 0.000000 1.000000</gml:pos>
<gml:pos>1.000000 1.000000 1.000000</gml:pos>
@hugoledoux
hugoledoux / geos_orient.py
Last active December 23, 2015 17:59
GEOS doesn't check the orientation of rings, ie if oring and iring have same orientations then it's still valid
from shapely.wkt import loads
wkt = 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (1 1,3 1, 3 3, 1 1))'
p = loads(wkt)
print p.exterior.is_ccw
print p.interiors[0].is_ccw
print "p valid?", p.is_valid
print p.wkt
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/Solarized (Light) (SL).tmTheme",
"dictionary": "Packages/Language - English/en_GB.dic",
"font_face": "Source Code Pro",
"font_size": 14.0,
"highlight_line": true,
"highlight_modified_tabs": true,
"hot_exit": false,
@hugoledoux
hugoledoux / RulesLaTeX.md
Last active December 30, 2015 18:39
The Rules for happily collaborating on a LaTeX document

The Rules for happily collaborating on a LaTeX document

1. You shall use only one sentence per line.

Use one empty line to start a new paragraph

2. You shall use natbib for citations

\usepackage[round]{natbib}
...