[GIS] Converting Esri ASCII raster to Shapefile for CartoDB

arcgis-desktopcartoesri-ascii-rastershapefilevectorization

I have an ArcGIS grid ascii file (Ramankutty Cropland at 5 minute resolution) that begins as follows:

ncols         4320 
nrows         2160 
xllcorner     -180 
yllcorner       -90 
cellsize      0.08332825 
NODATA_value  -9999
-9999 -9999 -9999 -9999 -9999 -9999 -9999  
...

Someone gave me this file but did not provide a projection and could not recall what it was. However, I have some reason to believe the projection is WGS1984:

GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

I would like to be able to convert this to a format that CartoDB could use–an ESRI shapefile. Another person who did manage this, but who also could not recall the procedure, created a polygonal coverage of grid squares (closed oriented loops). The values at the row and column numbers were assigned to the polygonal squares (somehow–I do not know the data structures involved).

Is there a way to create some kind of polygonal grid square coverage without using ArcGIS (I'm guessing this was used, but no details were provided to me)? Open source tools would be nice, but if ArcGIS is necessary, so be it.

As an alternative, I tried
gdal_translate -of GTIFF -a_srs WGS1984.prj …
and uploaded the result to CartoDB, but CartoDB complained that the result was not georeferenced (the_geom lat/lon GeoJSON was empty).

(I'm not sure how to apologize for asking such vague and uninformed questions.)

Some more info: here's part of a row from the ESRI shapefile of this data that was imported into CartoDB

**id**  1
**the_geom** {"type":"MultiPolygon","coordinates":[[[[-8.7649,37.34027], [-8.87019,37.36377],[-8.79447,37.42393],[-8.7649,37.34027]]]]}
**shape_area** 63274611.152
**shape_leng** 36270.0549322

Another row:

**id**  2
**the_geom** {"type":"MultiPolygon","coordinates":[[[[-8.59219,37.34027],[-8.67854,37.34027],[-8.67854,37.40889],[-8.59219,37.40889],[-8.59219,37.34027]]]]}
**shape_area** 92417860.2
**shape_leng** 38453.683350300001621

Best Answer

In answer to my own question, I've written a program to "vectorize" an ArcInfo Grid ASCII files as an ESRI shapefile with a single layer containing oriented polygonal grid squares centered at the points of the grid, with an attribute value equal to the value at the coordinates of the centroid. The program (still under development) is available on GitHub. An example of a map produced with the program is on CartoDB (it might not be for long). Perhaps one could have done this in GRASS. Space for detailed answers in this vein is provided below.

In case the map has to be taken down, here is a screen capture Ramankutty cropland

Related Question