Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have vector data fed into a database which returns a report at province level upon querying. This is implemented in a web tool.

I want to add an extra functionality at point level, where I can input lat/lon and run a spatial query to calculate some attribute, say distance to coast, based on that point. Let us assume I have data which contains the distance from centroid of the province.

Please suggest me an open source approach to implement this. How feasible would it be to divide the province into grids and dynamically take up the values?

share|improve this question
Please clarify your question title to summarize what is being asked. Also, Zipcodes are actually not geographic areas by definition, but address groups or delivery routes. Thus dividing zipcodes into grids or working with the "centroid" of a zipcode makes little sense from a technical standpoint. – blah238 Jun 20 '12 at 20:36
I am sorry for the confusion. The area I refer to is a province which is divided into coded chunks for postal delivery. Each code represent a specific real world area. – Janus Jun 20 '12 at 20:41
Fix the title, too :) – Ragi Yaser Burhum Jun 21 '12 at 1:05
I am a GIS newbie. I apologize if the question made no sense to you. I dont know how else to phrase it. – Janus Jun 21 '12 at 5:25
up vote 1 down vote accepted

One way to approach this would be to calculate a "cost" raster. It contains the distance to the coast from each raster cell center. In the web tool, you'd just capture the input coordinates and then look up which cell it corresponds to.

share|improve this answer
Thanks a lot! Your answer pointed me in the right direction. – Janus Jul 2 '12 at 12:05

SpatiaLite is a free database that offers spatial queries and functions. The core database is Sqlite. You may want to research "Intersects" for your Point-in-Polygon query and "Distance" to return the distance to coast.

Spatialite functions

There is also a GIS viewer named Spatialite-gis, among other tools, to help visualize your data.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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