Created
June 6, 2016 20:44
-
-
Save robgaston/cc206d0e8ec6da831a24c48746aa0c08 to your computer and use it in GitHub Desktop.
Arches - converting WKT to GeoJSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(['openlayers'], function (ol) { | |
var wkt = 'POLYGON ((-77.0199645623452080 38.9367434431880500, -77.0170892342812290 38.9348073023232930, -77.0130981072670690 38.9378116362101990, -77.0173896416908970 38.9389799539040380, -77.0193250499710590 38.9372989139861830, -77.0199645623452080 38.9367434431880500))'; | |
var wktFormat = new ol.format.WKT(); | |
var geoJSONFormat = new ol.format.GeoJSON(); | |
var geom = wktFormat.readGeometry(wkt); | |
var geoJSON = geoJSONFormat.writeGeometry(geom); | |
console.log(geoJSON); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.geos import GEOSGeometry | |
wkt = 'POLYGON ((-77.0199645623452080 38.9367434431880500, -77.0170892342812290 38.9348073023232930, -77.0130981072670690 38.9378116362101990, -77.0173896416908970 38.9389799539040380, -77.0193250499710590 38.9372989139861830, -77.0199645623452080 38.9367434431880500))' | |
geom = GEOSGeometry(wkt) | |
geojson = geom.geojson | |
print geojson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment