I am working on a new project where I need to highlight census tracts by boundaries. Google Maps can do this as long as I give it GeoJSON (data layers).

I did some research and it seemed like Tiger is a good solution. I was able to install and setup PostGIs and a Tiger Geocoder database (125 gigabytes!) https://postgis.net/docs/Extras.html

After going through this incredibly long process, I could finally geocode an address using the built-in function geocode. I could even return back GeoJSON from an address:

SELECT ST_AsGeoJSON(geomout) 
FROM geocode('8615 Chestnut Oak Rd, Baltimore, MD 21234', 1)

and it spits out GeoJSON:


Finally, using the get_tract function, I can get back a census tract like this:

SELECT get_tract(geomout, 'tract_id') As tract_id 
FROM geocode('8615 Chestnut Oak Rd, Baltimore, MD 21234', 1) 
As g;` 

Which returns a tract.

The Question:

Now that I've shown what I've been able to do, what I can't do is get the GeoJSON for this tract. Would anyone be able to nudge me in the right direction?

I am wondering if maybe there is a function to return back a geometry object from a census tract (which I can then pass into the ST_AsGeoJSON function, or some other solution).

3 Answers 3


You could use GeoServer to handle the conversion of PostGIS results to GeoJSON for you. A simple WFS request like this would return the geometry (and optionally the attributes associated with it).

http://astun-desktop:8080/geoserver/wfs?request=GetFeature&typeName=topp:states&propertyName=STATE_NAME,LAND_KM,the_geom&CQL_FILTER=contains(the_geom, POINT(-76.5617440647409 39.3951950048467)&version=1.0.0&outputformat=json
  • This is interesting, thanks. Let me take a look i'll let you know if I have any issues. Commented Jul 11, 2017 at 13:24

So it appears there is a 'tract' table that has a column called the_geom. You can simply pass this value into ST_AsGeoJSON() and it will work, giving you the polygon represented as GeoJSON. That's all there was to it. Not sure how I missed this!


I've translated most of Census' Cartography files to GeoJSON and made them available here:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.