-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rough draft implementation #1
Conversation
@geowurster i'm back in my home office after a work trip, have shipped Rasterio 0.26, and am 👀 on this at last. |
@geowurster I suggest we put I feel like >>> from geojseq.core import FeatureStream
>>> with open('/tmp/coutwldrnp.jseq', 'r') as f, FeatureStream(f) as src:
... for ftr in src:
... print((ftr['id'], ftr['properties']['NAME']))
...
('0', 'Mount Naomi Wilderness')
('1', 'Wellsville Mountain Wilderness')
('2', 'Mount Zirkel Wilderness')
('3', 'High Uintas Wilderness')
('4', 'Rawah Wilderness')
('5', 'Mount Olympus Wilderness')
('6', 'Comanche Peak Wilderness')
('7', 'Cache La Poudre Wilderness')
... Let's consider separate classes for the reading and writing duties. |
@sgillies While the I didn't use it for this project because our core file-like object will need to have GeoJSON specific properties etc., but I already have a Are there more compelling reasons that I'm missing for the Some examples of this change in the stdlib:
In contrast, libraries like import csv
with open('data.csv') as f:
for line in csv.DictReader(f):
# Do something
import msgpack
with open('data.msg') as f:
for msg in msgpack.Unpacker(f):
# Do something
with open('data.msg', 'w') as f:
packer = msgpack.Packer()
for item in something_else:
f.write(packer.pack(item)) Objects like |
Sold. I'm game to start with one class and add an |
@sgillies et al.
This PR and associated
draft
branch is intended to start a discussion but not necessarily be merged.For those not aware of the background, this was spurred by Toblerity/fio-buffer#4. Fiona has a
fio cat
CLI command that reads an OGR supported vector datasource and prints each feature on its own line. Being able to stream vector features and geometries around is very unixy and makes it easier to develop standalone tools that are good at doing one thing, but there is no standard method for reading and writing these streams.This PR aims to make reading GeoJSON feature sequences just like reading a text file with
open()
.So now doing something like supporting OGR datasources via something like Fiona AND feature streams would look something like: