[gdal-dev] Convert DBX/SHP to JSON using ogr2ogr
Even Rouault
even.rouault at mines-paris.org
Sun Jun 3 09:50:39 PDT 2012
Le dimanche 03 juin 2012 18:32:48, Tobias Preuss a écrit :
> Hello. I am trying convert shape files [1] of London (Canada) into
> JSON. I am totally new to these formats but at least I found out that
> ogr2ogr is able to do the job. However, there are two files that
> contain the data as far as I can tell. One file TREES.DBF contains all
> the properties. The other file trees.shp holds the main objects (trees
> in this case) with an identifier. I can convert each file into JSON
> with the following commands.
>
> $ ogr2ogr -f GeoJSON -s_srs EPSG:26917 -t_srs EPSG:4326
> trees_coordinates.json trees.shp
> $ ogr2ogr -f GeoJSON -s_srs EPSG:26917 TREES_properties.json TREES.DBF
>
> I am not sure what the other files are good for?!
A shapefile consists at the minimum of .shp, .shx and .dbf files.
.shp contains the geometry, .shx is an index to the .shp, and .dbf contains
the properties.
The OGR Shapefile driver can read geometries and properties together, but in
the particular case of this dataset, if you are on Unix/Linux, due to the case
sensitivity of filesystems, you need to rename TREES.DBF to trees.dbf, so that
.dbf and .shp are associated.
I've tested that the following command then gives sensible result :
ogr2ogr -f GeoJSON -s_srs EPSG:26917 -t_srs EPSG:4326 trees.json trees.shp
And to finish answering your question, the .sbn and .sbx are ESRI specific
spatial index, and .shp.xml a ESRI specific metadata file. All 3 not used by
OGR.
More information about the gdal-dev
mailing list