Copying an existing postgis db to use in Tilemill

Furthering my exploration in cartography, I’ve been experimenting with Tilemill lately, particularly using data from openstreetmap [that's in a postgis db].

[The rest of this entry assumes you're at least familiar with Tilemill and its terminology].

I started learning to make my own Tilemill stylesheets [written in carto]. As of now, there’s only 3-4 other stylesheets for maps on a street level. (we’re talking like 0.25mile=72 pixels, roughly; enough to see several city blocks on your computer monitor]. (I also plan on comparing these in a future post in the coming days).

One of the most prominent ones is open-streets, a stylesheet made by developmentseed/Mapbox, the dev’s of Tilemill.

Although open-streets has been invaluable for me learning tilemill, I was questioning how they structured their stylesheet and wondered if there were any other approaches.

I then found high-roads by Michal Migurski, whose work and mapping I’m beginning to admire.

So, for the past couple days, on and off, I was figuring how to try out high-roads without making a whole new postgis database from scratch (preparing OSM data, etc, etc) and instead copying an existing one and using that copied db to experiment with using high-roads.

Caveat: You could use the same database in another Tilemill project, but I wasn’t sure if using views.sql from high-road would alter the database; and wanted to be safe than sorry.

So, after some trial and error, this what I did to do that:

Found this helpful page by Ramesh Natarajan concisely explaining how to export a single mysql db:
did the following to back up the postgis database whose copy I would use for high-roads:
(obviously, user-name is the one that is the owner of the postgis db):

pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}

pg_dump -U myusername thecleve -v -f theclevebackup.sql

Log into your postgres account:
sudo -u postgres -i

created the new database that you’ll be using for your new Tilemill project:
createdb thenameofyournewdb (in the following commands, it's named thecleve-hr)

Then run the couple commands to prepare your mysql for postgis:
createlang plpgsql thecleve-hr
psql -d thecleve-hr -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
psql -d thecleve-hr -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
echo "ALTER TABLE geometry_columns OWNER TO skorasaurus; ALTER TABLE spatial_ref_sys OWNER TO myusername;" | psql -d thecleve-hr

(I ran this last ‘echo..’ command to move the ownership back to my postgis user name.. I know that I didn’t create my postgis user name correctly, so I have add myself as the
owner again…)

Then, I was going to restore the database…
$ psql -U myusername -d thecleve-hr -f theclevebackup.sql
psql: FATAL: Ident authentication failed for user "myusername"
nope, that didn't work.

Next idea, log out of postgres, and do it as my normal user name…

So I did…
$ psql -U myusername -d thecleve-hr -f theclevebackup.sql
[received tons of errors after this].

So I figured, let’s see if the new db works anyways.
psql “dbname=thecleve-hr host=localhost user=myusername password=mypassword”
I can connect to the database by….
but when issuing \d:
no relations are made... that’s a bad sign !

but on a whim, I decided to remove my username and try:
$ psql -U -d thecleve-hr -f theclevebackup.sql

and now the data is there after issuing \d !

Then, I just went ahead and created my project in Tilemill =)

Cleveland Planning Commission – Jan. 6,2012

[intentionally left blank].

There was no City Planning Commission meeting on Jan. 6, 2012. City Planning Director Bob Brown told me that there was not anything submitted, so there wasn’t any need for a meeting although it’s normally held the 1st and 3rd Friday of every month.

There you have it. The next meeting is scheduled to be held, at the normal time, 3rd Friday of the month: January 20,2011.

Cleveland Planning commission Meeting Roundup – Dec. 16, 2011

The shortest Planning Commission meeting that I’ve been to [out of the dozen or so] Ended by 10:30am.

Attendance: Krumholz, Coyne [Chair], Pickney, Cleveland [9:20a], Bowens [9:50]

Very minor ; here’s a very quick recap, and I’ll flesh it out later today or tomorrow.

- CWRU’s Planning Director said that they’re considering renovating a portion of the Temple on E. 105th for a performing arts center…

- Pending demolition for 2 buildings on Broadway. One of the buildings, former Goodman’s Furniture, has some nice architectural elements on the outside. Its owner, the city of Cleveland, is going to find out how much it will cost to salvage those elements (and find someone to take them, because they claim not to have the storage space for them). One hasty quote [for removing them] that the city received was $10k; But they’re going to get firmer quotes, and this will come back [as far as I remember] to the Commish in at the next meeting.
My guess is that if it’s anything over $10k or if they don’t have anyone interested in the elements, they’ll demolish it. The overall time frame on this building is relatively fast, city hopes to have this demo’d in 6-8 weeks. [address is somewhere in my notes, these buildings are right next to Holy Family Church, near the intersection of Harvard and Broadway].

- The zoning changes along Hough Avenue on the agenda were tabled [at the last minute] at the request of whoever initiated the zoning changes. They will be brought again before the commish in January.

-

Cleveland Planning Commission Notes – Dec. 2, 2011

Quote of the meeting: that what it ends up being…being there at the right time.. – Special K, Norm Krumholz

Attendence: Krumholz, Pickney, Bowen (late), Cleveland (10:15) and Bob Brown (not-voting)

One of the more noteworthy things was who was missing, rather than who was actually there. There’s 7 Commissioners, each have full-time jobs but are paid for being on the Cleveland City Planning Commission. After attending about 10-12 of these over the past year, each of the commissioner’s attendance has not been perfect but Friday was inexcusable.

In order to take a vote on any amendment or approval, 4 need to be present. At 9:00 AM, the scheduled time for the meeting to begin: Only 2 were there [Krumholz and Pickney]. Ouch. After waiting for 15-20 minutes for Commissioner Bowen to arrive, the meeting started and postponed any votes until the lucky 4th person (Phyllis Cleveland, who arrived at 10:15).

And the Notable Happenings:

The East 22nd Project [PeeDee Link] – Re-doing the streetscape for E. 22nd (from Orange Ave to Euclid Ave), is tersely, good. It’s currently dead of any Pedestrian traffic or of anything else besides St. Vincent Hospital.
- Plants in the median, removing one lane of traffic on each side (it’s 3 lanes each way, south of Cedar), plus adding a bike lane.

At Orange Ave, this bike lane would actually connect with a bike trail connecting from Slavic Village towards downtown [I don't know any more details about this Slavic Village bike trail , I'll edit later if I find any].
-
Cost: $4 million, roughly; 615k will be from ODOT (since ODOT designated E. 22 as a detour for the innerbelt construction, ODOT is paying for a ‘Mill and Fill’ of E.22; regardless if this project is implemented).

- A few spruce-ups on Professor Ave in Tremont. This authorized the city to hire consultants, contractors for the Power lines to be buried, and a couple other things that I missed (or were maybe not even mentioned).
no idea when the actual work will be done.

- Ditto for Larchmere Blvd (From MLK Jr. to N. Moreland).

- Miceli’s is expanding their operations at their headquarters. Sounded like a very small expansion, but required them to take over E. 90th place and Evarts Ave.

http://www.theatlanticcities.com/commute/2011/12/transportation-planning-law-every-city-should-repeal/636/

The . The proposed changes would change from a B to a D, still acceptable, the archetects duly noted.

The Paris Art Theater Demolished

Another day, another building demolished in Cleveland.

This time it was the Paris Art Theatre, 3151 West 25th Street,
Cleveland, OH 44109.
I noticed it demo’d on Monday, Nov. 7th.
You can find more information on the property by entering the Parcel #: 008-10-010 in Cuyahoga County’s property database.

(Credits to otterphoto for some pictures here and Cinematreasures has some notes on it as well. Originally named the Southern Theatre, it turned to a porn theater in the late 60s or 70s, showing classics like Deep Throat .

I haven’t seen the building operable in the past 10 years. It’s a shame. Granted, I have no idea what should be done with the building.
$14,000 in property taxes owed. The owner of the building since 2000: the Clark Metro Development Corporation. I haven’t heard much about them since I moved back to Cleveland in 2009 and as I understand, is dissolved. Regardless, they should be responsible for the cost of demolishing the Paris Art Theatre. Was the building salvageable ? Why did Clark Metro sit on it for so long [since 2000] ? If they’re dissolved, why didn’t Tremont West or Detroit Shoreway, the 2 CDCs who have been active in the neighborhood recently take ownership ?

There’s more commentary on this at realneo

Also, just a few buildings down is the Aragon Ballroom, a boarded-up Concert Hall, also currently shuttered and I was preparing a blog post months ago on this building and remember reading that Live had a concert there in ’92 but I can’t find the link right now.

As often is the case, I’m left with more questions than answers about the demolition and there’s more to the story…

…All the pieces matter. – Freemon.

(note: All links are ‘safe for work’ and do not display any pornography).

Creating an extract of a city in Openstreetmap

I have been rendering maps of my local city [Cleveland, Ohio] recently. Because of Cleveland’s administrative borders, I had to extract the city of Cleveland using a large bounding box that included a lot of data outside of the city of Cleveland. As a result, I had to manually remove many ways and nodes (via josm) outside the city’s borders before I later used this data within the city’s boundaries for rendering in osmarender, and as a postgis db in tilemill and mapnik.

To automate this, I have been looking to create an extract of my city (and hopefully to be able to replicate this with other cities). This extract would only contain data within the city’s administrative boundaries.

I found a similar project to mine,
The Extractotron – which is a great project but its extracts are for cities including areas outside a city’s administrative borders.

I have unsuccessfully tried the following:

1] Created an extract that contains the administrative borders of my city in its entirety from a larger extract (in my case, my state) from geofabrik

bzcat ohio.osm.bz2 | osmosis\
–read-xml enableDateParsing=no file=-\
–bounding-box top=41.606 left=-81.88 bottom=41.3903 right=-81.5323 clipIncompleteEntities=true –write-xml file=-\
| bzip2 > extracted.osm.bz2

2.] Filtered the extract again in osmosis to only contain the administrative boundaries [and highway motorway link as a reference for me]

