An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080729/e6dafce2/attachment.pl>
R Raster to ArcGIS
4 messages · Matt.Farnsworth at aphis.usda.gov, Ashton Shortridge, Guy Serbin +1 more
Hi Matt (and list), ArcGIS still (as far as I know) doesn't work with rectangular cells. This isn't a problem with the AsciitoGrid function, but I think is more fundamentally a problem with Arc's raster data structure. The trick to getting around this may be to convert your matrix to a point object - with x, y, and z values - in R, where x and y correspond to the ground coordinates of each cell in the matrix. I think you would have to do this with your own code, but if you've programmed with arrays before it would not be difficult. Then interpolate these points to a square grid. The interpolation could be done in R (using gstat routines for example) or within a GIS (that is, write the xyz object to a text file, or perhaps straight to a shapefile, import it as a vector point set to a GIS, and then convert that to a raster. Hope this helps, Ashton
On Tuesday 29 July 2008, Matt.Farnsworth at aphis.usda.gov wrote:
Dear list, I'm trying to bring an ASCII raster file into ArcGIS that resulted from calling the R function Tsp(), which is in the "fields" library, followed by the use of the function predict.surface() to generate the matrix of predicted values. These functions use many of the same inputs as the Krig() function in R. My problem is that the output is a symmetrical matrix of dimension NxN, however, because R outputs an NxN matrix it necessarily results in having a rectangular grid cell (e.g., x dimension is 50 and y dimension is 30) for any input data set whose spatial extent is not square. My question is; does anybody know how to import a rectangular grid from an ASCII raster file into ArcGIS using something other than the AsciiToGrid function in ArcGIS, which only allows for square grids? Thanks in advance for any help, Matt ************************************************* Matt Farnsworth Disease Ecologist Spatial Epidemiology Unit Centers for Epidemiology and Animal Health
Ashton Shortridge Associate Professor ashton at msu.edu Dept of Geography http://www.msu.edu/~ashton 235 Geography Building ph (517) 432-3561 Michigan State University fx (517) 432-1671
Hi list, I'm going to borrow what I just learned from my other thread. I'd export your raster data as an ENVI file, which ArcGIS should be able to read with the ENVI Reader for ArcGIS installed. 1. Go to www.ittvis.com and download the appropriate version of the ENVI Reader for ArcGIS (1.1 for ArcGIS 8.3-9.1, 1.2 for ArcGIS 9.2). You won't need the ENVI reader for ArcGIS 9.3 as support for this format is in the upcoming version. 2. Get the caTools package for R and load it. 3. Export your data from R using write.ENVI 4. Read data into ArcGIS using usual means. You could also see if one of the other packages, e.g., RPyGeo, allows you to directly interface between R and ArcGIS for your purposes. Best of luck, Guy Serbin
On Tue, Jul 29, 2008 at 2:54 PM, Ashton Shortridge <ashton at msu.edu> wrote:
Hi Matt (and list), ArcGIS still (as far as I know) doesn't work with rectangular cells. This isn't a problem with the AsciitoGrid function, but I think is more fundamentally a problem with Arc's raster data structure. The trick to getting around this may be to convert your matrix to a point object - with x, y, and z values - in R, where x and y correspond to the ground coordinates of each cell in the matrix. I think you would have to do this with your own code, but if you've programmed with arrays before it would not be difficult. Then interpolate these points to a square grid. The interpolation could be done in R (using gstat routines for example) or within a GIS (that is, write the xyz object to a text file, or perhaps straight to a shapefile, import it as a vector point set to a GIS, and then convert that to a raster. Hope this helps, Ashton On Tuesday 29 July 2008, Matt.Farnsworth at aphis.usda.gov wrote:
Dear list, I'm trying to bring an ASCII raster file into ArcGIS that resulted from calling the R function Tsp(), which is in the "fields" library, followed by the use of the function predict.surface() to generate the matrix of predicted values. These functions use many of the same inputs as the Krig() function in R. My problem is that the output is a symmetrical matrix of dimension NxN, however, because R outputs an NxN matrix it necessarily results in having a rectangular grid cell (e.g., x dimension is 50 and y dimension is 30) for any input data set whose spatial extent is not square. My question is; does anybody know how to import a rectangular grid from an ASCII raster file into ArcGIS using something other than the AsciiToGrid function in ArcGIS, which only allows for square grids? Thanks in advance for any help, Matt ************************************************* Matt Farnsworth Disease Ecologist Spatial Epidemiology Unit Centers for Epidemiology and Animal Health
-- Ashton Shortridge Associate Professor ashton at msu.edu Dept of Geography http://www.msu.edu/~ashton 235 Geography Building ph (517) 432-3561 Michigan State University fx (517) 432-1671
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Guy Serbin, Ph.D. Research Soil Scientist Hydrology and Remote Sensing Lab Bldg 007 Rm 104 BARC-West 10300 Baltimore Blvd Beltsville, MD 20705-2350 USA +1(301)504-5250 guy.serbin at gmail.com
On Tue, 29 Jul 2008, Guy Serbin wrote:
Hi list, I'm going to borrow what I just learned from my other thread. I'd export your raster data as an ENVI file, which ArcGIS should be able to read with the ENVI Reader for ArcGIS installed. 1. Go to www.ittvis.com and download the appropriate version of the ENVI Reader for ArcGIS (1.1 for ArcGIS 8.3-9.1, 1.2 for ArcGIS 9.2). You won't need the ENVI reader for ArcGIS 9.3 as support for this format is in the upcoming version. 2. Get the caTools package for R and load it. 3. Export your data from R using write.ENVI 4. Read data into ArcGIS using usual means.
Seems like a long way round when readGDAL/writeGDAL in the rgdal package have plenty of drivers, such as GeoTiff. Depending on which application needs to be "in front", using rgdal and system() from R is very flexible. I've found GDAL-generated GeoTiff files very easy to read into ENVI, harder to read into ArcGIS (may need statistics setting to get the symbology reasonable). Roger
You could also see if one of the other packages, e.g., RPyGeo, allows you to directly interface between R and ArcGIS for your purposes. Best of luck, Guy Serbin On Tue, Jul 29, 2008 at 2:54 PM, Ashton Shortridge <ashton at msu.edu> wrote:
Hi Matt (and list), ArcGIS still (as far as I know) doesn't work with rectangular cells. This isn't a problem with the AsciitoGrid function, but I think is more fundamentally a problem with Arc's raster data structure. The trick to getting around this may be to convert your matrix to a point object - with x, y, and z values - in R, where x and y correspond to the ground coordinates of each cell in the matrix. I think you would have to do this with your own code, but if you've programmed with arrays before it would not be difficult. Then interpolate these points to a square grid. The interpolation could be done in R (using gstat routines for example) or within a GIS (that is, write the xyz object to a text file, or perhaps straight to a shapefile, import it as a vector point set to a GIS, and then convert that to a raster. Hope this helps, Ashton On Tuesday 29 July 2008, Matt.Farnsworth at aphis.usda.gov wrote:
Dear list, I'm trying to bring an ASCII raster file into ArcGIS that resulted from calling the R function Tsp(), which is in the "fields" library, followed by the use of the function predict.surface() to generate the matrix of predicted values. These functions use many of the same inputs as the Krig() function in R. My problem is that the output is a symmetrical matrix of dimension NxN, however, because R outputs an NxN matrix it necessarily results in having a rectangular grid cell (e.g., x dimension is 50 and y dimension is 30) for any input data set whose spatial extent is not square. My question is; does anybody know how to import a rectangular grid from an ASCII raster file into ArcGIS using something other than the AsciiToGrid function in ArcGIS, which only allows for square grids? Thanks in advance for any help, Matt ************************************************* Matt Farnsworth Disease Ecologist Spatial Epidemiology Unit Centers for Epidemiology and Animal Health
-- Ashton Shortridge Associate Professor ashton at msu.edu Dept of Geography http://www.msu.edu/~ashton 235 Geography Building ph (517) 432-3561 Michigan State University fx (517) 432-1671
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no