geo distance #3

Open
opened 2017-11-12 17:00:50 +00:00 by agp8x · 1 comment
	def calc_distance(geojson:str):
		from osgeo import ogr
		geom = ogr.CreateGeometryFromJson(geojson)
		return geom.Length()
``` def calc_distance(geojson:str): from osgeo import ogr geom = ogr.CreateGeometryFromJson(geojson) return geom.Length() ```
Poster
Owner

projected (to meter):

	def calc_distance(geojson: str):
		from shapely.geometry import LineString
		from shapely.ops import transform
		from functools import partial
		import pyproj
		track = LineString(json.loads(geojson)['coordinates'])
		project = partial(
			pyproj.transform,
			pyproj.Proj(init='EPSG:4326'),
			pyproj.Proj(init='EPSG:32633'))
		return transform(project, track).length
projected (to meter): ``` def calc_distance(geojson: str): from shapely.geometry import LineString from shapely.ops import transform from functools import partial import pyproj track = LineString(json.loads(geojson)['coordinates']) project = partial( pyproj.transform, pyproj.Proj(init='EPSG:4326'), pyproj.Proj(init='EPSG:32633')) return transform(project, track).length ```
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ma/project#3
There is no content yet.