Maptime: Spatial databases and their use (part 1 of 2)

Eric Theise (@erictheise) will be leading us in a hands-on lesson about spatial databases! 

From Eric:

Crack your knuckles, this'll be a fast-paced, hands-on Maptime. We'll start with an overview and installation of PostgreSQL, PostGIS, and supporting utilities. We'll talk about creating databases, address basic security concerns, then run through examples of what you can do with a relational database, and one that's spatially-enabled to boot. We'll start by using Leaflet to plot some basic markers, then advance to working with data from OpenStreetMap and shapefiles to generate and serve our own map tiles.

Next week, we'll build on this foundation and do some intermediate-level client-side work with Leaflet, GeoJSON, and more.

We'll be moving quickly, so advance preparation is key. It takes a long time to download all the pieces we'll be using, so start this weekend!

Xcode:

Download this from the Apple App Store. Once you've installed it, go to Preferences and install the Command Line Tools Component.

Homebrew:

The single line you need to get going with Homebrew is on this page: http://brew.sh/ More detailed information is given at https://github.com/mxcl/homebrew/wiki/installation

There's a helpful write-up on setting up these tools, as well as git, at http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/

Go no further than Step 5! You don't need RVM, Ruby, or Rails for what we'll be doing.

TileMill:

You may have already downloaded TileMill at an earlier Maptime, but get it from https://www.mapbox.com/tilemill/

I'll be setting up a fresh installation over the weekend to find any rough spots, and will list other requirements as comments here on the Maptime Meetup page.



