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:
{"type":"Point","coordinates":[-76.5617440647409,39.3951950048467]}
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).