Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Gratier ThomasG77

View GitHub Profile
View README.md

Alternative to bundle with full projection support

Some people prefers using a full bundle Proj4js (https://github.com/DanielJDufour/proj4-fully-loaded). For server side, I like the approach but for client side, it bothers me to get the full bundle as I prefer loading on the fly the projection(s)

I made a short sample with two approaches (see comments in index.js). Code depends from availability from http://epsg.io and related APIs

Recipe to try the sample

git clone https://gist.github.com/f5a6a1b8d5a2b7c3f6c8f8d3745c535c load-proj4js-on-the-fly
View read_line_by_line_yield.py
import json
def csv_reader(file_name):
for row in open(file_name, "r"):
yield row
total = 0
for line in csv_reader("full.sjson"):
content = json.loads(line)
if 'housenumbers' in content:
View README.md

Read nested element from GeoJSON and GDAL SQLite dialect

ogrinfo -dialect SQlite -sql "SELECT a_property, json_extract(some_object, '$.another_property') AS another_property, json_extract(some_object, '$.last_prop[1]') AS subarrayelement, geometry FROM demo" /tmp/demo.geojson

We use functions presented at https://www.sqlite.org/json1.html to manipulate JSON in SQLite

View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Display a map on a webpage</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v1.13.1/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v1.13.1/mapbox-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
View qtnetwork.py
#!/usr/bin/python
'''
QNetworkAccessManager in PyQt
In this example we get a web page.
Author: Jan Bodnar
Website: zetcode.com
'''
View README.md
View check-ign-data-availability.py
import re
import urllib.request
from bs4 import BeautifulSoup
url = 'https://geoservices.ign.fr/documentation/diffusion/telechargement-donnees-libres.html'
urls = []
with urllib.request.urlopen(url) as f:
View report-http-broken.txt
├─BROKEN─ https://wxs.ign.fr/q2vmpil73wqufui9guglnusl/telechargement/prepackage/SCAN500-E080_PACK_GUF_2014-02-01%24SCAN500_1-0__JP2-E080_UTM22RGFG95_D973_2014-02-01/file/SCAN500_1-0__JP2-E080_UTM22RGFG95_D973_2014-02-01.7z (HTTP_404)
├─BROKEN─ https://orthohr:orthohr@wxs.ign.fr/o5eat18emvtnmvp2vtyfihlg/telechargement/prepackage/ORTHOHR-JP2_PACK_D016_2017-01-01%24ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01/file/ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01.7z.001 (HTTP_401)
├─BROKEN─ https://orthohr:orthohr@wxs.ign.fr/o5eat18emvtnmvp2vtyfihlg/telechargement/prepackage/ORTHOHR-JP2_PACK_D016_2017-01-01%24ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01/file/ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01.7z.002 (HTTP_401)
├─BROKEN─ https://orthohr:orthohr@wxs.ign.fr/o5eat18emvtnmvp2vtyfihlg/telechargement/prepackage/ORTHOHR-JP2_PACK_D016_2017-01-01%24ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01/file/ORTHOHR_1-0_RVB-0M20_JP2-E080_LAMB93_D016_2017-01-01.7z.003 (HTTP_401)
├─BROKEN─