[gdal-dev] VRT, CSV and geonames database import

Thomas Gratier osgeo.mailinglist at gmail.com
Sat May 1 19:09:27 EDT 2010


In the previous post, I forget the title so the same post with the
title, sorry...

Hello,

First time I come to this list.

I have a problem using FwTools 2.4.7 with VRT and CSV
I want to transform french geonames file to PostgreSQL with the geometry build

What I do to get this issue ?

Creation of a VRT called geonames.vrt containing

----------------------------------------
<OGRVRTDataSource>
<OGRVRTLayer name="geonames">
<SrcDataSource>geonames.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:4326</LayerSRS>
<GeometryField encoding="PointFromColumns" x="latitude" y="longitude"/>
</OGRVRTLayer>
</OGRVRTDataSource>
----------------------------------------
or with attributes
----------------------------------------
<OGRVRTDataSource>
<OGRVRTLayer name="geonames">
<SrcDataSource>geonames.csv</SrcDataSource>
<Field name="latitude" type="Real" />
<Field name="longitude" type="Real" />
<Field name="geonameid" type="Integer" />
<Field name="name" type="String" width="200" />
<Field name="asciiname" type="String" width="200" />
<Field name="alternatenames" type="String" width="5000" />
<Field name="feature class" type="String" width="10" />
<Field name="feature code" type="String" width="10" />
<Field name="country code" type="String" width="2" />
<Field name="cc2" type="String" width="60" />
<Field name="admin1 code" type="String" width="20" />
<Field name="admin2 code" type="String" width="80" />
<Field name="admin3 code" type="String" width="20" />
<Field name="admin4 code" type="String" width="20" />
<Field name="population" type="Integer" />
<Field name="elevation" type="Integer" />
<Field name="gtopo30" type="Integer" />
<Field name="timezone" type="String" width="100" />
<Field name="modification date" type="Date" />
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:4326</LayerSRS>
<GeometryField encoding="PointFromColumns" x="latitude" y="longitude"/>
</OGRVRTLayer>
</OGRVRTDataSource>




----------------------------------------




Creation of a geonames.csv file with this structure ( file around 3 Mo
for all the database on http://raster.analysesig.net/geonames.zip)

----------------------------------------
"latitude","longitude","geonameid","name","asciiname","alternatenames","feature
class","feature code","country code","cc2","admin1 code","admin2
code","admin3 code","admin4
code","population","elevation","gtopo30","timezone","modification
date"
"45.81667","1.76667","2967103","Peyrat-le-Château","Peyrat-le-Chateau","Peyrat","P","PPL","FR","","B1","87","872","87117","1140","","463","Europe/Paris","2006-04-29"
"43.16667","-0.91667","2967104","Soule","Soule","La
Soule,Soule,Xiberuea,Xiberüa,Zuberoa","L","RGN","FR","","97","64","","","0","","182","Europe/Paris","2006-04-07"
"45.16667","-0.68333","2967105","Île Boucheau","Ile Boucheau","Ile
Bouchaud,Ile du Grand Fagnard,Ile du Grand Fagnarg,Île Bouchaud,Île du
Grand Fagnard,Île du Grand
Fagnarg","T","ISLX","FR","FR","97","","","","0","","-9999","Europe/Paris","1996-03-21"
"44.81667","6.11667","2967106","Val Godemard","Val Godemard","Val
Godemar","T","VAL","FR","FR","B8","05","","","0","","1054","Europe/Paris","1994-01-06"
"47.5","3.81667","2967107","Domecy-sur-le-Vault","Domecy-sur-le-Vault","Domecy","P","PPL","FR","","A1","89","892","89146","107","","303","Europe/Paris","2006-04-30"
"45.13333","-0.66667","2967108","Blaye","Blaye","Blaia,Blaye-et-Sainte-Luce","P","PPLA3","FR","","97","33","331","33058","5277","","-9999","Europe/Paris","2010-04-19"
"50.8","2.43333","2967109","Zuytpeene","Zuytpeene","","P","PPL","FR","","B4","59","594","59669","483","","30","Europe/Paris","2006-04-30"

Finally launching of

------------------------------------------------------
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=username
dbname=mydatabase password=my_password" geonames.vrt

------------------------------------------------------
It stops in the middle of the import around line 51000 depending of
the use of the first or the second VRT example

I supposed I miss something but what ?

Thanks for any help

Regards

ThomasG


More information about the gdal-dev mailing list