I’m working on a neighborhood-related map feature for something at work. Zillow blog released its neighborhood shape file data to the public to be able to map the boundaries on various things, most notably Google Maps.
While doing some research into the situation, this undertaking is going to be pretty complicated. A brief Google search gave me several key blogs and tools that I think will help me in this project.
Trying to use shp2text. Downloaded ZIP file. Damn thing won’t compile on Mac.
make: *** No rule to make target `shapefil.h’, needed by `shpopen.o’. Stop.
Downloaded shapefile C lib. Compiled shapefile and copied
chapefil.h to my shp2text dir. Damn shp2text still won’t compile. Damn Mac.
cc -g -c dbfopen.c
dbfopen.c:210:24: error: safe-ctype.h: No such file or directory
make: *** [dbfopen.o] Error 1
Got shp2text to compile. Found a thread that had exact same problem as me. Comment out
include safe-ctype.h from the
dbfopen.c file. That file is in the shp2text dir.
Now I can use shp2text to convert my
.shp file into 3 formats: tab-separated value spreadsheet, GPX (XML), or geo.location (XML). I’m not sure what these are but we’ll find out soon enough.
shp2text —gpx ZillowNeighborhoods-CA.shp
To convert into GPX it asks me to choose some fields. I presume the field selection availability is pulled from the
.shp file somehow.
shp2text —gpx shape_file.shp name_field# attribute_field#
;utility to dump esri shapefiles into various text formats
;you must supply two field numbers
Field 0: Type=String, Title=`STATE’, Width=2, Decimals=0
Field 1: Type=String, Title=`COUNTY’, Width=43, Decimals=0
Field 2: Type=String, Title=`CITY’, Width=64, Decimals=0
Field 3: Type=String, Title=`NAME’, Width=64, Decimals=0
Field 4: Type=Double, Title=`REGIONID’, Width=32, Decimals=10
Since I want neighborhood name and city, I picked 2 and 3.
shp2text —gpx ZillowNeighborhoods-CA.shp 2 3
But it pushes everything to standard output. So I need to send it to a file…
shp2text —gpx ZillowNeighborhoods-CA.shp 2 3 > cali.xml
Now I have a GPX file
cali.xml of all the neighborhoods in California. I think I can use this static file in Google maps but I’m not sure if it will give me a filled polygon or not.
geo.location option looks promising because it specifies a geo.polyline but it does not give me metadata for the city or neighborhood name. The format is useless to me. Damn!