Skip to content

Instantly share code, notes, and snippets.

View tomkralidis's full-sized avatar
🛠️
geohacking

Tom Kralidis tomkralidis

🛠️
geohacking
View GitHub Profile
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" service="CSW" version="2.0.2" resultType="results" startPosition="1" maxRecords="5" outputFormat="application/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd" xmlns:gml="http://www.opengis.net/gml" xmlns:gmd="http://www.isotc211.org/2005/gmd" outputSchema="http://www.isotc211.org/2005/gmd">
<csw:Query typeNames="gmd:MD_Metadata">
<csw:ElementSetName>brief</csw:ElementSetName>
<csw:Constraint version="1.1.0">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>apiso:TopicCategory</ogc:PropertyName>
<ogc:Literal>imageryBaseMapsEarthCover</ogc:Literal>
</ogc:PropertyIsEqualTo>
@tomkralidis
tomkralidis / geonode-update-metadata
Created September 23, 2012 13:28
GeoNode update_metadata
def update_metadata(layer_uuid, xml, saved_layer):
"""Update metadata XML document with GeoNode specific values"""
# check if document is XML
try:
exml = etree.fromstring(xml)
except Exception, err:
raise GeoNodeException('Uploaded XML document is not XML: %s' % str(err))
# check if document is an accepted XML metadata format
try:
tagname = exml.tag.split('}')[1]
@tomkralidis
tomkralidis / pycsw-windows-install
Last active December 15, 2015 19:29
pycsw Windows Installation
Install Dependencies:
- Python (2.7 series)
- http://python.org/download/
Install Package Management Tools
- download http://python-distribute.org/distribute_setup.py
- C:\python27\python.exe distribute_setup.py
Install Virtual Environment
- C:\python27\scripts\easy_install.exe virtualenv
@tomkralidis
tomkralidis / inasafe-impact-function-format
Last active December 20, 2015 03:09
Sample impact function format proposal as per https://github.com/AIFDR/inasafe/issues/587
<?xml version="1.0" encoding="UTF-8"?>
<Record
xmlns="http://www.opengis.net/cat/csw/2.0.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/record.xsd">
<dc:identifier>123</dc:identifier>
<dc:title>My Impact function calculation</dc:title>
<dct:modified>2013-07-23T11:01:41Z</dct:modified>
<dct:abstract>This is my impact function description</dct:abstract>
<dc:type>model</dc:type>
<dc:subject>impact</dc:subject>
<dc:subject>function</dc:subject>
import sys
import csv
from slugify import slugify
with open('posts.csv') as csvfile:
for row in csv.reader(csvfile):
slug = '%s-%s' % (row[0], slugify(unicode(row[1])))
content = '''---
layout: default
title: %s
@tomkralidis
tomkralidis / validate-multi-xsd
Created October 26, 2013 12:23
using Python lxml to do XML Schema validation on a document, against multiple XML Schema (courtesy @rouault)
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Portions coming from EOxServer
# ( https://github.com/EOxServer/eoxserver/blob/master/eoxserver/services/testbase.py )
# Copyright (C) 2011 EOX IT Services GmbH
#
# 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
@tomkralidis
tomkralidis / build.sh
Last active December 31, 2015 05:58
WorldWeatherSymbols usage in MapServer
#!/bin/sh
WMO_SYMBOLS_DIR=build/WorldWeatherSymbols
if [ ! -d $WMO_SYMBOLS_DIR ]; then
echo "Downloading WMO World Weather Symbols"
git clone https://github.com/OGCMetOceanDWG/WorldWeatherSymbols.git $WMO_SYMBOLS_DIR
echo "Converting all symbols to PNG"
$WMO_SYMBOLS_DIR/scripts/wws_manage.sh png
@tomkralidis
tomkralidis / test_ckan_harvest_objects.py
Last active December 31, 2015 19:29
Test to exemplify CKAN API issue of false positive harvested objects
# test to exemplify CKAN API issue of false positive harvested objects
# Example invocation:
# python test_ckan_harvest_objects.py https://data.noaa.gov 1c7cb5dd-f2ca-4aad-b971-af251c1acf4d
import sys
from urllib2 import urlopen
import requests
if len(sys.argv) < 3:
@tomkralidis
tomkralidis / dublin_core_rdf.liquid
Last active August 29, 2015 14:02
Dublin Core RDF template
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:ows="http://www.opengis.net/ows">
<rdf:Description rdf:about="{{ record.identifier }}">
<dc:identifier>{{ record.identifier }}</dc:identifier>
<dc:title>{{ record.title }}</dc:title>
<dc:type>{{ record.type }}</dc:type>
<dc:format>{{ record.format }}</dc:format>
<dc:description>{{ record.description }}</dc:description>
<dct:abstract>{{ record.abstract }}</dct:abstract>
<dct:modified>{{ record.modified }}</dct:modified>
@tomkralidis
tomkralidis / iso_keywords_analyzer.py
Created June 22, 2014 14:07
ISO metadata keywords analyzer
# scan a directory of ISO metadata files
# and generate a keyword frequency count
from glob import glob
import os
from pprint import pprint
import sys
from lxml import etree