Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a shapefile (.shp) to xml/json

I'm working with a shapefile (.shp, .dbf, etc) and would like to convert it to xml. I'm on a mac, and I'm having trouble finding an application that will help me with the conversion. Does anyone know of a method for converting this file format into an xml file?

like image 478
minimalpop Avatar asked Feb 08 '10 18:02

minimalpop


People also ask

How do I convert shapefile to GeoJSON in Arcmap?

Using this web site, in the “Convert to GeoJSON” section, under “File*:” Browse to and choose your file. Then select “Convert to GeoJSON”. This will generate GeoJSON code and display in a new window (Example 2).

What is SHP XML file?

shp. xml : the file that is the geospatial metadata in XML format, (e.g. ISO 19115 or XML format).

How do I convert a shapefile to GeoJSON Qgis?

Just drag the Shapefile files, one click on button and convert to GeoJSON. There are many website which provides the tool to convert the files by browsing them to server side and convert and also some client side conversion too.


1 Answers

What dassouki said. Get GDAL from http://www.kyngchaos.com/software:frameworks. Use it to convert a shapefile to GeoJSON like this:

$ ogr2ogr -f "GeoJSON" output.json input.shp 

eg

$ ogr2ogr -f "GeoJSON" /tmp/world.json world_borders.shp world_borders $ cat /tmp/world.json { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "CAT": 1.000000, "FIPS_CNTRY": "AA",   "CNTRY_NAME": "Aruba", "AREA": 193.000000, "POP_CNTRY": 71218.000000 },    "geometry": { "type": "Polygon", "coordinates": [ [ [ -69.882233, ...   ... 
like image 83
sgillies Avatar answered Sep 21 '22 17:09

sgillies