viernes, enero 09, 2009

Agregar el template_postgis en PostgreSQL

Después de renegar un poquito con mi instalación de postgis en Ubuntu, puntualmente era que no tenia instalado el template_postgis. Revolví un poco en google y encontre esto (que es literalmente como se dice un COPY & PASTE!! de aquí). Lo único que tuve que modificar fue la ruta a los archivos lwpostgis.sql y spatial_ref_sys.sql

Nota: el archivo lwpostgis.sql también se puede encontrar como: postgis.sql, en mi Ubuntu (Karmic) el directorio donde se encuentran estos archivos es: /usr/share/postgresql/8.4/contrib/postgis-1.5/

  1. Create a database with UTF encoding  
  2. $ createdb -E UTF8 -O postgres -U postgres template_postgis  
  3.   
  4. Load the required language for PostGIS  
  5. $ createlang plpgsql -d template_postgis -U postgres  
  6.   
  7. Load postgis functions and spatial reference info  
  8. # which are sometimes installed in the postgres share directory ($ pg_config --sharedir)  
  9. # Also look for lwpostgis.sql and spatial_ref_sys.sql in (/usr/share/  or /usr/local/share/)  
  10.   
  11. # Once you have found the correct location, load the first sql into your template db:  
  12. $ psql -d template_postgis -U postgres -f /usr/share/lwpostgis.sql  
  13.   
  14.   
  15. # Note: ignore any NOTICES, like 'psql:/usr/share/lwpostgis.sql:44: NOTICE:  type "histogram2d" is not yet defined'  
  16. # You should see output like:  
  17. BEGIN  
  18. CREATE FUNCTION  
  19. CREATE OPERATOR  
  20. CREATE TYPE  
  21. CREATE AGGREGATE  
  22. COMMIT  
  23.   
  24. Then load the geographic projection tables  
  25. $ psql -d template_postgis -U postgres -f /usr/share/spatial_ref_sys.sql  
  26.   
  27. # if you get an error about not being able to find  `geos` add /usr/local/lib to /etc/ld.so.conf  
  28. And run:  
  29. $ ldconfig # Then restart PostgreSQL  

No hay comentarios.: