#NEWLINE# def esri2geojson( esri_url , geojson_path ) : #NEWLINE# #INDENT# ' Convert single ESRI feature service URL to GeoJSON file.\n    ' #NEWLINE# workdir = mkdtemp ( prefix = 'esri2geojson-' ) #NEWLINE# ogr . UseExceptions ( ) #NEWLINE# try : #NEWLINE# #INDENT# task = EsriRestDownloadTask ( 'esri' ) #NEWLINE# ( csv_path , ) = task . download ( [ esri_url ] , workdir ) #NEWLINE# _L . info ( 'Saved {esri_url} to {csv_path}' . format ( ** locals ( ) ) ) #NEWLINE# vrt_path = write_vrt_file ( csv_path ) #NEWLINE# ds_in = ogr . Open ( vrt_path ) #NEWLINE# driver = ogr . GetDriverByName ( 'GeoJSON' ) #NEWLINE# if exists ( geojson_path ) : #NEWLINE# #INDENT# remove ( geojson_path ) #NEWLINE# #UNINDENT# ds_out = driver . CopyDataSource ( workdir , geojson_path ) #NEWLINE# ds_out . Release ( ) #NEWLINE# _L . info ( 'Converted {csv_path} to {geojson_path}' . format ( ** locals ( ) ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# rmtree ( workdir ) #NEWLINE# _L . info ( 'Removed {workdir}' . format ( ** locals ( ) ) )