Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Reading both shapefiles and grid files

$
0
0
Hello everybody!

I have a grid file of 4x5 cells. This file contains values of water velocity.

I also have a polygon shapefile that contains the information of land use in the same region.

I am reading the velocity cell values one by one and according to these values and the type of land use, I want to solve a specific equation.

My problem is that I am reading the velocity values from the grid file and everything is ok, but how can I read simultaneously the respective types of landuse from the shapefile in the respective location of every grid cell?

I have managed to read a shapefile by the use of the following code:

Code:

import arcpy

LandUse="C:\\Python26\\ArcGIS10.0\\Python programming \\landuse shpfile\\landuse data_ypan.shp"

#rows = arcpy.SearchCursor(featureClass)

rows = arcpy.SearchCursor(LandUse)
row = rows.next()

while row:
     
    print row.Land_Group
    row = rows.next()

But obviously these commands read the whole shapefile. I only need to read the respective values in the specific cells.

I imagine that a solution is to convert the land use shapefile to a grid file but is there any other way?

I am a new Python user and unfortunately I can’t imagine yet what Python can do…

Thank you very much for your time!!!

Viewing all articles
Browse latest Browse all 2485

Trending Articles