3

I'm new to GIS applications and trying to figure out what options I have for visualizing spatial query results that combine raster and vector data using OpenLayers/GeoExt/GeoServer/PostGIS.

A hypothetical query that could be created on a web client by a user might be: "give me all raster pixels with an index value of 1 that are within a distance of 120 meters of any river (line vector feature) and touching or inside a selected watershed (polygon vector feature)".

I think I have a good idea how I could write a where clause for a spatial SQL query such this, but it's not at all clear where I'm submitting this type of query from my JavaScript web client. Some PHP examples I've found seem to suggest that a server side process will have to submit the SQL query, presumably directly to the PostGIS database? Is this correct?

It's also not super clear how I can visualize mixed raster/vector query results. I've seen some purely vector examples that create a vector map layer in OpenLayers and when the vector features come back to the client, those features are simply pushed onto the vector map layer. Assuming a mixed vector+raster query is possible in PostGIS, should I be expecting to follow the same process (get vector features back, then add them to a vector OpenLayers layer) for visualization?

Lastly, does it even sound like I'm thinking along the right lines here or am I attempting to do something that is difficult or even impossible given the feature sets available in Open Source GIS tools these days?

1

To answer just one part of the question, specifically

I think I have a good idea how I could write a where clause for a spatial SQL query such this, but it's not at all clear where I'm submitting this type of query from my Javascript web client. Some PHP examples I've found seem to suggest that a server side process will have to submit the SQL query, presumably directly to the PostGIS database? Is this correct?

Yes, you need to have some server side scripting to access your database, and you have to be very careful that you don't open your application to SQL injection type security vulnerabilities. I would recommend using prepared statements for accessing your DB layer.

See http://en.wikipedia.org/wiki/Prepared_statement for more information.

  • Definitely, keeping SQL injection in mind is a good point. Still struggling to piece together the big picture, though. Overall, Raster+Vector query functionality seems pretty limited in most spatial databases, including PostGIS. Hoping someone can prove me wrong, though. Cheers! – JDischler Apr 30 '13 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.