Specifically I did:
osmosis –read-xml extracted.osm –way-key-value keyValueList=”highway.motorway_link,boundary.administrative” –used-node –write-xml entireclevelandboundingbox.osm

4. Opened the file in josm, selected the multipolygon that consisted of the city’s administrative boundary, and then right-clicked on it, Selected Members, and copied it to a new layer

5. In the new layer, Removed the tags from the city’s boundaries and then combined all of them into one single way [in one direction] and saved it as a new osm file.

http://dl.dropbox.com/u/17003223/clevelandboundaryonly-dell.osm

6. Used osm2poly to create a polygon:
perl ./osm2poly.pl clevelandboundaryonly-dell.osm > clevelandboundaryonly-dell.poly

polygon can be found:

http://dl.dropbox.com/u/17003223/clevelandboundaryonly-dell.poly

7. Use the polygon as the boundary from the first large extract [from the state of ohio].

bzcat ohio.osm.bz2 | osmosis\
–read-xml enableDateParsing=no file=-\
–bounding-polygon file=clevelandboundaryonly-dell.poly clipIncompleteEntities=true –write-xml file=-\
| bzip2 > extracted.osm.bz2

http://dl.dropbox.com/u/17003223/extracted-dell.osm

This last osm file results in administrative boundaries are broken and incomplete.

