01 January 2011

How to convert excel data into pgsql
      1.       Save excel data into csv
1.1   Change column name xcoord= long, ycoord = lat
1.2   Sperator coma(,)
2.       Convert csv to shapefiles.
2.1   Create dbf file via commad( ogr2ogr –f "ESRI Shapefile" OUTPUT.shp INPUT.csv)
2.2   Create shapefile via command ( ogr2ogr –f "ESRI Shapefile" OUTPUT.shp INPUT.vrt)
Sample code:
Test.csv:
long,lat,value
12,23,123
Test.vrt:
<OGRVRTDataSource>
  <OGRVRTLayer name="test">
    <SrcDataSource relativeToVRT="1">F:\temp\sam\testcsv</SrcDataSource>
    <SrcLayer>Bredevoort</SrcLayer>
    <GeometryType>wkbPoint</GeometryType>   
    <GeometryField encoding="PointFromColumns" x="long" y="lat"/>
  </OGRVRTLayer>
</OGRVRTDataSource>
3. convert shape to sql via shp2pgsql
With this ogr2ogr libray, who need ESRI arcgis?!?!

--
Xiaoyu Guan (Sam)
http://guanxiaoyu.blogspot.com

No comments: