Database Reference
In-Depth Information
Importing nonspatial tabular data (CSV)
using PostGIS functions
Thereareacoupleofalternativeapproachestoimporta Comma Separated Values
( CSV ) file, which stores attributes and geometries in PostGIS. In this recipe, we will
usetheapproachofimportingsuchafileusingthePostgreSQL COPY commandand
a couple of PostGIS functions.
Getting ready
Wewillimportthe firenews.csv filethatstoresaseriesofwebnewscollectedfrom
thevariousRSSfeedsrelatedtoforestfiresinEuropeinthecontextofthe European
Forest Fire Information System ( EFFIS ), available at http://effis.jrc.ec.europa.eu/ .
For each news feed, there are attributes like place name , size of the fire in hec-
tares, URL ,andsoon.Mostimportantly,therearethe x and y fieldsthatgivethepo-
sitionofthegeolocalizednewsindecimaldegrees(intheWGS84spatialreference
system, SRID = 4326).
How to do it...
The steps you need to followto complete this recipe are as shown:
1. InspectthestructureoftheCSVfile, firenews.csv ,whichyoucanfindwith-
inthebookdataset(ifyouareonWindows,opentheCSVfilewithaneditor
such as Notepad).
Tip
Downloading the example code
You can download the example code files for all Packt topics you have
purchased from your account at http://www.packtpub.com . If you pur-
Search WWH ::




Custom Search