• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
  • License
    BSD 3-Clause "New...
  • Created about 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fiona-Rasterio-Shapely Cheat Sheet

Fiona-Rasterio-Shapely Cheat Sheet

A cheat sheet for Fiona/Rasterio/Shapely command-line geodata tools, with apologies to @dwtkns. Suggestions welcome!

See https://github.com/Toblerity/Fiona/blob/master/docs/cli.rst or fio --help and https://github.com/mapbox/rasterio/blob/master/docs/cli.rst or rio --help for more about Fiona and Rasterio commands.

Vector operations

Get Fiona version

New in 1.4.3

fio --version

Enumerate format drivers

New in 1.4.3

fio env --formats

Get vector information

fio info input.shp

Print vector format

fio info input.shp --format

Print vector extent

fio info input.shp --bounds

Print vector coordinate reference system

fio info input.shp --crs

Print count of features

fio info input.shp --count

Convert vectors to GeoJSON

With coordinate reference system transformation and rounding of numbers to a constant precision.

fio cat input.shp --dst_crs EPSG:4326 \
| fio collect --precision 6 > output.json

Convert between vector formats

fio cat input.shp | fio load --format Shapefile output.shp

Print count of features with attributes matching a given pattern

Using grep.

fio cat input.shp | grep -c "pattern"

Using jq.

fio cat input.shp | jq '.properties.my_prop=="pattern"' | grep -c "true"

Select features by long/lat bounding box

fio cat input.shp --bbox "$WEST,$SOUTH,$EAST,$NORTH"

Select features by bounds of another dataset

$ fio cat input.shp --bbox "`fio info other.shp --bounds | tr ' ' ','`"

Reproject vector

fio cat input.shp --dst_crs EPSG:4326 \
| fio load --sequence --format Shapefile --dst_crs EPSG:4326 output.shp

Merge features in a vector file by attribute ("dissolve")

TODO

Merge vector files

fio cat *.shp | fio load --format Shapefile merged.shp

Merge vector files (to GeoJSON)

fio cat *.shp | fio collect > merged.json

Filter a vector file

Using jq for filtering and geojsonio-cli for display of results.

fio cat input.shp \
| jq 'select(.id=="10")' -c \
| fio collect \
| geojsonio

Filter a vector file in parallel

Using GNU Parallel

fio cat input.shp \
| parallel --pipe "jq -c 'select(.id==\"10\")'" \
| fio collect \
| geojsonio

Subset & filter all shapefiles in a directory

TODO

Raster operations

Get Rasterio version

New in 0.15

rio --version

Enumerate format drivers

New in 0.15

rio env --formats

Get raster information

As JSON – no more scraping the output of gdalinfo!

rio info input.tif

Print raster format (not JSON)

rio info input.tif --format

Print raster extent

rio info input.tif --bounds

Print raster coordinate reference system

rio info input.tif --crs

Print count of raster bands

rio info input.tif --count

Get raster extent as GeoJSON

And pipe to geojsonio-cli:

rio bounds input.tif | geojsonio

Concatenate or stack datasets together

New in 0.15.

rio stack r.tif g.tif b.tif -o rgb.tif

Extract vectors from raster band as GeoJSON

rio shapes input.tif --bidx 1 > output.json

Extract data/nodata vectors from raster as GeoJSON

rio shapes input.tif --mask > output.json

Burn vector into raster

rio-rasterize is new in 0.18

$ rio rasterize output.tif --res 0.0167 < input.geojson

Sample values of a dataset

rio-sample is new in 0.18.

$ cat << EOF | rio sample input.tif
> [220649.99999832606, 2719199.999999095]
> EOF

Copy georeferencing, tags, and nodata attribute from one dataset to another

rio-edit-info is new in 0.24.

$ rio edit-info unreferenced.jpg --like referenced.tif --all

(Lots of other operations TODO)

Coordinate transforms

Transform long/lat to other CRS

$ rio transform "[-78.0, 23.0]" --dst_crs EPSG:32618 --precision 2

Transform many pairs of long/lat

$ cat << EOF | rio transform --dst_crs EPSG:32618 --precision 2
> [-78.0, 23.0]
> [-79.0, 24.0]
> EOF

More Repositories

1

geojson-events

Extending GeoJSON with event-like features
CSS
40
star
2

mainer

Uses GitHub API to help repos switch from "master" to "main"
Python
15
star
3

we-jam-econo

A Fiona, Rasterio, and Shapely Dockerfile
Shell
11
star
4

frs-wheel-builds

Fiona-Rasterio-Shapely wheel builds
Python
11
star
5

HoneyBadger

Python
11
star
6

worldmill

Done. Development moving over to ==> https://github.com/sgillies/Fiona
C
10
star
7

geometry-collections

A bestiary of frightful and ungodly GeoJSON geometries
Python
9
star
8

jsonseq

Python implementation of RFC 7464
Python
9
star
9

leaflet-geojson-ld

GeoJSON-LD plugin for Leaflet
JavaScript
8
star
10

foss4g-2014-fiona-rasterio

FOSS4G 2014 Presentation
JavaScript
7
star
11

ichpage

I can has Python and GIS environments?
6
star
12

vaytrou

Spatial search server
Python
6
star
13

rio-plugin-example

A Rasterio CLI command plugin example
Python
5
star
14

pleiades-frontpage

JavaScript
4
star
15

notarcpy

(I Can't Believe It's) Not ArcPy: fake objects to make testing possible.
Python
4
star
16

fiona-wheels

CMake
3
star
17

fio-taxa

Classification of GeoJSON features
Python
2
star
18

lawdi-2013-intro-geospatial-linked-data

JavaScript
2
star
19

pleiades3-buildout

Pleiades Buildout
Python
2
star
20

pleiades-api

JavaScript
2
star
21

babibl-web

Code and data behind the Barrington Atlas Bibliography with Pleiades links.
JavaScript
2
star
22

gispython.org

JavaScript
1
star
23

scipy-2014-rasterio

Presentation for SciPy
JavaScript
1
star
24

rutherford

Python
1
star
25

capgrids

Classical Atlas Project map grid data and utils
Python
1
star
26

kml2geojson

A Python 3.4 command-line program to convert KML files to GeoJSON
Python
1
star
27

translytervania

A Transliteration App
Python
1
star
28

python-gis-for-humans

JavaScript
1
star
29

lawdi-presentation

JavaScript
1
star
30

tpeutb

Browser for the Tabula Peutingeriana Codex Vindobonensis 324
JavaScript
1
star
31

pleiades-s5

Pleiades S5 presentation template
JavaScript
1
star
32

coorder

Python
1
star
33

capgrids-web

Python
1
star
34

pleiades.rdf

RDF from Pleiades
1
star
35

pleiades.portlet.pelagios

Python
1
star
36

talks

Reveal based presentations
JavaScript
1
star