An example of these broken boundaries can be can see in a screenshot of josm at http://i.imgur.com/Tw8Ba.png
In this screenshot, the underlying gray line is an inactive layer in josm and the same OSM file that I used to create the polygon in Step 5. The
administrative boundary, shown as orange dashed line in the screenshot, is from the extract in step 7 and should be over the gray line.

Any idea why the boundaries are broken in my new extract ?

Although we were unsuccessful, thank you to stereo in #osm for troubleshooting this with me yesterday.

Cleveland Neighborhood Map

The Cleveland Neighborhood Map was updated last week, check it out. I added Brooklyn Centre and Lake Erie is now included on the map.

the cleveland bike rack is open!

The Cleveland bike Rack, to take a shower and secure your bicycle finally opened a couple weeks ago (it was initially scheduled to be opened in the Spring).

I am slightly disappointed that the space only has parking for 50 bikes but if they need more space in the future, then the station was at least a success.

However, I am frustrated that the current economics of downtown Cleveland parking. Although downtown parking is relatively cheap (and my low budget likes that a lot), its low costs dissuades other sources of transportation (bike, RTA – the rapid or bus).
It’s $5 per day to park your bike indoors (the $25 monthly pass is a great deal and is a higher incentive to use).

Although The bike rack offers showers and changing areas, that prices isn’t very competitive as there are lots right now in downtown Cleveland (including one covered parking garage across the street on Huron, just east of east6th – http://www.openstreetmap.org/?lat=41.497893&lon=-81.688057&zoom=18&layers=M ) that charge as low as $3.50 (the early bird, before 9am) for a car.

I’m interested to learn more about the economics of parking lots here in downtown Cleveland.

Yes, Osmarender can render coastlines [sort of]!

There’s been a nagging error in the Cleveland Neighborhood Map: No Lake.

Lake Erie will be in the upcoming CNM update as I figured out how to configure my rendering software, or/p, (a perl implementation of osmarender) to include the coastline.

Here is how I did it:

The problem:

When downloading data from OSM, the geographic area is (not always, but for the sake of this post, most of time) shaped in a rectangle defined by the bounding a north, east, south, and west coordinates (known as a bounding box).

When it comes to coastlines in OSM, the entire area is not downloaded, just the data within the bounding box. This can be a problem if your data partially contains a coastline and the data does not specify which side is land and which is water !

Thus, here’s what you should do if you have a large coastline to render in osmarender.
(thanks to bobkare in the OSM IRC channel for the help).

  1. download the tiles@home client.
  2. Extract the t@h client, copy both ./close-areas.pl and the folder png2tileinfo to the folder that contains the .OSM file you wish to render.
  3. Run ./close-areas.pl on the .OSM file
    As follows: ./close-areas.pl minlat minlon maxlat maxlon < theosmfile.osm > output.osm

close-areas.pl will download the additional coastline that was not in the bounding box and specify the area(s) near the coastline which contain water.

After running close-areas.pl, my output .osm file, once rendered, still did not have water in it.
Why ?!
Through a couple trial and errors of running close-areas.pl, I also learned that the the bounding box order IS NOT the same as your minlat minlon maxlat maxlon . The bounding box order (used in the OSM API, [v.06]) is left,bottom,right,top sides of your bounding box;

but the parameters of the
minlat is the bottom (of your bounding box) (southern portion),
maxlat is the top/north;
minlon is the left/west;
maxlon is the right/east.

I had mistakenly entered the bounding box coordinates in the same order of the API, not the specific order used in close-areas.pl

The correct close-areas.pl was:./close-areas.pl 41.49503 -81.7291 41.51245 -81.69391 < input.osm &rt; output.osm

EDIT: I haven’t fixed it yet I was able to render the coastline using an area of bounding box that consisted of the mall portion of downtown Cleveland (the above coordinates), for the sake of simplicity during this debugging process. However, when I attempt to run the above using the bounding box of the entire city of Cleveland (the same used for the Cleveland Neighborhood Map), the water is displayed everywhere on the rendered image, instead of just Lake Erie.

Progress Indicator for the Cleveland Neighborhood Map

First off, a group Naplab, in Indy have made a great neighborhood map. Aaron Renn of the Urbanophile has an interview with the creators here. I hope to talk to them soon to kick around a few ideas with the Cleveland Neighborhood map and discuss our projects.

The Cleveland Neighborhood map has a background layer of roads, rivers, streams, and railways from Openstreetmap (OSM). However, this background layer of data from OSM was mostly based from the 2007 US Census Data. As I worked on the Cleveland neighborhood map, I noticed quite a few instances where the data (the roads no longer existed, were incorrectly named, or new roads have since been created, and didn’t mark any streets as one ways) was wrong.
Through the past few months, I have traveled around the city to verify the data in Openstreetmap and made many corrections. (This is also quite addictive too!)

July 18, 2011 edit: see the code map for more information

The green roads have been verified or corrected (as of June 16th)
red have not been verified. Also thanks to someonecallAlejandro (CWRU campus), badandy23 and anyone else in the OSM community who had contributed.

I plan on rolling out an updated version of the Cleveland Neighborhood Map in the next week or so, hopefully adding Glenville and Shaker Square.

(For me, back to rebuilding my sister’s garage!)

Follow

Get every new post delivered to your Inbox.