Skip to content

Instantly share code, notes, and snippets.

View BishopGIS's full-sized avatar

Dmitry Baryshnikov BishopGIS

  • NextGIS
  • Russia, Moscow
View GitHub Profile
@BishopGIS
BishopGIS / response
Last active August 5, 2019 10:31
api response
{
"features": [
{
"attrs": {
"address": "г. Москва, ул. Озерная, вл. 49, стр. 1",
"cn": "77:07:0014004:7068",
"id": "77:7:14004:7068"
},
"center": {
"x": 4168166.7754504266,
@BishopGIS
BishopGIS / err.log
Created September 4, 2019 07:46
geoserver wms
Uncaught UnicodeEncodeError at http://0.0.0.0:8080/api/component/render/image?resource=5&extent=9400684.360680686,6659270.34123284,9626326.468178527,6800984.591673557&size=1476,927
app_1 | Traceback (most recent call last):
app_1 | File "/opt/ngw/package/nextgisweb/nextgisweb/pyramid/exception.py", line 76, in unhandled_exception_tween
app_1 | return handler(request)
app_1 | File "/opt/ngw/package/nextgisweb/nextgisweb/pyramid/exception.py", line 66, in handled_exception_tween
app_1 | reraise(*exc_info)
app_1 | File "/opt/ngw/package/nextgisweb/nextgisweb/pyramid/exception.py", line 42, in handled_exception_tween
app_1 | response = handler(request)
app_1 | File "/usr/local/lib/python2.7/dist-packages/pyramid_tm/__init__.py", line 171, in tm_tween
app_1 | reraise(*exc_info)
@BishopGIS
BishopGIS / test.py
Created March 30, 2020 22:03
test numpy exists
import sys
import os
for path_item in sys.path:
try:
items = os.listdir(path_item)
for item in items:
if item == 'numpy':
print('numpy directory present in path: {}'.format(path_item))
# cut some lines from __init__.py
@BishopGIS
BishopGIS / test_osr.py
Created May 5, 2020 18:37
Test coordinate transformation accuracy
from osgeo import gdal, osr
y = 7509137.5811
x = 4187591.89173
gsk2011 = '+proj=longlat +a=6378136.5 +rf=298.2564151 +towgs84=0.013,-0.092,-0.03,0.001738,0.003559,-0.004263,0.0074 +no_defs'
src = osr.SpatialReference()
dst = osr.SpatialReference()
src.ImportFromEPSG(3857)
from osgeo import osr
proj4 = ''
dst = osr.SpatialReference()
dst.ImportFromProj4(proj4)
dst.ExportToWkt()
from osgeo import gdal
from osgeo import ogr
from osgeo import osr
base_url = 'https://sandbox.nextgis.com'
service = 6038
version = '1.0.0'
gdal.SetConfigOption("CPL_DEBUG", "ON")
gdal.SetConfigOption("CPL_CURL_VERBOSE", "YES")
bishop@Bishop-MacBookPro tmp % /usr/bin/env python /Users/Bishop/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/launcher 58870 -- /Volumes/Data/tmp/test_wfs.py
WFS: https://sandbox.nextgis.com/api/resource/6038/wfs?VERSION=1.0.0&SERVICE=WFS&REQUEST=GetCapabilities
HTTP: Fetch(https://sandbox.nextgis.com/api/resource/6038/wfs?VERSION=1.0.0&SERVICE=WFS&REQUEST=GetCapabilities)
HTTP: libcurl/7.71.1 OpenSSL/1.1.1c zlib/1.2.11
* Couldn't find host sandbox.nextgis.com in the .netrc file; using defaults
* Trying 5.9.138.126:443...
* Connected to sandbox.nextgis.com (5.9.138.126) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /Users/Bishop/Applications/NextGIS/Library/Frameworks/openssl.framework/Resources/ssl/certs/cert.pem
@BishopGIS
BishopGIS / test_scale_zoom.py
Created November 9, 2020 13:37
Test scale to zoom conversion
# -*- coding: utf-8 -*-
import math
dpi = 1000 / 39.37 / 0.28
ipm = 39.37
metersPerTile = 156543.04
def getZoomFromScale(scale):
return math.log(scale) / math.log(2)
@BishopGIS
BishopGIS / test_warp.py
Created December 26, 2020 12:52
Test warp
from osgeo import gdal
import os
ds = gdal.Warp('', 'small.tif', format='MEM', warpOptions=["INIT_DEST=NO_DATA", "UNIFIED_SRC_NODATA=YES"], srcNodata=0, dstAlpha=True)
try:
os.remove('nd5.tiff')
except OSError:
pass
from osgeo import ogr, osr
pt = ogr.CreateGeometryFromWkt('POINT(37.0 55.0)')
epsg7683 = osr.SpatialReference()
epsg7683.ImportFromEPSG(7683)
epsg7683.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
# epsg7683.SetTOWGS84(23.57,-140.95,-79.8,0,0.35,0.79,-0.22)
epsg4326 = osr.SpatialReference()
epsg4326.ImportFromEPSG(4326)