Coder Social home page Coder Social logo

raster2points's Introduction

raster2points

Codacy Badge

Convert one or multiple raster images to points. Tool will read first input raster and extract lat/lon coordinates and values for all pixels which have data. Optional it calculates geodesic area for each point based on pixel size. Successive input rasters will use data mask from first input raster.

Returns a Pandas dataframe, CLI will export results as CSV file.

Input files can be local file paths or S3 paths, or a mix. For reading from S3, you'll need AWS credentials configured, such as with a profile in ~/.aws and an AWS_PROFILE variable in your environment.

Multi-worker only works with S3 inputs, not local files.

Installation and Dependencies

This module uses rasterio and requires GDAL>=1.11. Use pip to install.

pip install raster2points

CLI Usage

raster2csv.py   [-h]
                [--col_names COL_NAMES [COL_NAMES ...]]
                [--separator {,,;,t}]
                [--max_block_size MAX_BLOCK_SIZE]
                [--calc_area [CALC_AREA]]
                [--workers WORKERS]
                INPUT [INPUT ...]
                OUTPUT

Python Usage

You can also use the module directly in python. It will return a Pandas dataframe with your data.

Get Pandas data frame

from raster2points import raster2df

raster1 = "path/to/file1.tif"
raster2 = "path/to/file2.tif"

df = raster2df(raster1, raster2, col_names=["name1", "name2"], calc_area=True)

print(df.columns)
print(df.dtypes)

df.head()

Export to TSV

from raster2points import raster2csv

raster1 = "path/to/file1.tif"
raster2 = "path/to/file2.tif"
output = "path/to/newfile.tsv"

raster2csv(raster1, raster2, output, col_names=["name1", "name2"], separator="\t", calc_area=True)

raster2points's People

Contributors

klaash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raster2points's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.