Import shape files to postgis

This howto is dedicated to Laura, the first that made cun comment on my blog. Well once we have postgis installed on a server (windows or linux) the easiest way to import a shp file to postgis is by using the hp2pgsql command.

All we have to do is look for where our binary shp2psql is, and then we run:
shp2pgsql -I -s 4326 -W latin1 barrios.shp barrios | psql -U postgres -d geoprop

I explain the options:

-I to create a geometric index.
-s projection, 4326 = WGS84
-W the charset, it is very important to use latin1 if they have accents.
-U the user of the database
-d database to be used.

Then they edit the table with pgadmin for example and they change what they want but they will already have all the data, the geometric ones and the associated dbf.

If you need a postgres hosting with mapserver, geoserver and postgis support I recommend Root Solutions .