Friday, December 9, 2011

Postgresql PostGIS How to set your search_path


The problem:
You want to have all your spatial data in a schema other than "public" in your Postgresql PostGIS database and don't want to have to always specify the schema.tablename when creating new tables.

The solution:

  1. Close the connection to the database you want to change
  2. run the sql query    
            ALTER DATABASE DatabaseName SET search_path = '$user','geodata', 'public';             


in this example the schema 'geodata' is the primary schema where I want to store all my spatial tables.  The order in which Postgresql "searches" where to create the table is then defined in the same order as you have listed in your SET search_path statement.


If you just want to change the search_path for a current session you can use:
SET search_path = '$user','geodata', 'public';

now you can merrily go and create a new table and it will automatically be created in your 'geodata' schema.

if you already have the tables in the 'public' schema and want to move them to your new shiny 'geodata' schema it is really easy to do:

ALTER TABLE name SET SCHEMA new_schema

now if you do this don't forge that your geometry_columns won't automatically reflect your schema changes and must be updated by using

SELECT Populate_Geometry_Columns('geodata.myspatial_table'::regclass);

cheers
Michael

Wednesday, November 23, 2011

How to upgrade Geoserver 2.1.1 to 2.1.2


From 2.1.1 to 2.1.2, Ubuntu 10.04 Server, Tomcat6

Note: all those commands need to be done as root (or alternatively, run sudo before the command)
  1. Stop Apache tomcat:
    /etc/init.d/tomcat stop 
    
  2. Backup the your directories, this could be different from your own installation: /var/geoserver-data, /opt/tomcat/webapps/geoserver/  
    tar -cf geoserver-data-nov-17.tar /var/geoserver-data # takes quite long on current geoserver installation (orthofotos, ...)
    gzip geoserver-data-nov-17.tar
    tar -cf geoserver-app-nov-17.tar /opt/tomcat/webapps/geoserver
    gzip geoserver-app-nov-17.tar
    
  3. Additionally, backup web.xml file from WEB-INF directory:
    cp /opt/tomcat/webapps/geoserver/WEB-INF/web.xml web-backup-nov17.xml
    
  4. Download latest (in this case: 2.1.2) geoserver version (war archive)
    wget http://downloads.sourceforge.net/geoserver/geoserver-2.1.2-war.zip
    
  5. Unzip it
    unzip geoserver-2.1.2-war.zip
    
  6. Copy it to the tomcat webapps directory
    cp geoserver.war /opt/tomcat/webapps/geoserver.war
    
  7. Delete old geoserver installation
    rm -rf /opt/tomcat/webapps/geoserver/
    
  8. Start Tomcat again
    /etc/init.d/tomcat start
    
  9. Wait... (this can take a while, monitor CPU usage via htop or other tools)
  10. Check /opt/tomcat/webapps/ directory, you should see a subdirectory geoserver very soon
    ls -la /opt/tomcat/webapps/
    
  11. Verify that new geoserver version is running by trying to access  http://gs1.gomogi.com:8080/geoserver/
  12. We're not done yet, let's put the old configuration file in place again:
    cp web-backup-nov17.xml /opt/tomcat/webapps/geoserver/WEB-INF/web.xml
    
  13. Restart tomcat once again and all should be good in update land.
    /etc/init.d/tomcat restart

Sunday, July 10, 2011

Why use OpenERP in a small business

Well it did take more than 1/2 hour to get  OpenERP Odoo up and running last night.  To be precise it took exactly 4,75 hours. I must say that I'm impressed with the modules, features and useability.   Now I need at least 1 week to play/customize it and we are off to the races.

Why did I install an Enterprise Resource Planning (ERP) web application for my small business? Well my company GOMOGI  like all other small businesses around the world need to do all the same stuff like big companies on a smaller scale like:
  • manage and engage customers (Customer Relationship Management (CRM))
  • marketing our products
  • write bills/invoices
  • manage projects with AGILE  SCRUM  methodology
  • Getting Things Done way to organize my busy multitasking days, weeks, months and years
This keeps all our STUFF in one place and accessible online at anytime no matter where I am (onsite with a customer, traveling, anywhere). No backing up issues since our hosting provider takes care of that for us.

OpenERP Odoo with its modular design allowed me to install only the modules I need now to keep me running with  the ability to expand and add new features easily when I need them as we grow as a company.

I also have a biased view since I love technology and OpenERP Odoo in the background uses my favourite things Python as its development language and Postgresql as its database, both things I use for my spatial work load.  We also use PostGIS a spatial extension to Postgresql, plus mix and match Python scripts wich is also the language of ESRI scripting :).

Wednesday, June 8, 2011

What Python version do my geospatial apps/libraries use?

Setting up a new PC and I was interested to know what version of Python is being installed and used by various GIS applications and libraries.

The problem many new users have is finding what version to install with what software.  So here is the run down of what is using what Python Version.
  • FWTools 2.4.7 (Windows 32bit)  uses Python 2.3.4
  • ESRI ArcGIS 10 uses Python 2.6.5  on installation
  • ESRI ArcGIS 9.3 uses Python 2.5.1
  • OSGeo4w  uses Python 2.5.2
  • Google AppEngine as of 08.06.2011 uses Python 2.5.2   Roadmap has 2.7 in sight
  • Ubuntu Server 10.04 has Python 2.6.5  as a standard instal
  • Django supports any Python version from 2.4 to 2.7
 A quick note
