There wasn't a good way to programatically upload geojson files to Socrata. This is a work-around. Uses the standard sodapy replace and upsert methods.
####This script also contains support to receive email reports to let you know if the upload succeeded or failed and log exceptions that the script encounters at runtime.
-
Take the first line of your geojson file like this:
head -n3 geoJsonFile.json > geoJsonFileHeader.json
and then add ]} to your file stuff to make your json valid. -
Manually create a new geo dataset in socrata. When it asks for a file, upload your geoJsonFileHeader.json file. No need to upload the entire file; all you need is one record so that you can create the attribute schema for the geodata set.
-
Once the geodata dataset is created, grab the 4x4 for the layer (important to note- the dataset 4x4 and the layer 4x4 are two separate things. You want the layer 4x4 as you will be upserting to this). Stick the layer 4x4 for the dataset into the script's configuration file, fieldconfig.yaml
-
Fill out the rest of config files ( fieldconfig.yaml, socrata_config.yaml, email_config.yaml) with your own params. Ie your socrata username/pass, your email server, directory configs, etc.
-
Feel free to email questions to: janine.heiser@sfgov.org