The ST_Buffer solution already explained here is valid, but it can be improved in order to avoid the spikes (and the intersection step itself). You need to add a new parameter to the buffer mitre_limit.
st_buffer(geom, 1, 'join=mitre mitre_limit=1.0'
), -1, 'join=mitre mitre_limit=1.0'
You're messing up the order in the ST_Contains fuction.
ST_Contains(geometry geomA, geometry geomB):
Geometry A contains Geometry B if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.
So your polygon and samplecol.the_geom need to switch places in the ST_Contains function.
You must use ST_3DIntersects. Which provides you the correct result on your sample query in your question:
ST_GeomFromText('LINESTRING( 1 1 1, 5 5 1)'),
ST_GeomFromText('LINESTRING( 4 1 10, 1 5 10)'
Have a look at the link below:
It is available from PostGIS 2.0.0 onwards.
The error message mentions " 0101000000A7E8482EFFC", with a trailing space, which makes the geometry invalid.
The dirty solution is to trim your data
SELECT ST_AsText(TRIM(GPS)) from schema.table;
with src as (select ' 0101000000A7E8482EFFC55B402063EE5A42064140'::text txt)
select st_asText(txt::geometry) from src;
ERROR: parse error - invalid geometry
the point is not a PostGIS type, but a native PostgresSQL type. The two are not compatible.
Creating a geometry from a string is one way. You can of course create a (PostGIS) point geometry via ST_Point or ST_MakePoint
CREATE TABLE riverscale.test as
b.id AS id2,
ST_MakeLine(a.geom, b.geom) as geom
FROM riverscale.points a, riverscale.points b
ALTER TABLE riverscale.test
ALTER COLUMN geom TYPE geometry(LineString, 3763) USING ST_SetSRID(geom, 3763);
Building on what @JohnPowell said in the comments, you can make a join that is based on a spatial intersection. If you have a spatial index setup, this should have much better performance than a cross join. If you do not have a spatial indexes, you can create them directly in PostgreSQL using SQL or use the QGIS DB Manager to create them with a GUI.
It is a geometry already.
What you have is not a table but the result of a query. You have at least 2 options:
1) create a new table with the output and load it in QGIS
CREATE TABLE test as
b.id AS id2,
ST_MakeLine(a.geom, b.geom) as geom
FROM riverscale.points a, riverscale.points b
2) load the tables in QGIS and query ...
In PostGIS, this can be done quite easily with a Cartesian product or CROSS JOIN in SQL, ie, joining a table on itself and using the 2nd form of ST_MakeLine. So, assuming a table called points with an id and a geometry called geom, this would look like:
FROM points a, points b
WHERE a.id < ...
Tested on QGIS 2.18 and QGIS 3.4
I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume we have 10 features in "points" layer respectively, see image below.
With the following Queries, it is possible to achieve the lines between all possible connection of points excluding themselves.
SELECT p1.id ||...
If i'm correct you are trying to get the distance from each node in the network to each other node, correct?
Your subquery (SELECT array_agg(id) FROM ma_2po_4pgr ) returns each unique edge in the network, while'you want this query to return each unique node. To get all the unique nodes you have to select them form the source and target ...
As far as I know, PostGIS stores raster in bigger objects, not tile-wise. So your one line contains multiple raster cells, which you can see in any GIS program. Have you tried to use -t <a>x<b>, where a and b are the size of your raster cells? At least I've done that once and the corresponding value should be accessible with ST_Value. Check out ...
The easiest way I found is to cast the geometry type like this:
CREATE OR REPLACE VIEW view_waypAZ AS
SELECT polR.codeR, polR.nameR, ST_centroid(polR.geom)::geometry(Point,4326) as geom
FROM boundaryR as polR;
Check out PostGIS section 4.3.4. Manually Registering Geometry Columns in geometry_columns
You can also use ST_ClusterDBSCAN to cluster adjacent polygons together and then assign class by most frequent class in that cluster group:
--Add a temp column holding cluster id
alter table sometable add column cid int;
set cid = sub.clusterid
from (SELECT *, ST_ClusterDBSCAN(geom, eps := 0, minpoints := 1) OVER () clusterid
I have the same problem as I cannot load the query into the map canvas.
In the python error console I get this
I have no
to exchange and I don't use the "postgres" login for the DB.
I use QGIS 3.4 Madeira on a Mac.
I can only answer your first question, "Is it anyhow possible to collect data offline with a postgis database in QField? (Also with manaually synchronization)"
I created a sync package in QGIS and copied it on different tablets.
the input data to edit is a postgis table, in mode "offline editing".
Each tablet updates some of the objects in the offline ...
Hope this answers your question,
set roadclass =sub.nearest_value
p.idd as updating_id,b.id2 as nearest_id, b.roadclass as
--selecting id and geom of null values
SELECT gid AS idd, geom
FROM your_table where roadclass is null
--finding nearest polygon and its of the ...
As per my comment above:
Better use ST_DWithin for proximity searches:
UPDATE intersections AS g
SET facility_flag = EXISTS (
FROM network_subset AS d
WHERE ST_DWithin(g.geom, d.geom, 100)
This assumes your data is projected in a CRS with feet as unit.
Here, the Boolean result of EXISTS is (explicitly) cast to INT. ...
CREATE TABLE schema.polytable AS
SELECT column1, column2, ST_AsText(ST_CONVEXHULL(ST_COLLECT(geomcolumn))) AS newgeomcolumn
GROUP BY column1, column2
As suggested by someone else, this works in this scenario.
1) Create two worksheets for stations by running the query:
SELECT * INTO stations_0 FROM stations;
SELECT * INTO stations_1 FROM stations;
2) Delete the stations that are included in the polygons:
DELETE FROM stations_0 as t1
WHERE EXISTS (SELECT 1 FROM provinces as t2
WHERE ST_Intersects(t2.geom, t1.geom));
and do not enter polygons:
here is your solution:
CREATE SCHEMA gc;
CREATE EXTENSION postgis SCHEMA gc;
If you already installed the postGIS extension in your public schema and want to move in gc then write following code:
SET extrelocatable = TRUE
WHERE extname = 'postgis';
ALTER EXTENSION postgis
SET SCHEMA gc;
Try enforcing closed LineStrings by adding their ST_StartPoint to the end of the them:
SELECT ST_MakePolygon( ST_MakeValid( ST_AddPoint( shape. ST_StartPoint( shape ) ) ) ) AS shape
WHERE waterway ='riverbank'
If you want to make sure you are not duplicating points for when a LineString is already closed, run:
So, I decided to forgo the use of raster2pgsql and trying to "fix" the datatable for my purposes. I instead wrote a python script to read a tif file and upload its information to PostGIS, using rasterio and psycopg2.
If anyone has a comment as to why this isn't a default behavior obtainable with raster2pgsql, I'm still curious. GeoTIFF, from my ...
You need to move the subquery outside of the function call:
SELECT ST_x(geom) As X, ST_y(geom) As Y, ST_z(geom) As Z
JOIN building ON surface_geometry.id = building.id
WHERE geometry IS NOT NULL
AND cityobject_id = 95
You simply need to tell ogr2ogr what projection your data is in, as suggested by mrg. In my case it was -s_srs EPSG:3785.
You shouldn't have to redefine a standard projection in your database! This is not a clean solution and can have unexpected consequences later on.
The easiest way that I found is using OSMnx library in Python to upload the OSM map as a network in NetworkX (You can also use geopandas), once there is easy to link each of the points in the 'Points' Layer to the closer edge of the OSM layer and then use the steiner_tree algorithm to get the optimal tree, this is an example of a simple implementation of ...
When you (or whoever else) initialized the 3DCityDB instance, you didn't specify a spatial reference for it, which means that the data was saved with no SRID (i.e. set to 0). You will have to re-initialize the database with the proper SRID. Either delete the existing database or create a new one, then run the 3DCityDB setup scripts, but pay close attention ...
As I can't comment so that I will write it here.
You may have to provide the valid Spatial Reference Identifier SRID and an SRSName which is an OGC GML conformant CRS (coordinate reference system) definition identifier while importing the data to PostgreSQL Database.
Mark also the Extruded checkbox.
Perhaps this helps.
so after some manual checking here is a workin answer for people using OSM with the latest versions of the tools (OSM2pgsql and routing 2.62)
bascially way.target = route.node
SELECT * from ways join (
SELECT * from pgr_drivingDistance(
'SELECT gid as id
, length_m as cost FROM "ways" '
my answer is based on: http://www.postgresqltutorial.com/creating-first-trigger-postgresql/ and https://stackoverflow.com/questions/39607334/postgres-trigger-creation-error-no-language-specified-sql-state-42p13
EDIT1: adjusting for ThingumaBob's comment
first you need to create a function to be used by your trigger action :
CREATE OR REPLACE FUNCTION ...
You can use ST_PixelAsPoints to get a geometry for each point and then to a "Cartesian join", ie, a full join between the points and the pixels, eg,
WITH pixels (x, y, geom) AS (
SELECT x, y, geom
(SELECT (ST_PixelAsPoints(rast, 1)).*
WHERE rid = 1
gid, x, y, ST_Distance(points....
The correct syntax is SELECT DISTINCT ON (geom, eventdate) geom, eventdate FROM datos WHERE orden='x'. By omitting on, Postgres thinks you are looking for a composite type, rather than essentially just a GROUP BY geom, evendate. – John Powell Jul 3 at 15:28
Using shp2geojson.js library it is possible to load ESRI shapefile and convert it to standard GeoJSON object that can then be used to create overlay in OpenLayers 3.
Below is simple example of such usage. Shapefile Mexico_and_US_Border.zip is loaded directly from https://opendata.arcgis.com/ site and then added as overlay over OSM map. The only critical ...
You can use ST_FromGeoJson to convert the text to a geometry, then you would cast the result to the desired geography format. At last, you can use ST_Centroid
I think there is no issue with your secord query. It returns true or false for features which are in second table. But as your second table is empty the result from your inner select query is empty. So when you user where condition WHERE table_1.id = liste.name; no feature is updated. Instead you should have condition like WHERE table_1.id = liste.name or ...
To achieve something like:
Which is a ...
UPDATE1: although why you want to do this escapes me (joining with empty table) this query probably does what you want.
WITH empty as (SELECT T1.id AS name,
bool_or((ST_Contains(T2.geom, T1.geom) OR ST_Overlaps(T1.geom,T2.geom))) AS my_bool
FROM table_1 AS T1
CROSS JOIN table_2 AS T2
I suppose your observations are point geometry. If that's the case you can use ST_ClosestPoint to find the closest point on line and plot them on line itself.
ST_GeomFromText('MULTILINESTRING ((10 10, 40 50), (20 20, 50 20, 50 60, 20 20))'),
Just like with the COUNT(*), the SELECT can utilize (almost) every other aggregate function, keeping the reference to the grouped rows defined by the GROUP BY.
Not directly obvious: in your first query you implicitly GROUP BY ST_SnapToGrid(...) already, by using the column expression alias grid.
With that in mind, just run this very similar query:
would something like this do the job?
UPDATE1: used st_crosses instead of st_intersects and not st_equals and created an index for the geometry
UPDATE2: instead of calculating a huge multipoint, lets calculate one multipoint per join_id and let's split only the line with this join_id. Also, if a particular join_id has only one segment bring it anyways
PostgreSQL/PostGIS implement the SQL/MM specification, so just write it in proper SQL:
FROM my_border_table t1
JOIN my_polygon_table t2 ON ST_Intersects(t1.geoloc, t2.geom)
WHERE ST_Dimension(t1.geoloc) = 2
AND ST_Dimension(t2.geom ) = 2;
-- ST_GeometryType(t1.geoloc) IN ('ST_Polygon', 'ST_MultiPolygon')
-- AND ST_GeometryType(t2....