GdalOgrInPython GDAL this link for details


     Dependencies

  • Python 2.X (and 3.X since GDAL 1.7.0). Python 2 versions known to work range from 2.3 to 2.7.
  • libgdal (1.5.0 or greater) and header files (gdal-devel)
  • numpy (1.0.0 or greater) and header files (numpy-devel) (not explicitly required, but many examples and utilities will not work without it). Note that at the time of writing, there's not yet any Python 3 port of NumPy.
Michael

Monday, March 21, 2011

Quick Start Guide to OpenStreetMap (OSM)

As I find myself teaching more and more people to get started with the OpenStreetMap (OSM)  project the first "Newbie" steps are just still to complicated for non - tech users who want to add a simple house or Point of Interest based off Bing Images aka not using GPS.

It is really quite straight forward. Lets take for example I want to add a parking lot as  POINT so the parking lot symbol will show when rendered with the standard mapnik renderer aka the main map you see when first starting to us OSM maps.

  1. Register for a free account here you need this to do editing.
  2. Zoom to a small area where you want to add some data using the map interface. If you can see your entire city that is to much and is not allowed, try zooming in on a smaller area it will be faster too.
  3. Select the online editor by just holding your mouse over the Edit Tab and select the online editor for this example I'm using Potlatch2 (You need FLASH installed) .
  4. Now double click one time on the sport where you want the parking symbol to show up. Then select the type of object using the drop down list and select "Car Parking".
  5. Add a Name like  "guest parking" if you don't know it you can ignore it.
  6. Add the number of spaces if you know how many there are if not just ignore it.
  7. Click Save in the upper right hand corner and add a simple comment like "added parking spot"
  8. DONE
I managed to keep it under 10 Steps.  I hope this helps those of you just starting out and wishing for quick bang introduction to OSM.

Please feel free to let me know if this works out for you.

Wednesday, January 26, 2011

Free Geodata

Whenever you have a spatial project it usually begins with some data.  Now what if you don't have any data?  Well here come some sources to your rescue. EDEN Data Archive  has a huge list of free data sources

OpenStreetMap
  1. GeoFabrik
  2. Cloudmade
International
  1. ADDS - Africa Data Dissemination Service
  2. Natural Earth
  3. Data Depot's Country List
  4. GeoBase: Canadian site for sources of free GIS data
  5. GeoGratis: Canada's National Digital Atlas
  6. Geoscience Australia
  7. Gridded Population of the World
  8. GoGeo GIS Database (UK)
  9. Russian Federation Digital Data
  10. Southern Africa Regional Science Initiative (SAFARI) 
Imagery
  1. Arizona Regional Image Archive (AVHRR, AVIRIS, MSS, TM, SPOT for six southwestern states including California)
  2. Canadian Geospatial Data Infrastructure
  3. Earth Explorer (Landsat, AVHRR and aerial photos)
  4. Earth Observing System Data Gateway (Atmosphere, land, ocean, solar and cryosphere imagery)
  5. Geoscience Australia (Free Landsat 7, MODIS & AVHRR data)
  6. Global Land Cover Facility (ASTER, Landsat, MODIS, AVHRR)
  7. Global Visualization Viewer (Free ASTER, MODIS and Landsat Imagery)
  8. Landsat.org (Huge collection of Landsat imagery; not all free)
  9. NASA Image Server (Landsat 4,5,7)
  10. Terraserver (Quickie air photo images from Microsoft)
  11. University of Nevada Landsat TM Archive (State of Nevada)
  12. USGS EROS Data Center (Many sensors with links to data access)
Land Cover Data
  1. The U.S. Environmental Protection Agency's Land Cover Data Directory
  2. Global Land Cover 2000
  3. Global Land Cover Facility
  4. GAP analysis program (land cover data by U.S. State)
  5. USGS Geographic Data Download (older LULC data)
  6. National Land Cover Dataset from USGS (seamless and the most current for the US)
    1. NLCD Class Definitions in html or EXCEL .dbf format
  

Friday, January 7, 2011

Python and related spatial resources

To start the first post of the new year here are some thoughts and resources to anyone just starting out in GIS who has NO computer science training at all and wants quick access to great python spatial resources in print and on the web. James Fee over at his blog post has also some thoughts on python for 2011.

Why Python? well ESRI the "world number one" in GIS uses it as its scripting language of choice and VBA will eventually die. Plus the open source GIS scene is also in love with python and of course I just like it.

Python books I invested some money into when I started out.  The rest of the python resources are of course all coming from web sources, blog posts and from reading a TON of documentation.

First off here are two good free books to get you started:
These ones cost some money if you still read hard copies ( I do )
Head First Programming: A Learner's Guide to Programming Using the Python LanguagePython Geospatial DevelopmentLearning Python: Powerful Object-Oriented Programming 


    Second on the list are bloggers who use Python:

    Other spatial Python sources or projects on the web:
     Non Spatial Python web resources and training materials for Python

    Feel free to help me out add to this collection of links and post a comment.
    cheers michael