GithubHelp home page GithubHelp logo

gridlulcpixelcounter's Introduction

GridLULCPixelCounter

Overview

GridLULCPixelCounter is a Python script designed for environmental scientists, geographers, and GIS professionals to analyze land use and land cover (LULC) data. It counts the number of pixels for each LULC class within predefined grid cells and calculates the centroid for each cell. The output is a comprehensive CSV file that includes the centroid coordinates along with the pixel counts for each LULC class within each grid cell. This tool is invaluable for spatial analysis, environmental monitoring, and urban planning.

In addition to pixel counting, this toolset includes a grid creation script, create_grid, which generates a grid layer over any raster dataset, regardless of its coordinate reference system (CRS). A user-friendly Tkinter interface is provided for easy grid creation.

Features

  • Pixel Counting: Accurately counts pixels of specified LULC classes within each grid cell of a given vector layer.
  • Centroid Calculation: Determines the geographic center (centroid) for each grid cell.
  • CSV Export: Outputs a CSV file containing the grid cell ID, centroid coordinates (latitude and longitude), and the count of pixels for each LULC class within the cell.
  • Grid Creation: Generates a grid layer over any raster dataset, with customizable grid size.
  • Flexibility: Works with any raster and vector data, provided they share the same coordinate reference system (CRS).

Prerequisites

  • Python 3.x
  • GDAL
  • Rasterio
  • Geopandas
  • Numpy

Make sure all dependencies are installed using pip:

pip install gdal rasterio geopandas numpy

Usage

Pixel Counting

  • Prepare your raster (LULC data) and vector (grid) files. Ensure they are in the same CRS.
  • Run the GridLULCPixelCounter script with the necessary arguments: python GridLULCPixelCounter.py --raster path/to/lulc_raster.tif --vector path/to/grid.shp --output path/to/output.csv

Grid Creation

  • Run create_grid_tool.py script to open the Tkinter interface.
  • Select the input raster file, specify the grid size (in meters), and choose the output path for the grid layer.
  • Click the "Create Grid" button to generate the grid.

Example

An example dataset is provided in the example_data folder. To run the script with the example data, navigate to the script directory and execute: python GridLULCPixelCounter.py --raster example_data/lulc_raster.tif --vector example_data/grid.shp --output example_data/output.csv For grid creation, use the Tkinter interface provided by create_grid_tool.py

License

This project is licensed under the MIT License - see the LICENSE file for details.

gridlulcpixelcounter's People

Contributors

yuvraj198920 avatar

Watchers

 avatar

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.