A Pythonista's BFF:
__geo_interface__ in your toolbox, as long as you can read spatial data, you can write GeoJSON
import shapefile def features(data): sf = shapefile.Reader(data) fields = sf.fields[1:] field_names = [field for field in fields] for r in sf.shapeRecords(): attr = dict(zip(field_names, r.record)) geom = r.shape.__geo_interface__ yield dict(geometry=geom, properties=attr)
See also: Shapely, fiona, mapnik... even arcpy*>>> my_features = features(my_awesome_shapefile.shp) >>> my_features.next() # start with a shapefile, end with a geoJSON representation of each feature
$ cat my_awesome_document.txt | wc -l # returns number of lines in my_awesome_document.txt
(Feel free to just smile & nod here)
$ fio cat my_awesome_shapefile.shp | wc -l # returns number of spatial features in my_awesome_shapefile.shp
joins two shapefiles together and creates a new shapefile
$ fio cat my_red_shapefile.shp my_blue_shapefile.shp \ | fio load my_purple_shapefile.shp
Pipe arbitrary input through Python scripts & save the output as new spatial data
$ fio cat boring_shapefile.shp | magical_geoprocessing_script.py \ | fio load shiny_new_shapefile.shp
Python library fiona's built-in CLI "fio"
catworks like unix-y
cat, with added spatial goodness
(For the raster nerds, check out Rasterio, which has a CLI "rio")
Stick spatial data in a repo for the same reason you do it to your code.
Git for shapefiles & databases.
Keep on eye on them. Start playing around now.
$ geogig init $ geogig import my_awesome_shapefile.shp $ geogig add $ geogig commit -m "initial commit" $ geogig status On branch master # blah blah etc... # basically the git we all know & love... PLUS SPATIAL.