Spatially join two shapefiles

10 views
Skip to first unread message

Keith

unread,
Mar 24, 2008, 7:27:35 PM3/24/08
to JEQL Users
Martin,

Now that I'm careful with the upper/lower case of my statements I'm
having more success. Also, I really like the convenience of temporary
tables and geometry columns that are automatically disposed. I only
need to write the data to disk when I want to.

1.) Is something like this spatial join possible? Can I refer to
Table.Column and access multiple tables in the same SQL statement?

points = null;
subdivision = null;

ShapefileReader points
file: "E:\homes_for_sale.shp";

ShapefileReader subdivision
file: "E:\subdivisions_polygons.shp";

spatial_join = select subdivision.name, points.id where
Geom.intersects(points.GEOM,subdivision.GEOM);

2.) If there is no cursor or looping mechanism, how can I loop thru
all polygon geometries in one Shapefile and test each geometry against
each geometry in a different shapefile?

Thanks for your help. I appreciate all your work.

Martin Davis

unread,
Mar 24, 2008, 8:11:04 PM3/24/08
to jeql-...@googlegroups.com
Hi, Keith.

Easy handling of tables and geometry are what JEQL is all about!


For (1), you would write:

spatial_join = select subdivision.name, points.id
from subdivision join points on Geom.intersects(points.GEOM,subdivision.GEOM);

IN JEQL SQL, joins are always expressed using the JOIN notation.  Also, currently only one JOIN per select is supported (but you can mimic more by creating several tables in succession)

2) Looping is (for now) always expressed using select expressions.   So the case you mention is handled in exactly the same way as (1) above - using a JOIN to combine the input tables, and then pulling out the combinations that you want by using an ON condition.  (This is identical to how SQL works, if you're familiar with that paradigm).

There may be situations where explicit looping is desireable - but I'm trying hard to make JEQL powerful enough that it isn't needed. 

M

Keith

unread,
Mar 24, 2008, 9:56:29 PM3/24/08
to JEQL Users
It works! Thanks.

On Mar 24, 6:11 pm, "Martin Davis" <mtncl...@gmail.com> wrote:
> Hi, Keith.
>
> Easy handling of tables and geometry are what JEQL is all about!
>
> For (1), you would write:
>
> spatial_join = select subdivision.name, points.id
> from subdivision join points on Geom.intersects(points.GEOM,subdivision.GEOM
> );
>
> IN JEQL SQL, joins are always expressed using the JOIN notation. Also,
> currently only one JOIN per select is supported (but you can mimic more by
> creating several tables in succession)
>
> 2) Looping is (for now) always expressed using select expressions. So the
> case you mention is handled in exactly the same way as (1) above - using a
> JOIN to combine the input tables, and then pulling out the combinations that
> you want by using an ON condition. (This is identical to how SQL works, if
> you're familiar with that paradigm).
>
> There may be situations where explicit looping is desireable - but I'm
> trying hard to make JEQL powerful enough that it isn't needed.
>
> M
>
Reply all
Reply to author
Forward
0 new messages