Database Reference
In-Depth Information
3. Youcouldquerythe IT.txt fileasanOGRentity.Forexample,analyzeone
of the dataset featuresas shownin the following code:
$ ogrinfo CSV:IT.txt IT -where "NAME =
'San Gimignano'"INFO: Open of
`IT.vrt'using driver `VRT'
successful.Layer name: IT
Geometry: Point
Feature Count: 1
Extent: (11.042720, 43.469240) -
(11.042720, 43.469240)
Layer SRS WKT:
GEOGCS["WGS 84",
...
GEONAMEID: String (0.0)
NAME: String (0.0)
ASCIINAME: String (0.0)
...
MODDATE: String (0.0)
OGRFeature(IT):7791
GEONAMEID (String) = 3168320
NAME (String) = San Gimignano
ASCIINAME (String) = San Gimignano
...
MODDATE (String) = 2012-02-15
POINT (11.04272 43.46924)
4. For your purpose, you just need the name , asciiname , latitude , and
longitude attributes. You will import the file to PostGIS using the CSV
OGRdriver( http://www.gdal.org/ogr/drv_csv.html ) .Use ogr2ogr command
to import this GeoNames dataset in PostGIS:
$ ogr2ogr -f PostgreSQL -s_srs EPSG:4326
-lco GEOMETRY_NAME=the_geom -nln
chp08.geonames
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'" CSV:IT.txt -sql
"SELECT NAME, ASCIINAME FROM IT"
Search WWH ::




Custom Search