IDW on Google Map


Inspired by bad weather this afternoon, I made this basic Inverse Distance Weighted interpolator, written in JavaScript, displayed by PaperJS objects on top of a Google Map. It makes several randomly placed points with random values, then interpolates the colored surface based on the distance-weighted influence of the points. There are lots of geographic applications that may use this technique (rain, temperature surfaces, etc.), but I’m not feeling too inspired to go further right now. Let me know if you do!


4 thoughts on “IDW on Google Map

  1. Pingback: Magical Mystery Contours (raster to contour algorithm) | Darren's Side Projects

  2. Rory Kavanagh

    Hi Darren. I’m trying to implement something similar except all my points are in Latitude and Longitudes. Would you have any ideas on how to implement the IDW formula with the points in this format?

  3. dkwiens Post author

    Hi Rory,

    You could cycle through your lat/lng points, get their pixel coordinates using the function latLngToPoint(latLng), and change the line:

    var randPoint = new Point(maxPoint * Point.random());
    var randPoint = new Point(THE NEW XY COORDINATES);

    Please let me know how it goes and where you use it.

  4. Rory Kavanagh

    Hi Darren,

    Thanks for the reply. I understand what you’re saying there. I’m having a problem getting it working though. I’m extracting my data from a CSV file using a JQuery AJAX function. I can’t seem to pass the data to the drawPoint function. I know the data extraction method works on its own and I know your code works, but when I put the two together, it fails.

    Any suggestions on where to go from here?

    Thanks again man for the help!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s