Skip to content

Instantly share code, notes, and snippets.

@pedros007
pedros007 / multi_should_be_multi.map
Last active January 5, 2018 20:26
MapServer MAP file demonstrating a MultiPolygon being converted to a single polygon. https://lists.osgeo.org/pipermail/mapserver-users/2018-January/080433.html
# This GIST is for a question to the MapServer mailing list:
# https://lists.osgeo.org/pipermail/mapserver-users/2018-January/080433.html
#
# Request a GeoJSON FeatureCollection via this:
# curl "http://localhost/mapserv?MAP=/usr/src/mapfiles/multi_should_be_multi.map&service=WFS&VERSION=1.1.0&REQUEST=getfeature&typename=should_be_multi&OUTPUTFORMAT=geojson&layer_id=23"
# I expect to receive one feature with
# "geometry": { "type": "MultiPolygon", "coordinates": ... }
# However, I get one feature with
# "geometry": { "type": "Polygon", "coordinates": ... }
@pedros007
pedros007 / gist:4343baeff14380a282bbb9d90cb9e2a8
Created September 5, 2017 17:13
GeoJSON WebMercator Tile Covering
import json
import tiletanic
from shapely import geometry, wkb, ops
from osgeo import ogr, osr
import pyproj
from functools import partial
# Cover a geometry with WebMercator tiles at zoom level 9.
# Should make a pull request to add something like this to the Tiletanic CLI
@pedros007
pedros007 / SimpleVSIMEMFile.py
Last active May 22, 2018 23:46
gdal /vsimem/ file writer. This is compatible with boto s3.Object#put(Body=SimpleVSIMemFile('/vsimem/foo.tif')
class SimpleVSIMemFileError(Exception):
"""Unknown SimpleVSIMemFile error with VSI subsystem."""
class SimpleVSIMEMFile(object):
def __init__(self, path):
"""Simple file-like object for reading out of a VSIMEM dataset.
Params:
path: /vsimem path to use
"""
self._path = path
@pedros007
pedros007 / mapcache-config.xml
Last active October 21, 2016 14:58
Mapcache config to generate a cache from a WMS
<?xml version="1.0" encoding="UTF-8"?>
<!-- docs: http://mapserver.org/mapcache/config.html -->
<!-- see the accompanying mapcache.xml.sample for a fully commented configuration file -->
<!-- sample config: https://github.com/mapserver/mapcache/blob/master/mapcache.xml.sample -->
<!-- Mapcache docker image that can work with this: https://github.com/yjacolin/docker-mapcache/blob/master/Dockerfile -->
<mapcache>
<cache name="disk" type="disk">
<base>/tmp/tilecache</base>
<symlink_blank/>
</cache>
@pedros007
pedros007 / australia5.wkb
Last active February 24, 2016 16:53
Multipolygon of Australia stored as WKB. Obtained via `select ST_AsBinary(geom) from aois where id=73 \g '/usr/src/app/australia5.wkb'` and https://bl.ocks.org/anonymous/raw/420fd0e7ef82131c54bb/ This is here for an RGeo issue I opened https://github.com/rgeo/rgeo/issues/139
010600000071120000010300000001000000ba6b0000a4703d0ad74862408cf678211d8043c0f10d85cfd648624000000000008043c0e7c8ca2f034862405000c5c8927f43c0e77118cc5f4862403d80457efd7e43c0ff5e0a0f9a486240d7a3703d0a7f43c05c21acc69248624087191a4f047d43c0b3d2a4147447624035eb8cef8b7543c0ebe3a1efee4562408fc2f5285c6f43c0992b836a0346624035eb8cef8b6d43c053ebfd46bb4562402b8a5759db6c43c0b0e8d66b7a456240b5dc9909866b43c0b3d2a41474456240ebc726f9116943c0c3633f8b254562408d800a47906643c02d6002b7ee4462407b14ae47e16643c0eb8cef8b4b446240e17a14ae476543c07e18213cda436240821fd5b0df6543c0b7973446eb43624009a9dbd9576643c0be6c3b6d0d446240d461855b3e6643c0dd5f3dee5b446240ab7b6473d56643c070cff3a70d446240ed7f80b56a6743c067d47c95fc436240c03dcf9f366843c0484f91434444624064ae0caa0d6843c0016e162f9644624087191a4f046943c01d3d7e6fd344624087191a4f046943c03e78edd206456240d461855b3e6a43c0c7d5c8aeb4446240bbd6dea7aa6a43c0b7973446eb446240f59eca694f6b43c0c47c7901f6446240c03dcf9f366c43c0ecbfce4d1b45624028486c770f6c43c03333333333456240bd715298f76c43c0865968e7b4456240a2b8