1

I am looking for FOSS (maybe GDAL/OGR) solutions to a problem. I need to go from raster (200 million records) to CSV. It is easy enough to do via point but the point file breaks the allowable 2GB “any component part” shapefile rule so I would technically have to go to another point format such as file geodb but would like to avoid points altogether. I need to get another raster value into the CSV as well.

The CSV must carry over

  1. The original raster Value (16 –bit integer).
  2. An X Y value (technically just a y is needed) that is the center of the raster cell. This is in DD to double precision.
  3. A value from another raster. Double precision.

What I’ve done.

ArcGIS

  1. Raster (file GeoDB) to Point (file GeoDB).
  2. Add X Y coordiantes to the points.
  3. Extract Value to Points (from the other raster)
  4. Table (file geodb) to Table (csv).

FOSS

  1. Run ArcGIS to get the raster out of the GeoDB and to tiff. I cannot find a way to go file geodb raster to tiff without ArcGIS so as I need to use ArcGIS I just go file geodb raster to point into a file GeoDB point feature class.
  2. OGR 2 OGR (file geodb to csv) export to csv carrying across X any Y using geometry as WKT.
  3. Still need to get the “other raster value” into (1) or (2) remember I cannot go to shapefile.
  4. I would like to avoid point altogether.

So I plan to get the file geodatabase rasters into GeoTiff to find a FOSS solution. I would like to go straight from Raster to CSV carrying across the raster value in each cell, generating the x,y value for the raster cell (center), and then get another raster value into the CSV via the x,y CSV coordinate pair. This would avoid going to point and avoid using Arc.

2

The raster to ASCII file can be done using a simple gdal_translate -of XYZ input.tif output.asc

From there, you should compare the X and Y coordinates between your files, and replace as needed using any tool capable of doing that (Python, R, Excel etc.). Without specifying which tool you feel comfortable with, it'll be different going into more detail on this step.

1

In grass you can do:

for RASTER_NBR in $(seq 0 40) ; do
r.external -o input=myraster$RASTER_NBR.tif    output=myraster$RASTER_NBR    
r.out.xyz input=myraster$RASTER_NBR output=myraster$RASTER_NBR.csv separator=","
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.