georasters

GeoRasters is a Python module that provides a fast and flexible tool to work with GIS raster files.

https://github.com/ozak/georasters

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 8 committers (25.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (4.9%) to scientific vocabulary

Keywords

gis-raster-files python python-3 python-library python2 python3
Last synced: 4 months ago · JSON representation ·

Repository

GeoRasters is a Python module that provides a fast and flexible tool to work with GIS raster files.

Basic Info
  • Host: GitHub
  • Owner: ozak
  • License: gpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 11.1 MB
Statistics
  • Stars: 200
  • Watchers: 12
  • Forks: 36
  • Open Issues: 19
  • Releases: 5
Topics
gis-raster-files python python-3 python-library python2 python3
Created about 11 years ago · Last pushed about 1 year ago
Metadata Files
Readme License Citation

README.md

PyPiVersion Anaconda-Server Badge Pyversions ReadTheDocs CoverageStatus Binder Binder DOI

GeoRasters

The GeoRasters package is a python module that provides a fast and flexible tool to work with GIS raster files. It provides the GeoRaster class, which makes working with rasters quite transparent and easy. In a way it tries to do for rasters what GeoPandas does for geometries.

It includes tools to

  • Merge rasters
  • Plot rasters
  • Extract information from rasters
  • Given a point (lat,lon) find its location in a raster
  • Aggregate rasters to lower resolutions
  • Align two rasters of different sizes to common area and size
  • Get all the geographical information of raster
  • Create GeoTiff files easily
  • Load GeoTiff files as masked numpy rasters
  • Clip raster using geometries
  • Get zonal statistics using geometries
  • Spatial analysis tools

Install

GeoRasters can be installed using pip or conda.

pip install git+git://github.com/ozak/georasters.git
pip install georasters
conda install -c conda-forge georasters
conda install -c ozak georasters

You can try it out easily using conda env and the provided scripts:

Requirements

You need to install the following software for georasters to work.

  • GDAL

Example Usage: GeoRasters

```python import georasters as gr import numpy as np

Load data

raster = './data/slope.tif' data = gr.from_file(raster)

Plot data

data.plot()

Get some stats

data.mean() data.sum() data.std()

Convert to Pandas DataFrame

df = data.to_pandas()

Save transformed data to GeoTiff

data2 = data**2 data2.to_tiff('./data2')

Algebra with rasters

data3 = np.sin(data.raster) / data2 data3.plot()

Notice that by using the data.raster object,

you can do any mathematical operation that handles

Numpy Masked Arrays

Find value at point (x,y) or at vectors (X,Y)

value = data.mappixel(x,y) Value = data.mappixel(X,Y) ```

Example Merge GeoRasters:

```python import os import georasters as gr import matplotlib.pyplot as plt

DATA = "/path/to/tiff/files"

Import raster

raster = os.path.join(DATA, 'pre1500.tif') data = gr.from_file(raster) (xmin, xsize, x, ymax, y, ysize) = data.geot

Split raster in two

data1 = gr.GeoRaster(data.raster[:data.shape[0] / 2, :], data.geot, nodatavalue=data.nodatavalue, projection=data.projection, datatype=data.datatype)

data2 = gr.GeoRaster(data.raster[data.shape[0] / 2:, :], (xmin, xsize, x, ymax + ysize * data.shape[0] / 2, y, ysize), nodatavalue=data.nodatavalue, projection=data.projection, datatype=data.datatype,)

Plot both parts and save them

plt.figure(figsize=(12, 8)) data1.plot() plt.savefig(os.path.join(DATA, 'data1.png'), bbox_inches='tight') ```

plot1

python plt.figure(figsize=(12,8)) data2.plot() plt.savefig(os.path.join(DATA,'data2.png'), bbox_inches='tight')

plot2

Generate merged raster

```python data3 = data1.union(data2)

Plot it and save the figure

plt.figure(figsize=(12,8)) data3.plot() plt.savefig(os.path.join(DATA,'data3.png'), bbox_inches='tight') ```

plot3

Another Merge:

Example Usage: Other functions

```python import georasters as gr import numpy as np

Get info on raster

NDV, xsize, ysize, GeoT, Projection, DataType = gr.getgeoinfo(raster)

Load raster

data = load_tiff(raster)

Find location of point (x,y) on raster, e.g. to extract info at that location

col, row = gr.map_pixel(x,y,GeoT[1],GeoT[-1], GeoT[0],GeoT[3]) value = data[row,col]

Agregate raster by summing over cells in order to increase pixel size by e.g. 10

gr.aggregate(data,NDV,(10,10))

Align two rasters

data2 = loadtiff(raster2) (alignedrastero, alignedrastera, GeoTa) = gr.align_rasters(raster, raster2, how=np.mean)

Create GeoRaster

A=gr.GeoRaster(data, GeoT, nodata_value=NDV)

Load another raster

NDV, xsize, ysize, GeoT, Projection, DataType = gr.getgeoinfo(raster2) data = loadtiff(raster2) B=gr.GeoRaster(data2, GeoT, nodatavalue=NDV)

Plot Raster

A.plot()

Merge both rasters and plot

C=B.merge(A) C.plot() ```

Issues

Find a bug? Report it via Github issues by providing

  • a link to download the smallest possible raster and vector dataset necessary to reproduce the error
  • python code or command to reproduce the error
  • information on your environment: versions of python, gdal and numpy and system memory

Copyright

© Ömer Özak (2014)

This code and data is provided under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License and GPLv3.

Owner

  • Name: Ömer Özak
  • Login: ozak
  • Kind: user
  • Location: United States
  • Company: Southern Methodist University

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: Özak
    given-names: Ömer
    orcid: https://orcid.org/0000-0001-6421-2801
title: "GeoRasters"
license: GPL-3.0-or-later
identifiers:
  - type: doi
    value: 10.5281/zenodo.4058462
version: 0.5.29
date-released: 2024-12-06

GitHub Events

Total
  • Create event: 2
  • Issues event: 1
  • Release event: 4
  • Watch event: 4
  • Push event: 4
Last Year
  • Create event: 2
  • Issues event: 1
  • Release event: 4
  • Watch event: 4
  • Push event: 4

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 234
  • Total Committers: 8
  • Avg Commits per committer: 29.25
  • Development Distribution Score (DDS): 0.038
Past Year
  • Commits: 4
  • Committers: 1
  • Avg Commits per committer: 4.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Ömer Özak o****k 225
Rick Debbout d****r@g****m 2
espg r****e@r****m 2
codeananda 5****a 1
Steven Zindel z****n@k****l 1
Mragank Shekhar 4****K 1
Emil Stenström em@k****e 1
Ben b****n@n****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 60
  • Total pull requests: 12
  • Average time to close issues: 5 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 35
  • Total pull request authors: 10
  • Average comments per issue: 4.03
  • Average comments per pull request: 2.83
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ozak (10)
  • immuhammadadil (7)
  • marthinwurer (5)
  • culebron (3)
  • apoorvalal (2)
  • lucabaldassarre (2)
  • DeoLeung (2)
  • kritiksoman (2)
  • sjsrey (1)
  • andrewyushkevich (1)
  • vinayk95 (1)
  • JavierParada (1)
  • debboutr (1)
  • impactanalysts (1)
  • davidanderson-1701 (1)
Pull Request Authors
  • espg (2)
  • codeananda (2)
  • debboutr (2)
  • beadyallen (1)
  • culebron (1)
  • MgeeeeK (1)
  • szindel (1)
  • megies (1)
  • marthinwurer (1)
  • EmilStenstrom (1)
Top Labels
Issue Labels
enhancement (15) help wanted (14) bug (2) Installation Linux (2) Installation (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 539 last-month
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 12
    (may contain duplicates)
  • Total versions: 70
  • Total maintainers: 1
pypi.org: georasters

Tools for working with Geographical Information System Rasters

  • Versions: 56
  • Dependent Packages: 1
  • Dependent Repositories: 11
  • Downloads: 539 Last month
  • Docker Downloads: 0
Rankings
Docker downloads count: 4.3%
Dependent repos count: 4.4%
Dependent packages count: 4.8%
Stargazers count: 4.9%
Average: 5.2%
Downloads: 6.2%
Forks count: 6.5%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: georasters

The GeoRasters package is a python module that provides a fast and flexible tool to work with GIS raster files. It provides the GeoRaster class, which makes working with rasters quite transparent and easy. In a way it tries to do for rasters what GeoPandas does for geometries. It includes tools to * Merge rasters * Plot rasters * Extract information from rasters * Given a point (lat,lon) find its location in a raster * Aggregate rasters to lower resolutions * Align two rasters of different sizes to common area and size * Get all the geographical information of raster * Create GeoTiff files easily * Load GeoTiff files as masked numpy rasters * Clip raster using geometries * Get zonal statistics using geometries * Spatial analysis tools

  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.2%
Stargazers count: 26.4%
Forks count: 28.7%
Average: 32.7%
Dependent packages count: 51.6%
Last synced: 4 months ago

Dependencies

requirements.txt pypi
  • Cython *
  • GDAL *
  • affine *
  • coverage *
  • docopt *
  • fiona *
  • geopandas *
  • matplotlib *
  • numpy *
  • pandas *
  • pysal *
  • rasterstats *
requirements_dev.txt pypi
  • coverage * development
  • pytest * development
setup.py pypi
  • GDAL *
  • affine *
  • coverage *
  • docopt *
  • fiona *
  • geopandas *
  • matplotlib *
  • numpy *
  • pandas *
  • pyproj *
  • pysal *
  • rasterstats *
  • scikit-image *
docs/environment.yml conda
  • cartopy
  • contextily
  • descartes
  • fiona
  • gdal
  • geopandas
  • geoplot
  • geopy
  • ipython
  • jinja2
  • matplotlib
  • mock
  • numpydoc
  • pandas
  • pillow
  • pyproj
  • pysal
  • python 3.5.*
  • rtree
  • shapely
  • six
  • sphinx
  • sphinx-gallery
  • sphinx_rtd_theme
environment.yml conda
  • affine
  • coverage
  • descartes
  • docopt
  • fiona
  • gdal
  • geopandas
  • geoplot
  • html5lib
  • matplotlib-base
  • numpy
  • pandas
  • pip
  • pyproj
  • pysal
  • python 3.8
  • rasterstats >=0.12
  • scikit-image
  • seaborn
  • statsmodels