not at all the same: they are not equivalent.
because Within implies "geom2 is *fully* within
geom1". So, if some geometry actually crosses the
BBOX will be excluded by this spatial filter.
http://www.postgis.org/docs/ST_Within.html
the equivalent spatial filter is RTreeContains:
this will extract both geometries fully
contained within the BBOX *and* geometries
crossing the BBOX itself
in other words, when accessing the R*Tree
as a Spatial Index (quick BBOX filtering)
you are always expected to use RTreeContains.
bye Sandro
So, if some geometry actually crosses the
BBOX will be excluded by this spatial filter.
http://www.postgis.org/docs/ST_Within.html
the equivalent spatial filter is RTreeContains:
this will extract both geometries fully
contained within the BBOX *and* geometries
crossing the BBOX itself
in other words, when accessing the R*Tree
as a Spatial Index (quick BBOX filtering)
you are always expected to use RTreeContains.
| Hi, This should be a simple question. I'm trying to do a join between two tables that in some case is many to one, and the geometry is in the "one" table. To make this more concrete, From these two tables I want to create a third. The structure of the two original tables are: Table1 ID: Integer Name: Text Type: Text Table2 ID: Integer Geometry: Blob geometry column in my case Table2 is from a line string shapefile (road segments), and Table1 from a dbf. The ID and geometries are unique in Table2, but some of the values of the ID are not unique in Table1, and Table1 has more records than Table2. The code I'm using to create the third table (table3) is: CREATE TABLE table3( ID INTEGER, Name TEXT, Type TEXT ); SELECT AddGeometryColumn( 'table3', 'Geometry', 4269, 'XY'); INSERT INTO table3 SELECT a.ID, a.NAME, a.TYPE, ST_LineFromWKB(b.Geometry, 4269) FROM table1 as a, table2 as b WHERE a.ID = b.ID; I'm getting no errors from the spatialite command line console. When I read the new table into QGIS, the program indicates I'm getting the number of records in the file table I expect, but the layer does not display in QGIS (Table2 does display correctly). Looking at the metadata for the new data in QGIS indicates that the new table has no extent information (which is not true for Table2). My real question is whether I'm treating the geometry column correctly. I've looked at the spatialite manual and the cookbook, and haven't come across an example exactly like this one, so I'm concerned I may be error, which is causing the QGIS issues. Dan |
You cannot use ST_LineFromWKB() this way; this is
wrong and return an invalid Geometry (i.e. NULL).
WKB *is not* the internal geometry format used
by SpatiaLite.
Just to be pedantic, this is valid:
ST_LineFromWKB(ST_AsBinary(b.Geometry, 4269))
- using ST_AsBinary to convert from "internal"
� to WKB
- then using ST_LineFromWKB to get back again
� the same "internal" geometry from WKB
Obviously useless: you already have the "internal"
geometry. there is no need at all to convert back
and forward twice using WKB
And I notice a second potential flaw: in your
"table3" there is no PRIMARY KEY.
Here is your SQL rewritten in a better way:
CREATE TABLE table3(
� pk_id INTEGER PRIMARY KEY AUTOINCREMENT,
� ID INTEGER,
� Name TEXT,
� Type TEXT
);
SELECT AddGeometryColumn( 'table3', 'Geometry', 4269, 'XY');
INSERT INTO table3 (pk_id, ID, Name, Type)
� SELECT NULL, a.ID, a.NAME, a.TYPE, b.Geometry
� FROM table1 as a, table2 as b
� WHERE a.ID = b.ID;
bye Sandro
I'm unable to understand the exact terms of
your problem.
- I understand you surely have some worldwide dataset:
and I easily imagine this is SRID=4326, WGS84, long/lat
- then you are attempting to retrieve any data located
within a single UTM zone: and this probably implies
some appropriate CRS transformation.
I strongly suspect this is someway related to your
problem: but I need some SQL snippet in order to
give you any further evaluation.
bye Sandro
Sorry for starting a new thread, I seemed to have stepped onto another thread with my first message.
Using the INSERT statement you sent:
INSERT INTO table3 (pk_id, ID, Name, Type)
SELECT NULL, a.ID, a.NAME, a.TYPE, b.Geometry
FROM table1 as a, table2 as b
WHERE a.ID = b.ID;
generates the error message "SQL Error: 5 values for 4 columns"
The natural change to make to the query is:
INSERT INTO table3 (pk_id, ID, Name, Type, Geometry)
SELECT NULL, a.ID, a.NAME, a.TYPE, b.Geometry
FROM table1 as a, table2 as b
WHERE a.ID = b.ID;
This results in the error message: "SQL Error: table3.Geometry violates Geometry constraint [geom-type or SRID not allowed]"
Given this failure, I tried:
INSERT INTO table3 (pk_id, ID, Name, Type, Geometry)
SELECT NULL, a.ID, a.NAME, a.TYPE, ST_LineFromWKB(ST_AsBinary(b.Geometry, 4269))
FROM table1 as a, table2 as b
WHERE a.ID = b.ID;
which again results in the Geometry constraint error. If it helps, I can send along the original files and the code I can ran in an off-list email.
Dan
Thanks for your time and very quick response, not to mention all the effort you have put into SpatiaLite. The sanity check was a critical point. I incorrectly assumed that the importer would determine the SRID of a shapefile using the *.prj component of the set, but I now know that the SRID needs to be explicitly specified on import.
Perhaps a "recipe" along the lines of what I was trying to do would be a nice addition to the SpatiaLite cookbook when it gets revised.
Dan
--- On Wed, 8/10/11, a.furieri <a.fu...@lqt.it> wrote:
> --
> You received this message because you are subscribed to the
> Google Groups "SpatiaLite Users" group.
> To post to this group, send email to spatiali...@googlegroups.com.
> To unsubscribe from this group, send email to
> spatialite-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spatialite-users?hl=en.
>
>