Created
September 9, 2015 12:50
-
-
Save mattwigway/18799e8d56e20f81a4ba to your computer and use it in GitHub Desktop.
Replace bottom-coded values with null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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