Join or login to comment.

  • Eric T.

    Hey folks, the deck for this old pair of MaptimeSFs was extensively revised and expanded for presentations at this year's FOSS4G conference in Portland and NACIS in Pittsburgh. In the installation phase, there are now branches for OS X, Ubuntu 14, and Windows 8.1. In the front end phase, there's now a little Node.js server that returns GeoJSON for Leaflet to plot. Lots of changes throughout. Permanent home at http://erictheise.github.io/geostack-deck/

    2 · September 17

  • Ian S.

    Eric, I'm curious if you are still planning to post some slides or other info from the last meet up, since I didn't have my setup configured to be able to follow along. No worries if you don't have time - thanks!

    1 · November 17, 2013

    • Karsten

      I'm happy to help tuesday since I did get mine setup.

      November 18, 2013

  • Eric T.

    Hey everyone, I've put slides up at http://erictheise.com/maptime_platform_slides/ Please don't share or retweet beyond our MaptimeSF group for now.

    These slides get you to where we left off last week. I'll continue to update them between now and our meeting this coming Wednesday; ideally we'll use the slides for all exercises and it'll be easy to cut-and-paste commands.

    If you find any errors, let me know. See many of you on Wednesday. I'll also post something to the page for the upcoming Meetup later tonight.

    November 18, 2013

  • Rob R.

    Got the opening availability too late. Would be great if it's possible to do another round of pt 1.

    November 13, 2013

    • Eric T.

      Rob, I'd be happy to do pt 1 & pt 2 again sometime early next year, and I'll be posting slides over the weekend. There seems to be interest in using this material to create a foundation for other Maptime exercises/explorations.

      November 13, 2013

    • Rob R.

      Thanks Eric. Will keep an eye out for info about it and will check out the slides.

      November 15, 2013

  • Daniel B.

    Really nice job leading us through some complex code in a simple way!

    1 · November 13, 2013

  • Amy S.

    This was the best introduction to PostgreSQL and PostGIS - and I have a database to show for it! Thanks Stamen. :)

    November 13, 2013

  • Jason F.

    Thanks again to Eric for running the show and Beth for being our Stamen chaperone for the evening.

    I have a question about creating a db from the template we created. I ran the command as shown in the PostGIS documentation http://postgis.net/docs/manual-2.1/postgis_installation.html#templatepostgis - the database seemed to have created fine, but when I went to import the OSM PBF file, I came across an error that gis.stackexchange told me that the database wasn't spatially enabled.

    After running the extensions manually in the database my osm2psql command worked fine.

    So, any idea why the create didn't work?
    $ createdb -T template_postgis maptimesf

    November 13, 2013

    • Eric T.

      CREATE DATABASE maptimesf TEMPLATE template_postgis;

      November 13, 2013

    • Eric T.

      to create my db. Gotta love Meetup's assumption that <return> = end of post.

      November 13, 2013

  • Daniel B.

    OK, new question: is xcode 4.6.1 sufficient?

    thanks~!

    November 13, 2013

  • Daniel B.

    I'm looking forward to the event, and will arrive early--but if I'm using OSX as[masked] (don't laugh, please), can I find a compatible version of x-code?

    November 13, 2013

  • Nancy M.

    Ah - was far enough back on the wait list that I didn't expect to get on. Updating xcode from 4.x looks like it will take me past map time, so I'll give up my spot. If the update speeds up in time and there's still room, I'll swing by.

    November 13, 2013

  • A former member
    A former member

    Hi Everyone,
    This meetup looks great (a bit challenging for me but I look forward to it!) Seems like the waitlist is getting quite long though--what is the likelihood of there being space for those on the waitlist? Thanks !

    1 · November 12, 2013

    • Alan M.

      The main problem is that we literally don't have enough space to seat everybody! If this lesson is successful (and I'm sure that it will be!) we will probably schedule it again in a few months.

      November 12, 2013

    • A former member
      A former member

      Okay, thanks Alan, have a great time!

      November 12, 2013

  • Rob R.

    Would like to attend, sounds like a great workshop. Hope it can get scheduled again if it works out.

    November 12, 2013

  • Eric T.

    Hi Alan. Last time I was at Maptime, I looked around the room and only saw  after  after . I was cowardly hoping this question wouldn't come up as I'm no longer familiar with the Windows world. (I occasionally run XP on a virtual machine, and then only for browser testing & Quicken.)

    For the Mac, Xcode provides a compiler and a set of standard libraries. Homebrew installs additional, pre-vetted packages. I don't know if there's an equivalent in the Windows world (for Linux, yum & apt are common package managers).

    Tools we'll be using include current versions of PostgreSQL, PostGIS, TileMill, TileStache, & osm2pgsql, as well as Python 2.7. Those exist for common operating systems. Because the majority of Maptime attendees use Macs, that's what I'll focus on, but the commands I'll issue through these tools should work across platforms.

    I am in Los Angeles at the moment, with sketchy Internet access, and behind where I would like to be with my fresh installation. Working on it.

    November 11, 2013

    • Marina S.

      Eric - I must be the group's outlier :) I plan on borrowing a friend's Mac, performing all work on it and then trying to replicate steps on Windows. I've used Mac before but please bear with me if I am slow.

      November 11, 2013

    • Eric T.

      Sean, thanks for offering to help out. This is a pretty ambitious Maptime, so I (& others) appreciate it. Raymond, I think homebrew can deal with[masked]; just take a look at the output of "brew doctor" and see what kind of shape you're in. Mavericks (10.9) is what i just set up, and Mountain Lion (10.8) is what I use on my regular development machine. As for Ubuntu, you can try using its package manager to install the tools mentioned (Python 2.7.5 and numpy, PostGIS and its dependencies). Marina, I'll eventually put up a prezi about all the things we cover in these two sessions, so if things move too fast, there'll be the opportunity to go back and review the steps.

      1 · November 11, 2013

  • Eric T.

    First step: install Python. In a terminal window type

    brew install python

    You'll get a lot of input about dependencies and what homebrew is doing, but you shouldn't have to act on any of it.

    Next step: install numpy. In the terminal window, type

    pip-2.7 install numpy

    It will have a lot to say, but it should end with

    Successfully installed numpy
    Cleaning up...

    Final step for today: install PostGIS and its many dependencies. In the terminal window, type

    brew install postgis

    You shouldn't need to intervene in any of that, but be forewarned that from the time I started downloading Xcode to the time the PostGIS installation finished, it was about 2-1/2 hours. I am using a mid-2009 MacBook Pro and a fresh install of Mavericks. (You certainly don't need to install Mavericks. My MacBook Pro had so many years of accumulated cruft on it that a fresh install was indicated.)

    Good luck!

    November 11, 2013

  • Eric T.

    Hey folks, well I finally got my "fresh install" together today. I like visiting the Los Angeles County Museum of Art, but never thought their campus would have the most reliable WiFi in town. Spent many hours there out on the plaza not looking at art.

    Some notes. When I downloaded, then opened Xcode, "Command Line Tools" were not listed in the Preferences as a component. But when I installed homebrew, one of the first things it did was pop up a dialogue box telling me it was going to install them. So that worked out. After I ran the homebrew install, I ran "brew doctor", and the good doctor said: "Your system is ready to brew." Excellent.

    November 11, 2013

  • Alan M.

    Hey Eric, I know we have a few regular #maptime attendees who are running Windows. Any advice for them?

    November 10, 2013

  • Eric T.

    Hi Jason. Easiest thing would be to make sure that homebrew works with that setup. (If you've already installed it, run "brew update; brew doctor".) homebrew made me upgrade my Xcode from 5.0.0 to 5.0.1. My guess is that it will ask you to do the same.

    1 · November 10, 2013

    • Jason F.

      Thanks, Eric. I'm upgrading now.Even though brew doctor only gives me a warning that Xcode (4.6.2) is outdated, I apparently need Xcode 5.01 with OS X 10.8.x https://github.com/mxc...­

      November 10, 2013

  • Jason F.

    Eric, do we need a specific version of xCode? I have 4.6.2 with command line tools installed already.

    November 9, 2013

Our Sponsors

  • Stamen Design

    Covers meetup dues, provides meeting space and snacks.

People in this
Meetup are also in:

Create a Meetup Group and meet new people

Get started Learn more
Allison

Meetup has allowed me to meet people I wouldn't have met naturally - they're totally different than me.

Allison, started Women's Adventure Travel

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy