georasters
GeoRasters is a Python module that provides a fast and flexible tool to work with GIS raster files.
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
Repository
GeoRasters is a Python module that provides a fast and flexible tool to work with GIS raster files.
Basic Info
Statistics
- Stars: 200
- Watchers: 12
- Forks: 36
- Open Issues: 19
- Releases: 5
Topics
Metadata Files
README.md
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:
- try_georasters2.yml creates a GIS functional
python-2.7environment - try_georasters3.yml creates a GIS functional
python-3.5environment.
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') ```

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

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') ```

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
- Website: omerozak.com
- Twitter: OmerOzakEcon
- Repositories: 45
- Profile: https://github.com/ozak
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
Top Committers
| Name | 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
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
- Homepage: http://github.com/ozak/georasters
- Documentation: https://georasters.readthedocs.io/
- License: GPLv3
-
Latest release: 0.5.29
published almost 2 years ago
Rankings
Maintainers (1)
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
- Homepage: http://github.com/ozak/georasters
- License: GPL-2.0-or-later
-
Latest release: 0.5.23
published almost 5 years ago
Rankings
Dependencies
- Cython *
- GDAL *
- affine *
- coverage *
- docopt *
- fiona *
- geopandas *
- matplotlib *
- numpy *
- pandas *
- pysal *
- rasterstats *
- coverage * development
- pytest * development
- GDAL *
- affine *
- coverage *
- docopt *
- fiona *
- geopandas *
- matplotlib *
- numpy *
- pandas *
- pyproj *
- pysal *
- rasterstats *
- scikit-image *
- 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
- 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