Geo-spatial and Statistical Packages
A comparison of some key R and Python packages.
| Purpose | Package | Key Functions |
|---|---|---|
| Vector data handling (points, lines, polygons) | geopandas (Python) sf (R) |
read_file(), sjoin(), to_crs(), dissolve() st_read(), st_join(), st_transform(), st_union(), st_as_sf() |
| Raster data handling (reading/writing gridded data) | rasterio (Python) terra (R) |
open(), read(), mask(), warp.reproject() rast(), vect(), crop(), mask(), extract() |
| Multi-dimensional arrays (NetCDF, climate data) | xarray (Python) terra (R) |
open_dataset(), sel(), mean() rast(), app(), subset() |
| Geospatial xarray operations | rioxarray (Python) | open_rasterio(), rio.reproject(), rio.clip() |
| Vector-raster operations | xvec (Python) rasterstats (Python) terra (R) |
zonal_stats(), extract_points() zonal_stats() extract() |
| Fast raster extraction to polygons (area-weighted) | exactextract (Python) exactextractr (R) |
exact_extract() exact_extract() |
| Static visualization and plotting | matplotlib (Python) ggplot2 (R) |
pyplot.plot(), pyplot.imshow() ggplot(), geom_sf(), geom_raster() |
| Interactive web maps | folium (Python) tmap (R) leaflet (R) |
Map(), Choropleth() tm_shape(), tm_polygons(), tm_layout() leaflet(), addTiles(), addPolygons() |
| Statistical modeling and econometrics | statsmodels (Python) linearmodels (Python) fixest (R) pyfixest (Python) |
OLS(), summary() PanelOLS() feols(), etable() feols(), etable() |
| Google Earth Engine access | ee (Python)* rgeedim (R)* rgee (R)* |
ee.Initialize(), ee.ImageCollection(), ee.Image.reduceRegion() Download GEE as GeoTIFFs R wrapper for GEE |
| Animated visualizations | matplotlib.animation (Python)* plotly (Python)* gganimate (R)* |
FuncAnimation(), save() px.scatter(), animation_frame= Create GIFs from ggplot2 |
| 3D visualizations | pyvista (Python)* plotly (Python)* rayshader (R)* |
plot(), add_mesh() Surface(), Scatter3d() 3D maps and renderings |
| Geographic utilities | country_converter (Python)* countrycode (R)* |
convert(), continent() Convert country names/codes |
| Parallel processing | dask (Python)* doparallel (R)* |
compute(), delayed(), array() Parallel processing for R |
Note
Some of these Packages marked will not be used in this workshop but are useful for advanced workflows.
Important
Important packages for raster data in R.
terra: the best way of loading and processing raster data.sf: the go-to package for dealing with polygons, lines and spatial points.exactextractor: the quickest, easiest and most accurate way to calculate zonal statistics. It’s an R wrapper for theexactextractpackage (written in C++). It’s more accurate than ArcGIS, QGIS, and Python’s rasterstats package in calculating zonal stats.tmap: quick and easy, and its “view” mode allows you to create interactive maps that are built on leaflet.ggplot: the best package for building beautiful maps. Allows for more customisation thantmap.
There are also the following packages which we will not be using in this workshop:
rgeedim: provides the easiest way to download data directly from Google Earth Engine as GeoTiffs.rgee: an R wrapper for Google Earth Engine, so you can run GEE commands in Rgganimate: a package that allows you to turn your ggplot2 graphs into gifs.rayshader: create animated 3D graphs and maps in R.countrycode: a useful package to automatically generate ISO codes from country names (and vice versa), assign continents to countries.doparallel: my go-to package for parallel processing.