Error with generate_series Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How to insert 3d line into postgis database?How to create random points in a polygon in PostGIScan't geocode with PostGIS 2.1.1Function get_partition(geometry, unknown) does not exist - Nominatim tiger data importPython GDAL open dataset in PostGIS with quotationsHow to deal with “ERROR: GEOSUnaryUnion: TopologyException: Self-intersection”?PostgreSQL Queries pgAdmin versus Function callProblem with insert into PostGIS view table via QGISCross-schema function call with PostGIS dependenciesVery slow loading of PostGIS raster layer in qGIS
Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?
Should I use a zero-interest credit card for a large one-time purchase?
Can a new player join a group only when a new campaign starts?
What was the first language to use conditional keywords?
Effects on objects due to a brief relocation of massive amounts of mass
Why do we bend a book to keep it straight?
How to react to hostile behavior from a senior developer?
What initially awakened the Balrog?
How were pictures turned from film to a big picture in a picture frame before digital scanning?
What would you call this weird metallic apparatus that allows you to lift people?
Would the Life Transference spell be unbalanced if it ignored resistance and immunity?
Performance gap between vector<bool> and array
Denied boarding although I have proper visa and documentation. To whom should I make a complaint?
Disembodied hand growing fangs
Drawing without replacement: why is the order of draw irrelevant?
Find 108 by using 3,4,6
As a beginner, should I get a Squier Strat with a SSS config or a HSS?
How to compare two different files line by line in unix?
What is "gratricide"?
Time to Settle Down!
The code below, is it ill-formed NDR or is it well formed?
Why is Nikon 1.4g better when Nikon 1.8g is sharper?
Illegal assignment from sObject to Id
Project Euler #1 in C++
Error with generate_series
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to insert 3d line into postgis database?How to create random points in a polygon in PostGIScan't geocode with PostGIS 2.1.1Function get_partition(geometry, unknown) does not exist - Nominatim tiger data importPython GDAL open dataset in PostGIS with quotationsHow to deal with “ERROR: GEOSUnaryUnion: TopologyException: Self-intersection”?PostgreSQL Queries pgAdmin versus Function callProblem with insert into PostGIS view table via QGISCross-schema function call with PostGIS dependenciesVery slow loading of PostGIS raster layer in qGIS
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I`d like to create a Hex Grid using Hex grid algorithm for PostGIS (https://medium.com/@goldrydigital/hex-grid-algorithm-for-postgis-4ac45f61d093)
DO $$
DECLARE
_curs CURSOR FOR SELECT geom3857 FROM nrw;
_table TEXT := 'nrw_hx_10k';
_srid INTEGER := 3857;
_height NUMERIC := 10000;
_width NUMERIC := _height * 0.866;
_geom GEOMETRY;
_hx GEOMETRY := ST_GeomFromText(
FORMAT('POLYGON((0 0, %s %s, %s %s, %s %s, %s %s, %s %s, 0 0))',
(_width * 0.5), (_height * 0.25),
(_width * 0.5), (_height * 0.75),
0 , _height,
(_width * -0.5), (_height * 0.75),
(_width * -0.5), (_height * 0.25)
), _srid);
BEGIN
CREATE TEMP TABLE hx_tmp (geom GEOMETRY(POLYGON));
OPEN _curs;
LOOP
FETCH
_curs INTO _geom;
EXIT WHEN NOT FOUND;
INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
INSERT INTO hx_tmp
SELECT ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5),
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - (_height * 1.75),
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
END LOOP;
CLOSE _curs;
CREATE INDEX sidx_hx_tmp_geom ON hx_tmp USING GIST (geom);
EXECUTE 'DROP TABLE IF EXISTS '|| _table;
EXECUTE 'CREATE TABLE '|| _table ||' (geom GEOMETRY(POLYGON, '|| _srid ||'))';
EXECUTE 'INSERT INTO '|| _table ||' SELECT * FROM hx_tmp GROUP BY geom';
EXECUTE 'CREATE INDEX sidx_'|| _table ||'_geom ON '|| _table ||' USING GIST (geom)';
DROP TABLE IF EXISTS hx_tmp;
END $$;
When I try to use the function, I get the following error:
ERROR: function generate_series(numeric, numeric, numeric) does not exist
LINE 5: generate_series(
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom)
CONTEXT: PL/pgSQL function inline_code_block line 27 at SQL statement
********** Error **********
ERROR: function generate_series(numeric, numeric, numeric) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Context: PL/pgSQL function inline_code_block line 27 at SQL statement
postgis postgresql function
add a comment |
I`d like to create a Hex Grid using Hex grid algorithm for PostGIS (https://medium.com/@goldrydigital/hex-grid-algorithm-for-postgis-4ac45f61d093)
DO $$
DECLARE
_curs CURSOR FOR SELECT geom3857 FROM nrw;
_table TEXT := 'nrw_hx_10k';
_srid INTEGER := 3857;
_height NUMERIC := 10000;
_width NUMERIC := _height * 0.866;
_geom GEOMETRY;
_hx GEOMETRY := ST_GeomFromText(
FORMAT('POLYGON((0 0, %s %s, %s %s, %s %s, %s %s, %s %s, 0 0))',
(_width * 0.5), (_height * 0.25),
(_width * 0.5), (_height * 0.75),
0 , _height,
(_width * -0.5), (_height * 0.75),
(_width * -0.5), (_height * 0.25)
), _srid);
BEGIN
CREATE TEMP TABLE hx_tmp (geom GEOMETRY(POLYGON));
OPEN _curs;
LOOP
FETCH
_curs INTO _geom;
EXIT WHEN NOT FOUND;
INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
INSERT INTO hx_tmp
SELECT ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5),
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - (_height * 1.75),
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
END LOOP;
CLOSE _curs;
CREATE INDEX sidx_hx_tmp_geom ON hx_tmp USING GIST (geom);
EXECUTE 'DROP TABLE IF EXISTS '|| _table;
EXECUTE 'CREATE TABLE '|| _table ||' (geom GEOMETRY(POLYGON, '|| _srid ||'))';
EXECUTE 'INSERT INTO '|| _table ||' SELECT * FROM hx_tmp GROUP BY geom';
EXECUTE 'CREATE INDEX sidx_'|| _table ||'_geom ON '|| _table ||' USING GIST (geom)';
DROP TABLE IF EXISTS hx_tmp;
END $$;
When I try to use the function, I get the following error:
ERROR: function generate_series(numeric, numeric, numeric) does not exist
LINE 5: generate_series(
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom)
CONTEXT: PL/pgSQL function inline_code_block line 27 at SQL statement
********** Error **********
ERROR: function generate_series(numeric, numeric, numeric) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Context: PL/pgSQL function inline_code_block line 27 at SQL statement
postgis postgresql function
and have you tried explicit type casts? PG function calls usually don't like type ambiguity much at runtime.
– ThingumaBob
Apr 11 at 7:59
What version of Postgres are you using, the generate_series(numeric,numeric,numeric) function was only added in Postgres 9.5. So, if you have lower, do as @ThingumaBob suggests, and cast to int or bigint.
– John Powell
Apr 11 at 8:34
So, because _width is of type numeric, a line like(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5)
will end up being of type numeric. So, you need to cast the whole expression, eg,(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5))::bigint
– John Powell
Apr 11 at 8:38
add a comment |
I`d like to create a Hex Grid using Hex grid algorithm for PostGIS (https://medium.com/@goldrydigital/hex-grid-algorithm-for-postgis-4ac45f61d093)
DO $$
DECLARE
_curs CURSOR FOR SELECT geom3857 FROM nrw;
_table TEXT := 'nrw_hx_10k';
_srid INTEGER := 3857;
_height NUMERIC := 10000;
_width NUMERIC := _height * 0.866;
_geom GEOMETRY;
_hx GEOMETRY := ST_GeomFromText(
FORMAT('POLYGON((0 0, %s %s, %s %s, %s %s, %s %s, %s %s, 0 0))',
(_width * 0.5), (_height * 0.25),
(_width * 0.5), (_height * 0.75),
0 , _height,
(_width * -0.5), (_height * 0.75),
(_width * -0.5), (_height * 0.25)
), _srid);
BEGIN
CREATE TEMP TABLE hx_tmp (geom GEOMETRY(POLYGON));
OPEN _curs;
LOOP
FETCH
_curs INTO _geom;
EXIT WHEN NOT FOUND;
INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
INSERT INTO hx_tmp
SELECT ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5),
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - (_height * 1.75),
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
END LOOP;
CLOSE _curs;
CREATE INDEX sidx_hx_tmp_geom ON hx_tmp USING GIST (geom);
EXECUTE 'DROP TABLE IF EXISTS '|| _table;
EXECUTE 'CREATE TABLE '|| _table ||' (geom GEOMETRY(POLYGON, '|| _srid ||'))';
EXECUTE 'INSERT INTO '|| _table ||' SELECT * FROM hx_tmp GROUP BY geom';
EXECUTE 'CREATE INDEX sidx_'|| _table ||'_geom ON '|| _table ||' USING GIST (geom)';
DROP TABLE IF EXISTS hx_tmp;
END $$;
When I try to use the function, I get the following error:
ERROR: function generate_series(numeric, numeric, numeric) does not exist
LINE 5: generate_series(
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom)
CONTEXT: PL/pgSQL function inline_code_block line 27 at SQL statement
********** Error **********
ERROR: function generate_series(numeric, numeric, numeric) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Context: PL/pgSQL function inline_code_block line 27 at SQL statement
postgis postgresql function
I`d like to create a Hex Grid using Hex grid algorithm for PostGIS (https://medium.com/@goldrydigital/hex-grid-algorithm-for-postgis-4ac45f61d093)
DO $$
DECLARE
_curs CURSOR FOR SELECT geom3857 FROM nrw;
_table TEXT := 'nrw_hx_10k';
_srid INTEGER := 3857;
_height NUMERIC := 10000;
_width NUMERIC := _height * 0.866;
_geom GEOMETRY;
_hx GEOMETRY := ST_GeomFromText(
FORMAT('POLYGON((0 0, %s %s, %s %s, %s %s, %s %s, %s %s, 0 0))',
(_width * 0.5), (_height * 0.25),
(_width * 0.5), (_height * 0.75),
0 , _height,
(_width * -0.5), (_height * 0.75),
(_width * -0.5), (_height * 0.25)
), _srid);
BEGIN
CREATE TEMP TABLE hx_tmp (geom GEOMETRY(POLYGON));
OPEN _curs;
LOOP
FETCH
_curs INTO _geom;
EXIT WHEN NOT FOUND;
INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
INSERT INTO hx_tmp
SELECT ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5),
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - (_height * 1.75),
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom);
END LOOP;
CLOSE _curs;
CREATE INDEX sidx_hx_tmp_geom ON hx_tmp USING GIST (geom);
EXECUTE 'DROP TABLE IF EXISTS '|| _table;
EXECUTE 'CREATE TABLE '|| _table ||' (geom GEOMETRY(POLYGON, '|| _srid ||'))';
EXECUTE 'INSERT INTO '|| _table ||' SELECT * FROM hx_tmp GROUP BY geom';
EXECUTE 'CREATE INDEX sidx_'|| _table ||'_geom ON '|| _table ||' USING GIST (geom)';
DROP TABLE IF EXISTS hx_tmp;
END $$;
When I try to use the function, I get the following error:
ERROR: function generate_series(numeric, numeric, numeric) does not exist
LINE 5: generate_series(
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: INSERT INTO hx_tmp
SELECT
ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON) geom
FROM
generate_series(
(st_xmin(_geom) / _width)::INTEGER * _width - _width,
(st_xmax(_geom) / _width)::INTEGER * _width + _width,
_width) x_series,
generate_series(
(st_ymin(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) - _height,
(st_ymax(_geom) / (_height * 1.5))::INTEGER * (_height * 1.5) + _height,
_height * 1.5) y_series
WHERE
ST_Intersects(ST_Translate(_hx, x_series, y_series)::GEOMETRY(POLYGON), _geom)
CONTEXT: PL/pgSQL function inline_code_block line 27 at SQL statement
********** Error **********
ERROR: function generate_series(numeric, numeric, numeric) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Context: PL/pgSQL function inline_code_block line 27 at SQL statement
postgis postgresql function
postgis postgresql function
asked Apr 10 at 23:32
dlama49 dlama49
61
61
and have you tried explicit type casts? PG function calls usually don't like type ambiguity much at runtime.
– ThingumaBob
Apr 11 at 7:59
What version of Postgres are you using, the generate_series(numeric,numeric,numeric) function was only added in Postgres 9.5. So, if you have lower, do as @ThingumaBob suggests, and cast to int or bigint.
– John Powell
Apr 11 at 8:34
So, because _width is of type numeric, a line like(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5)
will end up being of type numeric. So, you need to cast the whole expression, eg,(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5))::bigint
– John Powell
Apr 11 at 8:38
add a comment |
and have you tried explicit type casts? PG function calls usually don't like type ambiguity much at runtime.
– ThingumaBob
Apr 11 at 7:59
What version of Postgres are you using, the generate_series(numeric,numeric,numeric) function was only added in Postgres 9.5. So, if you have lower, do as @ThingumaBob suggests, and cast to int or bigint.
– John Powell
Apr 11 at 8:34
So, because _width is of type numeric, a line like(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5)
will end up being of type numeric. So, you need to cast the whole expression, eg,(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5))::bigint
– John Powell
Apr 11 at 8:38
and have you tried explicit type casts? PG function calls usually don't like type ambiguity much at runtime.
– ThingumaBob
Apr 11 at 7:59
and have you tried explicit type casts? PG function calls usually don't like type ambiguity much at runtime.
– ThingumaBob
Apr 11 at 7:59
What version of Postgres are you using, the generate_series(numeric,numeric,numeric) function was only added in Postgres 9.5. So, if you have lower, do as @ThingumaBob suggests, and cast to int or bigint.
– John Powell
Apr 11 at 8:34
What version of Postgres are you using, the generate_series(numeric,numeric,numeric) function was only added in Postgres 9.5. So, if you have lower, do as @ThingumaBob suggests, and cast to int or bigint.
– John Powell
Apr 11 at 8:34
So, because _width is of type numeric, a line like
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5)
will end up being of type numeric. So, you need to cast the whole expression, eg, (st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5))::bigint
– John Powell
Apr 11 at 8:38
So, because _width is of type numeric, a line like
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5)
will end up being of type numeric. So, you need to cast the whole expression, eg, (st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5))::bigint
– John Powell
Apr 11 at 8:38
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318433%2ferror-with-generate-series%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318433%2ferror-with-generate-series%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
and have you tried explicit type casts? PG function calls usually don't like type ambiguity much at runtime.
– ThingumaBob
Apr 11 at 7:59
What version of Postgres are you using, the generate_series(numeric,numeric,numeric) function was only added in Postgres 9.5. So, if you have lower, do as @ThingumaBob suggests, and cast to int or bigint.
– John Powell
Apr 11 at 8:34
So, because _width is of type numeric, a line like
(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5)
will end up being of type numeric. So, you need to cast the whole expression, eg,(st_xmin(_geom) / _width)::INTEGER * _width - (_width * 1.5))::bigint
– John Powell
Apr 11 at 8:38