Skip to content

Instantly share code, notes, and snippets.

SELECT ST_Transform(ST_Intersection(lg.geometry, bbox.geom), 4326) As geometry,
SELECT "name","type","area","z_order" As properties FROM osm_landusages As lg, (
SELECT ST_Transform(ST_MakeEnvelope(-2.8125,38.82259097617711,25.312499999999986,57.326521225217064, 4326),3857) as geom) as bbox
WHERE ST_Intersects(lg.geometry, bbox.geom)
AND (area > 200000000);
Wu.DomEvent.on(box, 'keydown', this._throttledSave, this);
_throttledSave : function () {
_.throttle(this.save, 1000);
},
save : function () {
var text = div.innerHTML;
this._project.setText(text);
}
var mapnik = require('mapnik');
var proj4 = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over';
var mercator = new mapnik.Projection(proj4);
/**
* SphericalMercator constructor: precaches calculations
* for fast tile lookups
*/
function SphericalMercator() {
# second problem
select row_to_json(t) from (SELECT rid, pvc FROM file_pszjkuicfjvxvizbygbq, ST_ValueCount(rast,1) AS pvc WHERE st_intersects(st_transform(st_setsrid(ST_geomfromgeojson('{"geometry":{"type":"Polygon","coordinates":[[[9.31640625,60.88770004207789],[9.31640625,61.48075950007598],[10.8984375,61.48075950007598],[10.8984375,60.88770004207789],[9.31640625,60.88770004207789]]]}}'), 4326), 3857), rast) as t;
error running query { [Error: ERROR: unknown GeoJSON type
# first problem, solved!
select row_to_json(t) from (
WITH first AS (
SELECT id, (ST_Intersection(rast, rast, 0)).val
FROM file_caolvkddzzlgmvyeofrh
INNER JOIN file_xbwnbydpmwesokzmrcht ON ST_Intersects(rast, rast, 0)
)
SELECT id, COUNT(val), SUM(val), AVG(val), stddev(val), MIN(val), MAX(val)
FROM first
GROUP BY id;
The idea here is that there are two different rasters - one large rasterA, and one small rasterB used as a mask. We need to get the values of rasterA which are within the bounds of rasterB.
Additional problem: rasterB has NODATA value of 0, and ONLY the part of the rasterB that is NOT NODATA should be used as a mask.
The example below is wrong, for several reasons. Can you fix it?
select row_to_json(t) from (
SELECT A.rid, B.rid, pvc
FROM rasterA A
JOIN rasterB B
I simply need to clip a raster by a GeoJSON polygon. However, the query needs to fit into a Mapnik wrapper (of which I have no control).
# Full Mapnik query from PostGIS logs
SELECT ST_AsBinary(ST_Band(ST_Resample(ST_Clip("rast", ST_Expand(ST_SetSRID('BOX3D(743579.4111581944 8570731.10756024,900122.4450862355 8727274.141488284)'::box3d, 3857), greatest(abs(ST_ScaleX("rast")), abs(ST_ScaleY("rast"))))),305.748 * sign(ST_ScaleX("rast")),305.748 * sign(ST_ScaleY("rast")), 0, 0), 1)) AS geom FROM (SELECT ST_Clip(rast, st_transform(st_setsrid(ST_geomfromgeojson('{"type":"Polygon","coordinates":[[[9.019775390625,61.370409712010435],[7.998046875,61.17503266354878],[8.7890625,61.16443708638272],[9.29443359375,60.62471311568258],[10.469970703124998,61.63250678169624],[9.5361328125,61.201506036385375],[9.019775390625,61.370409712010435]]]}'), 4326), 3857)) FROM file_tpspmpkrwlsrcchskibg) as subquery WHERE "rast" && ST_SetSRID('BOX3D(743579.4111581944 8570731.10756024,900122.4450862355 8727274.141488284)'::box3d, 3857)
@knutole
knutole / Issues.md
Created October 6, 2016 12:45 — forked from rclark/Issues.md
Leaflet WMS + GetFeatureInfo

There are a bunch of reasons why this is convoluted, mostly in building the URL to make the request:

  1. You have to rely on an AJAX request, this example uses jQuery
  2. To make a GetFeatureInfo request, you must provide a BBOX for a image, and the pixel coordinates for the part of the image that you want info from. A couple of squirrely lines of Leaflet code can give you that.
  3. Output formats. The info_format parameter in the request. We don't know a priori which will be supported by a WMS that we might make a request to. See Geoserver's docs for what formats are available from Geoserver. That won't be the same from WMS to WMS, however.
  4. WMS services return XML docs when there's a mistake in the request or in processing. This sends an HTTP 200, which jQuery doesn't think is an error.
Art Bot Terms of Service and Privacy Policy
1. Terms
By accessing the website at https://www.facebook.com/ArtBot-2083196591906830/, you are agreeing to be bound by these terms of service, all applicable laws and regulations, and agree that you are responsible for compliance with any applicable local laws. If you do not agree with any of these terms, you are prohibited from using or accessing this site. The materials contained in this website are protected by applicable copyright and trademark law.
2. Use License
#!/bin/bash
# Install docker community edition on Ubuntu
# Updated May 5th 2017
# Maintained by <knutole at mapic dot io>
#
# For more info, see: https://docs.docker.com/engine/installation/linux/ubuntu/
DOCKER_COMPOSE_VERSION=1.13.0
DOCKER_MACHINE_VERSION=0.10.0