1

I have at hand a common GIS task:

The data: I posses 16,000 Excel rows. Each has latitude and longitude and some other attributes. I need to build a program that allows the user to type in a location and a radius and then the program will look up the data and fetch only those points that fall within the given radius. The output should be a map with the fetched points displayed, but also a table listing the points that fall within the radius.

I am aiming for a web mapping solution.

Also, what programming language do you think would be suited for this?

Any particular web map API?

I am good at Python, but not so good at Javascript.

closed as too broad by PolyGeo Aug 6 '17 at 20:47

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • There is no way we can help you without much more context. For example, what are the organisational policies on application deployment? That will inform the thick-client vs web application decision. How many of the points will be on the screen at once? What have you already looked at? What have you already tried / disregarded and why? – BradHards Dec 27 '13 at 9:23
  • I edited the question by being restricted to a web mapping solution. I haven't tried anything because I don't know what to try and hope someone could share a previous experience with a similar problem. – multigoodverse Dec 27 '13 at 9:41
4

I'd recommend following technology stack: a PostGIS database in combination with a python backend (I recommend flask - http://flask.pocoo.org/) serving JSON, which then gets displayed in the frontend on a map powered by leaflet (http://leafletjs.com/) and some sprinkles of javascript to render the attribute table; a framework like backbone or angularjs would be overkill.

Here is a sample for the python backend (be aware that this is just a quick and messy example which should never be run in production!). It queries against the geonames dataset and returns id and name as attribute to display in a table as well as a geojson to display in a map. The query-url would be:

host/search?lat=48&lon=12&rad=1

with the radius rad in degrees.

from flask import Flask, jsonify, url_for, request
import psycopg2
import json

conn = psycopg2.connect(database='***', user='***')
  curs = conn.cursor()

app = Flask(__name__)

@app.route("/search")
def search():
  # GET data from request
  data = (request.args.get('lat', ''), request.args.get('lon', ''), request.args.get('rad', ''))

  # Query PostGIS
  curs.execute("""\
    SELECT geonameid, name, ST_Distance(geom, point) as distance, ST_AsGeoJSON(geom)
    FROM geotest, (SELECT ST_MakePoint(%s, %s) AS point) AS f
    WHERE ST_DWithin(geom, point, %s)
    ORDER BY ST_Distance(geom, point) ASC;""", data)
  res = []

  # build response
  for row in curs.fetchall():
    rec = {"id": row[0], "name": row[1], "distance": row[2], "geojson": json.loads(row[3])}
    res.append(rec)

  # serve response
  resp_data = json.dumps(res)
  return Response(resp_data, status=200, mimetype='application/json')

if __name__ == "__main__":
  app.debug = True
  app.run()

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