0

I am looking to convert a raster into a csv file (or tab delimited) based on values in the raster (Value > 0).

The csv would have three values, latitude of center of cell, longitude of center of cell, and the raster value where the raster value is greater than 0.

The data in unprojected in geographic coordinate system WGS 1984. It is a GTiff.

I know I can go to point file and then add the latitude and longitude and then go to CSV but I wonder if a direct method exists as I have 130 million points.

Working on going Ras > Point (file Geodatabase) > Query Points > CSV in ArcGIS but it is slow.

I feel I need to build in the query at the Ras > Point section to speed things up as the entire raster has 130 billion cells but only 130 million have values. Rest are 0 or NoData.

Looking for ArcGIS solution.

2
  • 1
    I'd use raster calculator to get rid off zeros and take normal raster to point approach. Raster clean up is much faster than query points, something like Con("input"!=0,"input") will do
    – FelixIP
    Commented Jul 7, 2016 at 4:00
  • how about getting into @FelixIP s idea a bit more? maybe also split your raster to point tasks into smaller chunks of the huge raster. Use as little GIS processing as possible - editors like "UltraEdit" or the like are super powerful and fast when putting together large datasets...
    – dru87
    Commented Jul 7, 2016 at 8:11

1 Answer 1

3

You can use the Sample tool to generate a table of X,Y,Z values:

Creates a table that shows the values of cells from a raster, or set of rasters, for defined locations. The locations are defined by raster cells or by a set of points.

Use the same raster as both the input and location dataset.

The tool will output a DBF or a GDB Table which you can then export to CSV.


Alternatively, see this answer for a non ArcGIS method that uses GDAL and doesn't include NoData values in the output.

6
  • can you expand. I have used this in the past but think I need to make points to sample from so hence still have to go through the point part (what I want to avoid). Can I use the raster for both the raster and the sample (in place of the points). Commented Jul 7, 2016 at 2:11
  • thanks. I was thinking that may be it. never done it that way before (always used points). Thanks. Commented Jul 7, 2016 at 2:32
  • ~600,000 lines an hour. So ~205 hours for ~130 million lines.....Need other options. Thanks. Limiting factor is processor max out not RAM. Can split and run across 8 processors I suppose for about 1-2 days but will likely have write issues then. Commented Jul 7, 2016 at 3:12
  • yes it totally passed me by the GDAL can export like this. Ill try gdal_translate -of XYZ E:/temp/mwf2012.tif E:/temp/mfw2012_ascii.xyz Commented Jul 7, 2016 at 3:25
  • gdal_translate writes out the nodata lines so this is not an option as it will try to write 130 billion lines Commented Jul 7, 2016 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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