Compressing data to make grid codes