Using OGR to convert GIS Vector formats

OGR is a part of GDAL and is very useful for converting between geospatial vector formats. What does that mean? When storing Vector GIS data there are a dizzying number of formats it can be stored in, some of the more popular of late, or at least well known are KML and SHP. A friend of a friend was looking to convert some SHP (Shapefiles) into KML so that he could make a Google Maps mashup and I helped him out. Here is a workflow for how I went about performing the conversion.

OGR can be installed on debian/ubuntu machines by installing the package gdal-bin:

sudo apt-get install gdal-bin

Once you have GDAL/OGR installed you get a slew of command line utilities, I’ll try to cover some others in later tutorials, but for now we’re interested in ogr2ogr. ogr2ogr converts between the vector formats that OGR understands.

Example using a shapefile at the city of chicago website:
Download the data

wget http://egov.cityofchicago.org/webportal/COCWebPortal/COC_ATTACH/TIFS2008.zip

Unzip it

unzip TIFS2008.zip

Now we have to do the hard part (not really that hard, but important), look for the projection information in the metadata. I looked in the tifs.shp.xml file and found that the projections is:

NAD_1983_StatePlane_Illinois_East_FIPS_1201_Feet

Google uses WGS84 spatial reference system.
Now we have to lookup EPSG codes that OGR understands for these projections. A good spot to do this is spatialreference.org. EPSG codes provide a short form of expressing projection and spatial reference information.
Once we have that all sorted out we’re ready to run ogr2ogr:

ogr2ogr -f "KML" -s_srs "EPSG:102671" -t_srs "EPSG:4326" tifs.kml tifs.shp

The -f “KML” specifies that we want the output in KML. -s_srs is the source (tifs.shp) spatial reference system and -t_srs is the target spatial reference system found at spatialreference.org, then we specify the output file tifs.kml and the input file tifs.shp. That is it!

Lets shrink it down into a kmz (compressed kml) so that it takes up less disk space.

zip tifs.kmz tifs.kml

Antrhopogenic RF Interference

Was looking at raw AMSR-E data (a passive microwave radiometer flying on board Aqua). Can you tell where the cities are?

pmtbeqn29d016y080308v06sa.png

Hmmm…I wonder what one can do with this? A development indicator, surrogate for population? Very interesting. This anthropogenic interference gets in the way of soil moisture detection over land, but I wonder if it can be used creatively for something else.

Small houses

I have a dream of having one of these buildings (slideshow at Wired.com) in my back yard as a home office someday. Another dream is to get an acreage and scatter several of these buildings around with some paths connecting them together.

5 Dangerous things you should let your kids do.

Gever Tulley has a great video about the sort of dangerous things kids need to do when growing up. It is nice to see this kind of thing. Its a breath of fresh air from the fear society we live in. On a related note, kids don’t get the freedom to go out walking and exploring much anymore.

Scanning with sane’s scanimage from an ADF scanner to PDF and OCRed Text

Using libsane and tesseract, you can scan from an ADF (or non ADF) scanner in Ubuntu 7.10 to a PDF and OCR’ed text document with a few easy steps.

First we need to make sure we have the necessary packages installed.

apt-get install tesseract-ocr sane-utils

Continue reading ‘Scanning with sane’s scanimage from an ADF scanner to PDF and OCRed Text’

ntfsundelete

Just did a stupid thing and deleted a whole tree of file on a windows partition. Never fear…ntfsundelete is here.

sudo ntfsundelete -u -d /destination/directory -f -m *.jpg /dev/sda1

Run without the -u option and -d options to show what can be recovered.

On ubuntu/debian to install it do:

apt-get install ntfsprogs

Getting to know PostGIS

I am making the plunge to get more informed with how to use PostGIS. It is pretty impressive so far. Here is a quick tutorial which shows you how to get started and loading in a shapefile to play around with some fun SQL querying. I assume a basic understanding of the linux command line and some basic SQL skills.

To get started in ubuntu 7.04 (should work in 7.10 and debian too):

$ sudo apt-get install postgis postgresql-8.1-postgis

Next we’ll start setting up the PostGIS environment.
Continue reading ‘Getting to know PostGIS’

A bundle of links…

Some neat things found on the web recently:

  • Ponoko - Custom Laser cutting of Plexiglas and plywood.
  • Make your circuit boards in china for cheap
  • CouchDB simple database for content management systems.
  • Mabel’s Labels - Got kids? Need to label their stuff, these look neat.
  • San Diego Fires on MODIS

    Just whipped together an animation of the San Diego Fires from some recent MODIS scenes that I grabbed from the MODIS Rapid Response System. I put the animation together using GIMP.

    San Diego Fires
    (Click for Larger Version 1.9MB)

    United Airlines Marketing

    So, I receive this letter in the mail about once per week for the last 3 months telling me I have a balance in my United Mileage Plus account. It says I have 6,904 miles, that plus the 21,500 I’ll get from United will let me get enough for a free ticket which runs 25,000 miles, oh boy! Never mind the $60 annual fee, the 18.24% APY, I can get a free ticket baby…I can go places…see the world.

    united1.png

    Wait, what is that…there is an asterisk there…what does it say about that. “Based on mileage plus account balance as of 6/1/07. United Mileage Plus is not liable for mileage balance misprints.” Hmmm…alright.

    Ok, well lets go check united.com:
    united2.pngWhat’s this..my miles expired on 06/30/2007, leaving me with a balance of 0.

    So the notice I have been receiving every week for 3 months straight has been grossly misleading and too good to be true. I know the airlines are hurting….but c’mon guys lay off the deceptive marketing practices.