Quiero tomar la salida XML de una consulta Xapi y mostrarla usando un folleto o polymaps. ¿Cómo puedo hacer eso? ¿Hay una manera fácil de convertir XML a geojson
Quiero tomar la salida XML de una consulta Xapi y mostrarla usando un folleto o polymaps. ¿Cómo puedo hacer eso? ¿Hay una manera fácil de convertir XML a geojson
OSM2GEO - Un convertidor JS para convertir OSM a GeoJSON
* OSM2GEO - OSM to GeoJSON converter
* OSM to GeoJSON converter takes in a .osm XML file as input and produces
* corresponding GeoJSON object.
*
* AUTHOR: P.Arunmozhi <>
* DATE : 26 / Nov / 2011
* LICENSE : WTFPL - Do What The F##% You Want To Public License
* LICENSE URL: http://sam.zoy.org/wtfpl/
*
* DEPENDENCY: OSM2GEO entirely depends on jQuery for the XML parsing and
* DOM traversing. Make sure you include <script src="somewhere/jquery.js">
* </script> before you include osm2geo.js
*
* USAGE: This script contains a single function -> geojson osm2geo(osmXML)
* It takes in a .osm (xml) as parameter and returns the corresponding
* GeoJson object."
Crédito a P.Arunmozhi
La versión de desarrollo (como marzo de 2013) de gdal tiene soporte de lectura para OSM , tanto para el formato liso XML y PBF.
Para que pueda convertir su archivo OSM con:
ogr2ogr -f GeoJSON myfile.geojson myfile.osm.pbf
Puedes convertir OSM XML a GeoJson con ogr2ogr. Para convertir a GeoJSON sin obtener el siguiente error:
ERROR 6: GeoJSON driver doesn't support creating more than one layer
Puedes usar uno de los siguientes comandos o todos ellos:
ogr2ogr -f GeoJSON points.json data.osm.pbf points
ogr2ogr -f GeoJSON lines.json data.osm.pbf lines
ogr2ogr -f GeoJSON multilinestrings.json data.osm.pbf multilinestrings
ogr2ogr -f GeoJSON multipolygons.json data.osm.pbf multipolygons
ogr2ogr -f GeoJSON other_relations.json data.osm.pbf other_relations
osmtogeojson es otro convertidor de OSM a GeoJSON, que tiene algunos beneficios en comparación con este (OSM2GEO) o osm-and-geojson:
La biblioteca ya está en uso en geojson.io , así como overpass-turbo.eu .
complemento de OpenStreetMap para el folleto es otra forma de hacerlo. De esta manera puede utilizar su consulta de Xapi directamente en su código. Aunque solo tiene sentido para pequeños conjuntos de datos, ya que la solicitud lleva un tiempo.
Use osmtogeojson como está escrito en esta guía :
osmtogeojson Pittsburgh.xml > Pittsburgh.geojson
Lea otras preguntas en las etiquetas openstreetmap geojson leaflet polymaps xml