Dear T?nis
Yes, that was it.
Many thanks,
Robert
>>> T?nis K?rdi<Tonis.Kardi at regio.ee> 16/07/2013 10:20 p.m. >>>
Hello, seems like the list rejected my mail, but i'll forward it tou
You still.. hope it helps.
All the best,
T?nis K?rdi
________________________________________
Saatja: T?nis K?rdi
Saadetud: 16. juuli 2013. a. 13:11
To: gispython.org community projects
Teema: Vs: [Community] geoJSON
.. {"geometry": {"type": "Point", "coordinates":
["1456220.5418,5248259.03474"]} ..
Not really sure, but coordinates should be without the double quotes
like
{"geometry": {"type": "Point", "coordinates":
[1456220.5418,5248259.03474]}
methinks. And I'd put types all lowercased aswell, that is
"type":"point" or "type":"linestring".
all the best,
t?nis k.
________________________________________
Saatja: Robert Sanson [Robert.Sanson at asurequality.com]: nimel
community-bounces at lists.gispython.org
[community-bounces at lists.gispython.org]
Saadetud: 16. juuli 2013. a. 7:32
To: gispython.org community projects
Teema: [Community] geoJSON
I am working on a Python server-side script to take an uploaded GPX
file, parse it to do some spatial queries, and then format it into
geoJSON to return it to an OpenLayers client.
How critical is the order of the id, properties and geometry elements
in the geoJSON features?
Here are some snippets of Python code:
import json, geojson
#create list to hold geojson features
fl = []
#For each waypoint
for wpt in gpx.waypoints:
#create geojson point based on the lat/longs in the GPX file
re-projected to a cartesian coordinate system
gw = geojson.Point([str(x) +"," + str(y)])
#Prepare my attributes
attr =
{"date":wpt.comment,"fid":fid,"ftype":ftype,"fsize":fsize,"name":name,"postal1":postal1,"postal2":postal2,"postal3":postal3,"postalrd":postalrd,"postal4":postal4,"town":town,
"pcode":pcode,"homeph":homeph,"busph":busph,"mobile":mobile,"email":email,"elevation":str(wpt.elevation),"gheight":str(height),"htdiff":str(htdiff),"colour":colour}
#create the geoJSON feature and add it to the list
gf = geojson.Feature(id=wpt.name,properties=attr,geometry=gw)
fl.append(gf)
#finally put together in a feature collection
fc = geojson.FeatureCollection(fl)
print geojson.dumps(fc)
Here is an example output by my script:
{"type": "FeatureCollection", "features": [{"geometry": {"type":
"Point", "coordinates": ["1455676.30192,5249213.99569"]}, "type":
"Feature", "properties": {"town": "Hokitika", "postal1": null,
"postal2": null, "postal3": "Private Bag 701", "postal4": null, "name":
"Department of Conservation", "busph": "037568282", "mobile": null,
"colour": "brown", "fsize": 1035820.0, "gheight": "355.379", "pcode":
"7810", "ftype": "NAT", "fid": "WS00041", "htdiff": "13.4206970215",
"date": "04-NOV-12 11:19:34AM", "elevation": "368.8", "homeph": null,
"email": "westcoast at doc.govt.nz", "postalrd": null}, "id": "045"},
{"geometry": {"type": "Point", "coordinates":
["1455737.89165,5249119.87719"]}, "type": "Feature", "properties":
{"town": "Hokitika", "postal1": null, "postal2": null, "postal3":
"Private Bag 701", "postal4": null, "name": "Department of
Conservation", "busph": "037568282", "mobile": null, "colour": "brown",
"fsize": 1035820.0, "gheight": "381.533", "pcode": "7810", "ftype": "N
AT", "fid": "WS00041", "htdiff": "-1.23302001953", "date": "04-NOV-12
11:19:41AM", "elevation": "380.3", "homeph": null, "email":
"westcoast at doc.govt.nz", "postalrd": null}, "id": "046"},
{"geometry": {"type": "Point", "coordinates":
["1456220.5418,5248259.03474"]}, "type": "Feature", "properties":
{"town": "Hokitika", "postal1": null, "postal2": null, "postal3":
"Private Bag 701", "postal4": null, "name": "Department of
Conservation", "busph": "037568282", "mobile": null, "colour": "brown",
"fsize": 1035820.0, "gheight": "606.078", "pcode": "7810", "ftype":
"NAT", "fid": "WS00041", "htdiff": "46.5215087891", "date": "04-NOV-12
11:20:59AM", "elevation": "652.6", "homeph": null, "email":
"westcoast at doc.govt.nz", "postalrd": null}, "id": "047"},
{"geometry": {"type": "Point", "coordinates":
["1456236.64781,5248056.9161"]}, "type": "Feature", "properties":
{"town": "Hokitika", "postal1": null, "postal2": null, "postal3":
"Private Bag 701", "postal4": null, "name": "Department o
f Conservation", "busph": "037568282", "mobile": null, "colour":
"brown", "fsize": 1035820.0, "gheight": "748.209", "pcode": "7810",
"ftype": "NAT", "fid": "WS00041", "htdiff": "36.7909545898", "date":
"04-NOV-12 11:24:44AM", "elevation": "785.0", "homeph": null, "email":
"westcoast at doc.govt.nz", "postalrd": null}, "id": "048"},
{"geometry": {"type": "Point", "coordinates":
["1447818.17744,5244104.27075"]}, "type": "Feature", "properties":
{"town": "", "postal1": "", "postal2": "", "postal3": "", "postal4": "",
"name": "", "busph": "", "mobile": "", "colour": "brown", "fsize": 0,
"gheight": "377.242", "pcode": "", "ftype": "", "fid": "", "htdiff":
"52.3581481934", "date": "04-NOV-12 11:37:05AM", "elevation": "429.6",
"homeph": "", "email": "", "postalrd": ""}, "id": "049"}]}
Does this look correct?
Is there some other way to prepare the properties rather than using a
dictionary?
I am having trouble getting OpenLayers to consume this
Many thanks,
Robert Sanson
This email and any attachments are confidential and intended solely for
the addressee(s). If you are not the intended recipient, please notify
us immediately and then delete this email from your system.
This message has been scanned for Malware and Viruses by Websense
Hosted Security.
www.websense.com