Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDALWarp/RasterIO write to file #8

Open
mdsumner opened this issue Sep 26, 2020 · 0 comments
Open

GDALWarp/RasterIO write to file #8

mdsumner opened this issue Sep 26, 2020 · 0 comments

Comments

@mdsumner
Copy link
Member

mdsumner commented Sep 26, 2020

All that's needed is

inline List gdal_warp_in_memory(CharacterVector source_filename,
                     CharacterVector source_WKT,
                     CharacterVector target_WKT,
                     NumericVector target_geotransform,
                     IntegerVector target_dim,
                     IntegerVector band,
                     CharacterVector output_filename = "",
                     CharacterVector driver_shortname = "") {


// ...
// ............................................................
// ...


  if (strlen(output_filename[0]) < 1) {
    driver_shortname[0] = "MEM";

  }
  // Get output driver
  hDriver = GDALGetDriverByName( driver_shortname[0] );

  // Create the output data set.
  hDstDS = GDALCreate( hDriver, output_filename[0], target_dim[0], target_dim[1],
                       GDALGetRasterCount(po_SrcDS[0]), eDT, NULL );

// ...
// ............................................................
// ...


  Rcpp::List outlist(band.size());

  if (strlen(output_filename[0]) > 0) {
    GDALClose( hDstDS );
    for (int i = 0; i < source_filename.size(); i++) {
      GDALClose( po_SrcDS[i] );
    }
    return outlist;
  }

// else continue onto reading the band values out of MEM

but, it's a bit weird returning empty list or filename, so probably do a bit of work on modularizing first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant