Re: [postgis-users] How best to create and use associative array type in Postgres?

2022-01-07 Thread Regina Obe
Oh forgot one more very useful operator, the subtraction operator. Removes a key/value from the list: SELECT '{"color": "blue", "height_m": 10}'::jsonb - 'color' Returns: {"height_m": 10} From: Regina Obe [mailto:l...@pcorp.us] Sent: Friday, January 7, 2022 11:18 PM To: 'PostGIS

Re: [postgis-users] How best to create and use associative array type in Postgres?

2022-01-07 Thread Regina Obe
David, Not sure what you are asking? There are many functions for jsonb and even more the newer your PostgreSQL is. Take a look at - https://www.postgresql.org/docs/current/functions-json.html You can pull arrays by index but not really key/values by index (because jsonb reorders

Re: [postgis-users] How best to create and use associative array type in Postgres?

2022-01-07 Thread Shaozhong SHI
Hi, Regina, That is interesting! How to add new entries to the dictionary. E.g., weight: 40? Can the dictionary to serve as a collection of paired key, value set, so that we can accumulate data to be processed? Then, we can deal with the first, then 2nd and so on in turn? Or, we can do

Re: [postgis-users] AWS RDS postgis compatibility

2022-01-07 Thread Regina Obe
As Raj mentioned, it’s backward compatible. The main thing that changed between 2.5.2 and 3 is that the postgis_raster extension is split so make sure you follow the additional steps for that as it unbundles the raster functions from PostGIS and rebundles them. I forget how we got around

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 21:55 schrieb Luca Bertoncello: > Does someone have an idea? OK, I got it with a function: CREATE OR REPLACE FUNCTION getElevationsOnLine(startPoint geometry, endPoint geometry, pointsInterval int) RETURNS TABLE ( lat DOUBLE PRECISION, lng DOUBLE PRECISION, elevation

Re: [postgis-users] How best to create and use associative array type in Postgres?

2022-01-07 Thread Regina Obe
Use JSONB datatype. CREATE TABLE test(id integer, data jsonb); TRUNCATE tABLE test; INSERT INTO test(id, data) VALUES (1, '{"color": "red", "height_m": 10}'); -- PG14 or higher – you can used subscript feature UPDATE test SET data['color'] = to_jsonb('blue'::text),

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 21:31 schrieb Luca Bertoncello: > Am 07.01.2022 um 21:28 schrieb Paul Ramsey: >> Yes, the "distances" you got when you ran the calculation in geometry space >> were wrong. They were both wrong in unit terms (meaningless units vs meters) >> and also in picking the right elevation

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 21:28 schrieb Paul Ramsey: > Yes, the "distances" you got when you ran the calculation in geometry space > were wrong. They were both wrong in unit terms (meaningless units vs meters) > and also in picking the right elevation point (since there's a N/S > compression effect in

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Paul Ramsey
Yes, the "distances" you got when you ran the calculation in geometry space were wrong. They were both wrong in unit terms (meaningless units vs meters) and also in picking the right elevation point (since there's a N/S compression effect in raw lon/lat coordinates working in cartesian space).

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 21:20 schrieb Paul Ramsey: > Yep, I cut'n'pasted the wrong example. > > > EXPLAIN ANALYZE > SELECT *, > latlng <-> '010120E610E17A14AE47412C40BC74931804A64940' AS dist > FROM elevation2x2 > ORDER BY dist LIMIT 5; OK, this works very fast, but I think it is not

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Paul Ramsey
Yep, I cut'n'pasted the wrong example. EXPLAIN ANALYZE SELECT *, latlng <-> '010120E610E17A14AE47412C40BC74931804A64940' AS dist FROM elevation2x2 ORDER BY dist LIMIT 5; > On Jan 7, 2022, at 12:19 PM, Luca Bertoncello wrote: > > Am 07.01.2022 um 20:53 schrieb Paul Ramsey: >> You

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 20:53 schrieb Paul Ramsey: > You have an index on the geography, but you cast to geometry in your distance > calc, so the index helps you not at all. > > Do this > > SELECT *, ST_Distance(latlng, > '010120E610E17A14AE47412C40BC74931804A64940') AS dist FROM > elevation

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Paul Ramsey
> > Well, this was a very hard job... > I got the EU-DEM data from > https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1?tab=download > Then I converted the 38GB TIFFs in an SQL database. First of all, I > reduced the precision, since 25 meter is for flying too much precision. > One or

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Paul Ramsey
You have an index on the geography, but you cast to geometry in your distance calc, so the index helps you not at all. Do this SELECT *, ST_Distance(latlng, '010120E610E17A14AE47412C40BC74931804A64940') AS dist FROM elevation ORDER BY dist LIMIT 5; > On Jan 7, 2022, at 11:18 AM, Luca

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 20:35 schrieb Paul Ramsey: Hi Paul > Use the nearest neighbor operator > > https://www.postgis.net/workshops/postgis-intro/knn.html Even too long... About 16 seconds... I think I should create an index? gis=# explain analyze SELECT *, latlng::geometry <->

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Paul Ramsey
Use the nearest neighbor operator https://www.postgis.net/workshops/postgis-intro/knn.html Do you have a link to your source data? The table of elevations? > On Jan 7, 2022, at 11:18 AM, Luca Bertoncello wrote: > > Am 07.01.2022 um 20:01 schrieb Luca Bertoncello: > > Hi again > >> I get 33

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 20:01 schrieb Luca Bertoncello: Hi again > I get 33 points as result, and since the distance between the both > aerodromes is about 31 km, it could be correct... > > Now I'm not very sure how to get the nearest point in the table for all > these points... > Maybe it's just

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Luca Bertoncello
Am 07.01.2022 um 19:28 schrieb Martin Davis: Hi Martin, > How about this for an approach? > > - Create a line from the start and end point using ST_MakeLine > - Densify it using ST_Segmentize (e.g. to a1 km interval) > - Extract the individual points using ST_DumpPoints > - For each point,

Re: [postgis-users] Getting data from table with interval

2022-01-07 Thread Martin Davis
How about this for an approach? - Create a line from the start and end point using ST_MakeLine - Densify it using ST_Segmentize (e.g. to a1 km interval) - Extract the individual points using ST_DumpPoints - For each point, query to find the nearest elevation point On Thu, Jan 6, 2022 at 12:51

Re: [postgis-users] Enhancing visualisation in PgAdmin

2022-01-07 Thread Marco Boeringa
pgAdmin is not supposed to a be a full fledged GIS, it is an administrative tool to manage your (spatial) databases, that just happens to have some very rudimentary spatial visualization capability. If you need GIS type symbolization and labelling functionality, install QGIS, it has everything