Skip to content

Instantly share code, notes, and snippets.

@mattwigway
Created September 9, 2015 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattwigway/18799e8d56e20f81a4ba to your computer and use it in GitHub Desktop.
Save mattwigway/18799e8d56e20f81a4ba to your computer and use it in GitHub Desktop.
Replace bottom-coded values with null
#!/usr/bin/python
# Remove all the -99999... values in the NL neighborhoods file and replace them with NULL
from sys import argv
import fiona
with fiona.open(argv[1]) as infile:
meta = infile.meta
meta['schema']['geometry'] = 'MultiPolygon'
fidx = 0
with fiona.open(argv[2], 'w', **meta) as outfile:
for f in infile:
fidx += 1
if fidx % 1000 == 0:
print '{0} features processed'.format(fidx)
for prop, val in f['properties'].iteritems():
if val < -10000:
f['properties'][prop] = None
outfile.write(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment